2022-04-21 21:18:27 +00:00
# heavy_script
2022-06-10 20:32:39 +00:00
2022-07-28 22:01:29 +00:00
## Website
2022-08-19 03:36:04 +00:00
[HeavySetup - Further Explanation ](https://heavysetup.info/scripts/heavyscript/about/ )
2022-07-28 22:01:29 +00:00
2022-06-10 21:25:16 +00:00
## Table of contents:
2022-08-19 03:34:00 +00:00
* [Update Arguments ](#update-arguments )
* [Other Utilities ](#other-utilities )
2022-06-10 21:25:16 +00:00
* [How to Install ](#how-to-install )
* [How to Update ](#how-to-update )
* [Creating a Cron Job ](#creating-a-cron-job )
* [Additional Information ](#additional-information )
< br >
2022-06-10 20:32:39 +00:00
2022-08-17 02:19:46 +00:00
## The Menu
2022-08-17 02:20:50 +00:00
![image ](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png )
2022-08-17 02:24:15 +00:00
> Access this with `bash heavy_script.sh`
2022-08-17 02:19:46 +00:00
2022-08-17 02:25:47 +00:00
< br >
2022-08-17 02:19:46 +00:00
< br >
2022-08-17 02:17:19 +00:00
## Update Arguments
2022-09-08 23:19:12 +00:00
| Flag | Example | Parameter | Description |
|---------------|------------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -U | -U < br > -U 5 | Optional Integer | Update applications, ignoring major version changes< br > _Optionally, you can supply a number after the argument to update multiple applications at once_ |
| -u | -u< br > -u 5 | Optional Integer | Update applications, do NOT update if there was a major version change< br > _Optionally, you can supply a number after the argument to update multiple applications at once_ |
| -b | -b 14 | Integer | Snapshot ix-applications dataset< br > _Creates backups UP TO the number you've chosen_ |
| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating< br > _List one application after another as shown in the example_ |
| -r | -r | | Monitors applications after they update< br > If the app does not become "ACTIVE" after the timeout, rollback the application. |
| -v | -v | | Verbose Output< br > _Look at the bottom of this page for an example_ |
| -S | -S | | Shutdown the application prior to updating it |
| -t | -t 400 | Integer | Time in seconds that HeavyScript will wait for an application to no longer be deploying before declaring failure< br > Default: 500 |
| -s | -s | | Sync Catalogs prior to updating |
| -p | -p | | Prune unused docker images |
| --ignore-img | --ignore-img | | Ignore container image updates |
| --self-update | --self-update | | Updates HeavyScript prior to running any other commands |
2022-06-10 20:32:39 +00:00
2022-08-17 02:17:19 +00:00
2022-08-17 02:23:26 +00:00
### Example
2022-09-06 03:59:15 +00:00
#### Cron Job
2022-05-10 19:20:01 +00:00
```
2022-09-08 23:19:12 +00:00
bash heavy_script.sh --self-update -b 10 -i nextcloud -i sonarr -t 600 --ignore-img -rsp -u 5
2022-05-10 19:20:01 +00:00
```
2022-07-29 22:18:44 +00:00
> `-b` is set to 10. Up to 10 snapshots of your ix-applications dataset will be saved
2022-06-10 21:37:59 +00:00
2022-09-06 03:59:15 +00:00
> `-i` is set to ignore __nextcloud__ and __sonarr__. These applications will be skipped if they have an update.
2022-06-10 21:37:59 +00:00
2022-09-06 03:59:15 +00:00
> `-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 rolling back to the previous version since `-r` is used.
2022-06-10 21:37:59 +00:00
2022-09-08 23:19:12 +00:00
> `--ignore-img` Will not update the application if it is only a container image update
2022-09-06 03:59:15 +00:00
> `-r` Will rollback applications if they fail to deploy within the timeout, after updating.
2022-06-10 21:37:59 +00:00
2022-06-10 21:37:20 +00:00
> `-s` will just sync the repositories, ensuring you are downloading the latest updates.
2022-06-10 21:37:59 +00:00
2022-06-10 21:37:20 +00:00
> `-p` Prune docker images.
2022-04-28 01:30:18 +00:00
2022-07-27 00:57:22 +00:00
> `-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.
2022-07-27 00:58:17 +00:00
>> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time
2022-07-27 00:57:22 +00:00
2022-07-27 00:44:55 +00:00
> `--self-update` Will update the script prior to running anything else.
2022-09-08 23:19:12 +00:00
< br >
#### My Personal Cron Job
```
bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10
```
2022-08-17 02:25:47 +00:00
< br >
2022-08-17 02:23:26 +00:00
< br >
## Other Utilities
> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh`
2022-08-18 06:40:40 +00:00
| Flag | Description |
|-----------------|----------------------------------------------------------------------------------------------|
| --mount | Initiates mounting feature, choose between unmounting and mounting PVC data |
| --restore | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset |
| --delete-backup | Opens a menu to delete backups on your system |
| --dns | list all of your applications DNS names and their web ports |
| --cmd | Open a shell for one of your applications |
2022-08-17 02:23:26 +00:00
### Examples
2022-05-10 19:20:01 +00:00
#### Mounting PVC Data
```
2022-09-06 03:59:15 +00:00
bash /mnt/tank/scripts/heavy_script.sh --mount
2022-05-10 19:20:01 +00:00
```
#### Restoring ix-applications dataset
2022-04-28 01:39:44 +00:00
2022-05-10 19:20:01 +00:00
```
2022-06-10 20:32:39 +00:00
bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore
2022-05-10 19:20:01 +00:00
```
2022-04-28 01:39:44 +00:00
2022-06-11 02:04:52 +00:00
#### Deleting Backups
```
2022-06-11 04:41:55 +00:00
bash /mnt/tank/scripts/heavy_script/heavy_script.sh --delete-backup
2022-06-11 02:04:52 +00:00
```
2022-06-10 21:37:20 +00:00
#### List All DNS Names
```
bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns
```
2022-08-17 02:27:11 +00:00
#### Open a Containers Shell
2022-07-29 19:14:34 +00:00
2022-07-29 22:18:44 +00:00
```
2022-08-17 02:27:11 +00:00
bash /mnt/speed/scripts/heavy_script/heavy_script.sh --cmd
2022-05-10 19:20:01 +00:00
```
2022-05-12 01:15:28 +00:00
< br >
< br >
2022-06-05 21:50:10 +00:00
## How to Install
### Create a Scripts Dataset
I created a `scripts` dataset on my Truenas SCALE system, this is where all my scripts will remain.
### Open a Terminal
**Change Directory to your scripts folder**
```
cd /mnt/speed/scripts
```
**Git Clone Heavy_Script**
```
git clone https://github.com/Heavybullets8/heavy_script.git
```
**Change Directory to Heavy_Script folder**
```
cd heavy_script
```
From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS`
2022-07-27 00:44:55 +00:00
> Note: `chmod +x` is NOT required. Doing this will break the `git pull` (or self update) function. Just run the script with `bash heavy_script.sh`
2022-06-05 21:50:10 +00:00
< br >
## How to Update
2022-09-08 23:34:08 +00:00
### Built-In Option (Recommended)
2022-08-19 03:36:04 +00:00
```
bash heavyscript.sh --self-update -b 10 -supr
```
> The important argument here is the `--self-update`, you can still use all of your same arguments with this option.
2022-09-08 23:19:12 +00:00
>> `--self-update` will place users on the latest tag, as well as showing the changelog when new releases come out. So this is the preferred method. Not using this method, will instead place the user on `main` , where the changes are tested, but not as rigerously as they are on the releases.
2022-08-19 03:36:04 +00:00
< br >
2022-06-05 21:50:10 +00:00
### Manually
#### Open a Terminal
**Change Directory to your heavy_script folder**
```
cd /mnt/speed/scripts/heavy_script
```
**git pull**
```
git pull
```
2022-09-08 23:19:12 +00:00
> This is not recommended because the changes to main are not tested as much as the changes that are pushed to releases are tested, think of this method of updating as being in development.
2022-06-05 21:50:10 +00:00
< br >
< br >
## Creating a Cron Job
2022-06-10 21:25:16 +00:00
1. TrueNAS SCALE GUI
2022-06-05 21:50:10 +00:00
2. System Settings
3. Advanced
4. Cron Jobs
1. Click Add
| 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 |
2022-08-17 02:23:26 +00:00
| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -rsp -u 10` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10` |
2022-06-05 21:50:10 +00:00
| `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. |
| `Hide Standard Error` | `False` or Unticked | I want to see any errors that occur |
| `Enabled` | `True` or Ticked | This will Enable the script to run on your schedule |
< br >
< br >
2022-06-10 21:25:16 +00:00
### Additional Information
2022-05-12 01:15:28 +00:00
#### Verbose vs Non-Verbose
2022-06-10 20:32:39 +00:00
- Verbose used `bash heavy_script.sh -b 5 -Srupv`
- Non-Verbose used `bash heavy_script.sh -b 5 -Srup`
2022-05-12 01:15:28 +00:00
| Verbose | Non-Verbose |
|--------- |------------- |
| ![image ](https://user-images.githubusercontent.com/20793231/167971188-07f71d02-8da3-4e0c-b9a0-cd26e7f63613.png ) | ![image ](https://user-images.githubusercontent.com/20793231/167972033-dc8d4ab4-4fb2-4c8a-b7dc-b9311ae55cf8.png ) |