dependencies install + check
This commit is contained in:
parent
4925373994
commit
42986ee5f8
15
README.md
15
README.md
@ -4,20 +4,25 @@
|
|||||||
- [ ] Forwarding secret insert
|
- [ ] Forwarding secret insert
|
||||||
- [ ] Forwarding type insert
|
- [ ] Forwarding type insert
|
||||||
- [ ] Apt installed pakages
|
- [ ] Apt installed pakages
|
||||||
- [ ] on chenge y>n remove
|
- [ ] check on new dependency
|
||||||
- [ ] on change n>y install
|
- [x] Detect change and move
|
||||||
|
- [ ] Detect status
|
||||||
|
- [x] Iptables add
|
||||||
|
- [ ] File structure
|
||||||
|
- [ ] Datect change and move
|
||||||
|
- [ ] User managment
|
||||||
|
- [ ] Datect change and move
|
||||||
- [ ] Insert date in to .cfg
|
- [ ] Insert date in to .cfg
|
||||||
- [ ] Automake old.cfg
|
- [ ] Automake old.cfg
|
||||||
- [ ] AutoUpgrade
|
|
||||||
- [ ] Owner and permisions
|
- [ ] Owner and permisions
|
||||||
- [ ] Starting script to alevate priviliges
|
- [ ] Starting script to elevate priviliges
|
||||||
|
|
||||||
## Modularity
|
## Modularity
|
||||||
- [ ] Break into separate files
|
- [ ] Break into separate files
|
||||||
- [ ] Firewall update
|
- [ ] Firewall update
|
||||||
+ [ ] install iptables
|
|
||||||
- [ ] Whitelists - My players
|
- [ ] Whitelists - My players
|
||||||
- [ ] Base update
|
- [ ] Base update
|
||||||
|
- [ ] Nakolik duverovat old.cfg / check system
|
||||||
- [ ] Mods update
|
- [ ] Mods update
|
||||||
- [ ] Service update
|
- [ ] Service update
|
||||||
- [ ] Tailscale update
|
- [ ] Tailscale update
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
lastUpdateDate= #to version control
|
lastUpdateDate= #to version control
|
||||||
baseInstallLocation=/opt/velocity/
|
baseInstallLocation=/opt/velocity/
|
||||||
baseUserName=velocity
|
baseUserName=velocity
|
||||||
dependenciesInstalled=yes #if set to no will do it
|
dependenciesInstalled=('openjdk-17-jre-headless' 'screen')
|
||||||
systemdService=yes #if y > update, n > not
|
systemdService=yes #if y > update, n > disable
|
||||||
autoUpgrade=yes #work in progress
|
autoUpgrade=yes
|
||||||
|
|
||||||
# Firewall
|
# Firewall
|
||||||
iptables=yes #to check if installed + install
|
iptables=yes #to check if installed + install
|
||||||
|
|||||||
72
install.sh
72
install.sh
@ -1,11 +1,83 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# import configs
|
||||||
|
. install.cfg
|
||||||
|
. install/old.cfg
|
||||||
|
|
||||||
|
|
||||||
#stop service
|
#stop service
|
||||||
systemctl stop mc-forge
|
systemctl stop mc-forge
|
||||||
|
|
||||||
#update system
|
#update system
|
||||||
apt update
|
apt update
|
||||||
|
|
||||||
|
if [[ "$autoUpgrade" == "yes" ]]; then
|
||||||
|
apt upgrade -y
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Template on chack
|
||||||
|
: '
|
||||||
|
old=""
|
||||||
|
new=""
|
||||||
|
|
||||||
|
if [[ "$old" == "yes" && "$new" == "yes" ]]; then
|
||||||
|
# dubble yes
|
||||||
|
echo "check"
|
||||||
|
elif [[ "$old" == "no" && "$new" == "yes" ]]; then
|
||||||
|
# no > yes
|
||||||
|
echo "install"
|
||||||
|
elif [[ "$old" == "no" && "$new" == "no" ]]; then
|
||||||
|
# dubble no
|
||||||
|
echo "report"
|
||||||
|
elif [[ "$old" == "yes" && "$new" == "no" ]]; then
|
||||||
|
# yes > no
|
||||||
|
echo "uninstall"
|
||||||
|
else
|
||||||
|
#error handeling
|
||||||
|
fi
|
||||||
|
'
|
||||||
|
|
||||||
|
### Base dependencies check
|
||||||
|
# !TODO it is not bulean
|
||||||
|
old="oDependenciesInstalled"
|
||||||
|
new="dependenciesInstalled"
|
||||||
|
|
||||||
|
if [[ "$new" == "yes" ]]; then
|
||||||
|
BaseDep="install"
|
||||||
|
elif [[ "$old" == "no"]]; then
|
||||||
|
# dubble no
|
||||||
|
BaseDep="report"
|
||||||
|
elif [[ "$old" == "yes"]]; then
|
||||||
|
# yes > no
|
||||||
|
BaseDep="uninstall"
|
||||||
|
else
|
||||||
|
#error handeling
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Template on chack
|
||||||
|
old=""
|
||||||
|
new=""
|
||||||
|
|
||||||
|
if [[ "$old" == "yes" && "$new" == "yes" ]]; then
|
||||||
|
# dubble yes
|
||||||
|
echo "check"
|
||||||
|
elif [[ "$old" == "no" && "$new" == "yes" ]]; then
|
||||||
|
# no > yes
|
||||||
|
echo "install"
|
||||||
|
elif [[ "$old" == "no" && "$new" == "no" ]]; then
|
||||||
|
# dubble no
|
||||||
|
echo "report"
|
||||||
|
elif [[ "$old" == "yes" && "$new" == "no" ]]; then
|
||||||
|
# yes > no
|
||||||
|
echo "uninstall"
|
||||||
|
else
|
||||||
|
#error handeling
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Differencies betwen install.cfg a install-old.cfg > found what work needs to be done
|
# Differencies betwen install.cfg a install-old.cfg > found what work needs to be done
|
||||||
|
|||||||
@ -1,40 +1,81 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
### --- Dependencies --- ###
|
# TODO! check for new dependency
|
||||||
|
|
||||||
# If no > yes install
|
### Checks dependencies ###
|
||||||
if [[ "$oDependenciesInstalled"="no" && "$dependenciesInstalled"="yes"]]; then
|
DepNum=0
|
||||||
|
DepMissing=()
|
||||||
|
DepInstalled=()
|
||||||
|
|
||||||
printf "+ Installing depandencies \n"
|
if [[ "$iptables" == "yes" ]]; then
|
||||||
apt install openjdk-17-jre-headless screen
|
dependencies+=('iptables')
|
||||||
|
fi
|
||||||
|
|
||||||
|
for pkg in "${dependencies[@]}"; do
|
||||||
|
if [[ '$(dpkg-query -w --showformat="${Status}\n" $pkg | grep "install ok installed")' =~ ("install"|"ok"|"installed") ]]; then
|
||||||
|
# pkg is installed
|
||||||
|
((DepNum++))
|
||||||
|
DepInstalled+=("$pkg")
|
||||||
|
else
|
||||||
|
# pkg is NOT installed
|
||||||
|
DepMissing+=("$pkg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# if yes > no uninstall
|
### Count dependencies ###
|
||||||
if [[ "$oDependenciesInstalled"="yes" && "$dependenciesInstalled"="no"]]; then
|
if [[ "$DepNum" == "${#dependencies[@]}" ]]; then
|
||||||
|
#All dependencies are installed
|
||||||
|
DepStatus="all"
|
||||||
|
elif [[ "${#DepMissing[@]}" == "${#dependencies[@]}" ]]; then
|
||||||
|
#All dependencies are missing
|
||||||
|
DepStatus="none"
|
||||||
|
else
|
||||||
|
#Something is missing
|
||||||
|
DepStatus="some"
|
||||||
|
fi
|
||||||
|
|
||||||
printf "+ UNinstalling depandencies \n"
|
### --- ###
|
||||||
apt remove openjdk-17-jre-headless screen
|
|
||||||
|
|
||||||
|
if [[ "$BaseDep" == ("install") && "$DepStatus" == "all" ]]; then
|
||||||
|
# everything is allright
|
||||||
|
pritnf "it is done bro \n"
|
||||||
|
|
||||||
# if yes > yes update
|
elif [[ "$BaseDep" == ("install") && "$DepStatus" == ("none"|"some") ]]; then
|
||||||
if [[ "$oDependenciesInstalled"="yes" && "$dependenciesInstalled"="yes"]]; then
|
# some or none was installed installing rest
|
||||||
|
apt install ${DepMissing[@]}
|
||||||
|
printf "it is done now bro \n"
|
||||||
|
|
||||||
printf "+ skiping dependencies check \n"
|
elif [[ "$BaseDep" == "uninstall" && "$DepStatus" == "none" ]]; then
|
||||||
|
# uninstall but it is not there
|
||||||
|
|
||||||
|
elif [[ "$BaseDep" == "uninstall" && "$DepStatus" == ("some"|"all") ]]; then
|
||||||
|
# uninstall
|
||||||
|
apt remove ${DepMissing[@]}
|
||||||
|
|
||||||
# if no > no restr
|
elif [[ "$BaseDep" == "report" && "$DepStatus" == "none" ]]; then
|
||||||
if [[ "$oDependenciesInstalled"="no" && "$dependenciesInstalled"="no"]]; then
|
# nothing to do
|
||||||
|
|
||||||
pritf "+ skiping installation of dependencies \n"
|
elif [[ "$BaseDep" == "report" && "$DepStatus" == ("some"|"all") ]]; then
|
||||||
|
printf "Do you want to uinstall these dependencies? [Y/n]
|
||||||
|
printf "${DepInstalled[@]}
|
||||||
|
read ansReport
|
||||||
|
|
||||||
|
if [[ "$ansReport" =~ ("y"|"Y"|"yes"|"Yes") || -z $ansReport ]]; then
|
||||||
|
apt remove ${DepMissing[@]}
|
||||||
|
else
|
||||||
|
printf "Hope you know what you are doing."
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
# error handeling
|
||||||
#error handeling
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### ------------ Needs work ----------- ###
|
||||||
|
|
||||||
|
|
||||||
### --- User managment --- ###
|
### --- User managment --- ###
|
||||||
|
|
||||||
# If no > yes install
|
# If no > yes install
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user