dependencies install + check

This commit is contained in:
godot 2024-08-11 01:28:29 +02:00
parent 4925373994
commit 42986ee5f8
4 changed files with 143 additions and 25 deletions

View File

@ -4,20 +4,25 @@
- [ ] Forwarding secret insert
- [ ] Forwarding type insert
- [ ] Apt installed pakages
- [ ] on chenge y>n remove
- [ ] on change n>y install
- [ ] check on new dependency
- [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
- [ ] Automake old.cfg
- [ ] AutoUpgrade
- [ ] Owner and permisions
- [ ] Starting script to alevate priviliges
- [ ] Starting script to elevate priviliges
## Modularity
- [ ] Break into separate files
- [ ] Firewall update
+ [ ] install iptables
- [ ] Whitelists - My players
- [ ] Base update
- [ ] Nakolik duverovat old.cfg / check system
- [ ] Mods update
- [ ] Service update
- [ ] Tailscale update

View File

@ -2,9 +2,9 @@
lastUpdateDate= #to version control
baseInstallLocation=/opt/velocity/
baseUserName=velocity
dependenciesInstalled=yes #if set to no will do it
systemdService=yes #if y > update, n > not
autoUpgrade=yes #work in progress
dependenciesInstalled=('openjdk-17-jre-headless' 'screen')
systemdService=yes #if y > update, n > disable
autoUpgrade=yes
# Firewall
iptables=yes #to check if installed + install

View File

@ -1,11 +1,83 @@
#!/bin/bash
# import configs
. install.cfg
. install/old.cfg
#stop service
systemctl stop mc-forge
#update system
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

View File

@ -1,40 +1,81 @@
#!/bin/bash
### --- Dependencies --- ###
# TODO! check for new dependency
# If no > yes install
if [[ "$oDependenciesInstalled"="no" && "$dependenciesInstalled"="yes"]]; then
### Checks dependencies ###
DepNum=0
DepMissing=()
DepInstalled=()
printf "+ Installing depandencies \n"
apt install openjdk-17-jre-headless screen
if [[ "$iptables" == "yes" ]]; then
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
if [[ "$oDependenciesInstalled"="yes" && "$dependenciesInstalled"="no"]]; then
### Count dependencies ###
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
if [[ "$oDependenciesInstalled"="yes" && "$dependenciesInstalled"="yes"]]; then
elif [[ "$BaseDep" == ("install") && "$DepStatus" == ("none"|"some") ]]; 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
if [[ "$oDependenciesInstalled"="no" && "$dependenciesInstalled"="no"]]; then
elif [[ "$BaseDep" == "report" && "$DepStatus" == "none" ]]; 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
#error handeling
# error handeling
fi
### ------------ Needs work ----------- ###
### --- User managment --- ###
# If no > yes install