diff --git a/README.md b/README.md index 098c7b0..596da83 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ - [ ] Config requriments - [ ] Forwarding secret insert - [ ] Forwarding type insert - - [ ] Apt installed pakages - - [ ] check on new dependency + - [x] Apt installed pakages + - [x] check on new dependency - [x] Detect change and move - - [ ] Detect status + - [x] Detect status - [x] Iptables add - [ ] File structure - [ ] Datect change and move diff --git a/install.cfg b/install.cfg index bbf007d..b20704a 100644 --- a/install.cfg +++ b/install.cfg @@ -2,7 +2,8 @@ lastUpdateDate= #to version control baseInstallLocation=/opt/velocity/ baseUserName=velocity -dependenciesInstalled=('openjdk-17-jre-headless' 'screen') +dependenciesInstalled=yes +dependencies=('openjdk-17-jre-headless' 'screen') systemdService=yes #if y > update, n > disable autoUpgrade=yes diff --git a/install.sh b/install.sh index 3bfb24a..f2c5376 100755 --- a/install.sh +++ b/install.sh @@ -38,7 +38,6 @@ fi ' ### Base dependencies check -# !TODO it is not bulean old="oDependenciesInstalled" new="dependenciesInstalled" diff --git a/install/base.sh b/install/base.sh index e1d1f8e..03a095e 100644 --- a/install/base.sh +++ b/install/base.sh @@ -1,6 +1,29 @@ #!/bin/bash -# TODO! check for new dependency +### Checks dependencies arrays ### +depDiff=() + +for oPkg in "${oDependencies[@]}"; do + skip= + for pkg in "${dependencies[@]}"; do + [[ $oPkg == $pkg ]] && { skip=1; break; } + done + [[ -n $skip ]] || depDiff+=("$oPkg") +done + +declare -p depDiff + +if [[ ! "${#depDiff[@]}" == 0 ]]; then + printf "These dependencies are newly not requred: ${depDiff[@]} \n" + printf "Do you wish to uninstall them? [Y/n]: \n" + read ansDiff -n 1 + + if [[ "$ansDiff" =~ ("y"|"Y") || -z $ansDiff ]]; then + + apt remove ${depDiff[@]} + + fi +fi ### Checks dependencies ### DepNum=0 @@ -50,7 +73,7 @@ elif [[ "$BaseDep" == "uninstall" && "$DepStatus" == "none" ]]; then elif [[ "$BaseDep" == "uninstall" && "$DepStatus" == ("some"|"all") ]]; then # uninstall - apt remove ${DepMissing[@]} + apt remove ${DepInstalled[@]} elif [[ "$BaseDep" == "report" && "$DepStatus" == "none" ]]; then # nothing to do @@ -58,17 +81,17 @@ elif [[ "$BaseDep" == "report" && "$DepStatus" == "none" ]]; then elif [[ "$BaseDep" == "report" && "$DepStatus" == ("some"|"all") ]]; then printf "Do you want to uinstall these dependencies? [Y/n] printf "${DepInstalled[@]} - read ansReport + read ansReport -n 1 if [[ "$ansReport" =~ ("y"|"Y"|"yes"|"Yes") || -z $ansReport ]]; then - apt remove ${DepMissing[@]} + apt remove ${DepInstalled[@]} else printf "Hope you know what you are doing." fi else # error handeling - + fi diff --git a/install/old.cfg b/install/old.cfg index 473eeb5..271fcaf 100644 --- a/install/old.cfg +++ b/install/old.cfg @@ -4,6 +4,7 @@ oBaseInstallLocation=no oBaseUserName=no oDependenciesInstalled=no #if set to no will do it +oDependencies=('openjdk-17-jre-headless' 'screen') oSystemdService=no #if y > update, n > not oautoUpgrade=no #work in progress