diff --git a/README.md b/README.md
index f98afd30..e199193f 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,37 @@
# heavy_script
-Update | Backup | Restore | Mount PVC | Rollback Applications | Sync Catalog | Prune Docker Images
-| Flag | Example | Parameter | Description |
-|------ |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| -r | -r | None | Restore HeavyScript specific 'ix-applications dataset' snapshot |
-| -m | -m | None | Initiates mounting feature
Choose between unmounting and mounting PVC data |
-| -b | -b 14 | int | Backup 'ix-appliactions' dataset
Creates backups up to the number you've chosen |
-| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating |
-| -R | -R | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. |
-| -v | -v | None | Verbose output |
-| -S | -S | None | Shutdown applications prior to updating |
-| -t | -t 150 | int | Set a custom timeout to be used with either:
-m
- Time the script will wait for application to be "STOPPED"
or
-u/U
- Time the script will wait for application to be either "STOPPED" or "ACTIVE" |
-| -s | -s | None | Sync Catalog before updating |
-| -U | -U | None | Update applications, ignoring major version changes |
-| -u | -u | None | Update applications, do NOT update if there was a major version change |
-| -p | -p | None | Prune old/unused docker images |
+## Arguments
+
+| Flag | Example | Parameter | Description |
+|----------- |------------------------ |----------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot |
+| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data |
+| --dns | --dns | None | list all of your applications DNS names and their web ports |
+| -U | -U | None | Update applications, ignoring major version changes |
+| -u | -u | None | Update applications, do NOT update if there was a major version change |
+| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen |
+| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example |
+| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. Warning: deprecating `-R` please begin using `-r` instead |
+| -v | -v | None | Verbose Output Look at the bottom of this page for an example |
+| -S | -S | None | Shutdown the application prior to updating it |
+| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" |
+| -s | -s | None | Sync Catalogs prior to updating |
+| -p | -p | None | Prune old/unused docker images |
+
### Examples
#### Typical Cron Job
```
-bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -Rsup
+bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup
```
- -b is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved
- -i is set to ignore portainer, arch, sonarr, and radarr. These applications will be ignored when it comes to updates.
- -t I set it to 600 seconds, this means the script will wait 600 seconds for the application to become ACTIVE before timing out and continuing to a different application.
-- -R Will rollback applications if they fail to deploy after updating.
+- -r Will rollback applications if they fail to deploy after updating.
- -s will just sync the repositories, ensuring you are downloading the latest updates.
- -u update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually.
- -p Prune docker images.
@@ -36,18 +39,18 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -Rsup
#### Mounting PVC Data
```
-bash /mnt/tank/scripts/heavy_script.sh -t 300 -m
+bash /mnt/tank/scripts/heavy_script.sh -t 300 --mount
```
#### Restoring ix-applications dataset
```
-bash /mnt/tank/scripts/heavy_script/heavy_script.sh -r
+bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore
```
#### My personal Cron Job
```
-git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup
+git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup
```
@@ -106,14 +109,14 @@ Here, we will update the script prior to running it, incase there is a bugfix, o
**Cron Job Command**
```
-git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup
+git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup
```
> The important command here is the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull`
> This command will allow you to preform a `git pull` on a remote directory, which will ensure your script is udated prior to running it
> `&&` Is used to run a command AFTER the previous command completed successfully
->> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -Rsup` command
+>> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` command
@@ -129,7 +132,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr
| Name | Value | Reason |
|------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here |
-| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -Rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -Rsup` |
+| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup` |
| `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. |
| `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you |
| `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. |
@@ -144,8 +147,8 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr
### Additional Informaton
#### Verbose vs Non-Verbose
-- Verbose used `bash heavy_test.sh -b 5 -SRupv`
-- Non-Verbose used `bash heavy_test.sh -b 5 -SRup`
+- Verbose used `bash heavy_script.sh -b 5 -Srupv`
+- Non-Verbose used `bash heavy_script.sh -b 5 -Srup`
| Verbose | Non-Verbose |
|--------- |------------- |
diff --git a/heavy_script.sh b/heavy_script.sh
index 0bed593e..899130d4 100644
--- a/heavy_script.sh
+++ b/heavy_script.sh
@@ -9,6 +9,32 @@ do
case $opt in
-)
case "${OPTARG}" in
+ help)
+ clear -x
+ echo "Basic Utilities"
+ echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data"
+ echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset"
+ echo "--dns | list all of your applications DNS names and their web ports"
+ echo
+ echo "Update Options"
+ echo "-U | Update all applications, ignores versions"
+ echo "-u | Update all applications, does not update Major releases"
+ echo "-b | Back-up your ix-applications dataset, specify a number after -b"
+ echo "-i | Add application to ignore list, one by one, see example below."
+ echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update"
+ echo "-r | Roll-back applications if they fail to update"
+ echo "-S | Shutdown applications prior to updating"
+ echo "-v | verbose output"
+ echo "-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 "-s | sync catalog"
+ echo "-p | Prune unused/old docker images"
+ echo
+ echo "Examples"
+ echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp"
+ echo "bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m"
+ echo "bash /mnt/tank/scripts/heavy_script.sh --mount"
+ exit
+ ;;
dns)
dns="true"
;;
@@ -18,23 +44,6 @@ do
mount)
mount="true"
;;
- help)
- echo "-m | Initiates mounting feature, choose between unmounting and mounting PVC data"
- echo "-r | Opens a menu to restore a heavy_script backup that was taken on you ix-applications pool"
- echo "-b | Back-up your ix-applications dataset, specify a number after -b"
- echo "-i | Add application to ignore list, one by one, see example below."
- echo "-R | Roll-back applications if they fail to update"
- echo "-S | Shutdown applications prior to updating"
- echo "-v | verbose output"
- echo "-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 "-s | sync catalog"
- echo "-U | Update all applications, ignores versions"
- echo "-u | Update all applications, does not update Major releases"
- echo "-p | Prune unused/old docker images"
- echo "EX | bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vRsUp"
- echo "EX | bash /mnt/tank/scripts/heavy_script.sh -t 8812 -m"
- exit
- ;;
*)
echo "Invalid Option -$OPTARG, type --help for help"
@@ -84,6 +93,7 @@ do
;;
R)
rollback="true"
+ echo "WARNING: -R is being transisitioned to -r, this is due to a refactor in the script. Please Make the change ASAP!"
;;
v)
verbose="true"
@@ -342,7 +352,6 @@ echo "Generating DNS Names.."
ignore="cron|kube-system|nvidia|svclb|NAME|memcached"
# Pulling pod names
-
mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$ignore" | sort)
# Pulling all ports
@@ -364,6 +373,7 @@ export -f dns
#exit if incompatable functions are called
[[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit
[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit
+
#Continue to call functions in specific order
[[ "$dns" == "true" ]] && dns && exit
[[ "$restore" == "true" ]] && restore && exit