From ce164b23597b7946e29203c8a0400ba53b2a03c2 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 27 Dec 2022 12:37:53 +0100 Subject: [PATCH] remove unused functions --- functions/menu.sh | 96 -------------------- functions/script_create.sh | 180 ------------------------------------- functions/self_update.sh | 37 -------- 3 files changed, 313 deletions(-) delete mode 100755 functions/menu.sh delete mode 100755 functions/script_create.sh delete mode 100755 functions/self_update.sh diff --git a/functions/menu.sh b/functions/menu.sh deleted file mode 100755 index 8f808c57..00000000 --- a/functions/menu.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - - -menu(){ -clear -x -title -echo "Available Utilities" -echo "-------------------" -echo "1) Help" -echo "2) List DNS Names" -echo "3) Mount and Unmount PVC storage" -echo "4) Backup Options" -echo "5) Update HeavyScript" -echo "6) Update Applications" -echo "7) Command to Container" -echo "8) Patch 22.12.0" -echo "9) Patch 22.12.0 (2)" -echo -echo "0) Exit" -read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - -case $selection in - 0) - echo "Exiting.." - exit - ;; - 1) - help - ;; - 2) - dns - ;; - 3) - mount - ;; - 4) - while [[ $backup_selection != true ]] - do - clear -x - title - echo "Backup Menu" - echo "-----------" - echo "1) Create Backup" - echo "2) Delete Backup" - echo "3) Restore Backup" - echo - echo "0) Exit" - read -rt 120 -p "Please select an option by number: " backup_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $backup_selection in - 0) - echo "Exiting.." - exit - ;; - 1) - read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: The input must be an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - backup_selection=true - ;; - 2) - backup_selection=true - deleteBackup - ;; - 3) - backup_selection=true - restore - ;; - *) - echo "\"$selection\" was not an option, please try agian" && sleep 3 && continue - ;; - esac - done - ;; - - 5) - self_update - ;; - 6) - script_create - ;; - 7) - cmd_to_container - ;; - 8) - patch_2212_backups - ;; - 9) - patch_2212_backups2 - ;; - *) - echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu - ;; -esac -echo -} -export -f menu diff --git a/functions/script_create.sh b/functions/script_create.sh deleted file mode 100755 index 3f1c26e4..00000000 --- a/functions/script_create.sh +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/bash - - -script_create(){ -while true -do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 1 | -U) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-U" "$up_async") - break - fi - done - break - ;; - 2 | -u) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 3 - continue - else - update_selection+=("-u" "$up_async") - break - fi - done - break - ;; - *) - echo "$current_selection was not an option, try again" && sleep 3 - continue - ;; - esac -done -while true -do - clear -x - title - echo "Update Options" - echo "--------------" - echo "1) -r | Roll-back applications if they fail to update" - echo "2) -i | Add application to ignore list" - echo "3) -S | Shutdown applications prior to updating" - echo "4) -v | verbose output" - echo "5) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo - echo "Additional Options" - echo "------------------" - echo "6) -b | Back-up your ix-applications dataset" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo "9) --ignore-img | Ignore container image updates" - echo "10) --self-update | Updates HeavyScript prior to running any other commands" - echo - echo "99) Remove Update Options, Restart" - echo "00) Done making selections, proceed with update" - echo - echo "0) Exit" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 00) - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - ;; - 1 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-r") - ;; - 2 | -i) - read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 3 && continue - update_selection+=("-i" "$up_ignore") - ;; - 3 | -S) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-S") - ;; - 4 | -v) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-v") - ;; - 5 | -t) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "What do you want your timeout to be?" - read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-t" "$up_timeout") - ;; - 6 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-b" "$up_backups") - ;; - 7 | -s) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-s") - ;; - 8 | -p) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-p") - ;; - 9 | --ignore-img ) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--ignore-img" && echo -e "\"--ignore-img\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("--ignore-img") - ;; - 10 | --self-update ) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("--self-update") - ;; - 99) - count=2 - echo "restarting" - for i in "${update_selection[@]:2}" - do - unset "update_selection[$count]" - echo "$i removed" - ((count++)) - done - sleep 3 - continue - ;; - *) - echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue - ;; - esac -done -} -export -f script_create diff --git a/functions/self_update.sh b/functions/self_update.sh deleted file mode 100755 index 32795d01..00000000 --- a/functions/self_update.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - - -args=("$@") -self_update() { - -git fetch --tags &>/dev/null -git reset --hard &>/dev/null -latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)") -echo "🅂 🄴 🄻 🄵" -echo "🅄 🄿 🄳 🄰 🅃 🄴" -if [[ "$hs_version" != "$latest_ver" ]] ; then - echo "Found a new version of HeavyScript, updating myself..." - git checkout "$latest_ver" &>/dev/null - count=0 - for i in "${args[@]}" - do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) - done - echo "Updating from: $hs_version" - echo "Updating To: $latest_ver" - echo "Changelog:" - curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .body - echo - [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit - echo -e "Running the new version...\n\n" - sleep 5 - exec bash "$script_name" "${args[@]}" - # Now exit this old instance - exit -else - echo "HeavyScript is already the latest version:" - echo -e "$hs_version\n\n" -fi -} -export -f self_update