-
Notifications
You must be signed in to change notification settings - Fork 25
/
kgb.sh
75 lines (68 loc) · 2.38 KB
/
kgb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
### Variable info:
#! Variables in CAPS are used across multiple files, for example config values
#! Lowercase variables are usually local to a function
VERSION="2.1.2"
### Get path where script is located and save it to a variable
#! Using this variable will ensure that full paths are used
#! when files are referenced
SCRIPTPATH="$(
cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit
pwd -P
)"
### Initialize variable that tracks changes to the config
UNSAVED_CHANGES=0
### Load all functions
#! Shellcheck directives to make linting not fail on ´source´ commands
#! All files ending in ´.sh´ from ´lib/functions´ and ´lib/ui´ will be loaded
# shellcheck source=lib/functions/advanced.sh
# shellcheck source=lib/functions/backup.sh
# shellcheck source=lib/functions/colors.sh
# shellcheck source=lib/functions/config.sh
# shellcheck source=lib/functions/dialogs.sh
# shellcheck source=lib/functions/general.sh
# shellcheck source=lib/functions/git_install.sh
# shellcheck source=lib/functions/github.sh
# shellcheck source=lib/functions/help.sh
# shellcheck source=lib/functions/install_deps.sh
# shellcheck source=lib/functions/install.sh
# shellcheck source=lib/functions/log_rotation.sh
# shellcheck source=lib/functions/migrate.sh
# shellcheck source=lib/functions/misc.sh
# shellcheck source=lib/functions/restore.sh
# shellcheck source=lib/functions/schedule.sh
# shellcheck source=lib/functions/service_files.sh
# shellcheck source=lib/functions/ssh.sh
# shellcheck source=lib/functions/uninstall.sh
for function_script in "${SCRIPTPATH}/lib/functions/"*.sh; do
source "${function_script}"
done
# shellcheck source=lib/ui/advanced.sh
# shellcheck source=lib/ui/backup_schedule.sh
# shellcheck source=lib/ui/config.sh
# shellcheck source=lib/ui/github.sh
# shellcheck source=lib/ui/log_rotation.sh
# shellcheck source=lib/ui/main.sh
# shellcheck source=lib/ui/menu_elements.sh
# shellcheck source=lib/ui/restore.sh
for ui_script in "${SCRIPTPATH}/lib/ui/"*.sh; do
source "${ui_script}"
done
### Load config
#! If config doesn't exist, defaults will be set
# shellcheck source=sample_backup.cfg
if [[ -f "${HOME}/.config/kgb.cfg" ]]; then
source "${HOME}/.config/kgb.cfg"
else
GIT=1
GITHUB_BRANCH="main"
GIT_SERVER="github.com"
GIT_REPO="klipper-backups-by-kgb"
LOG_ROTATION=1
LOG_RETENTION=3
SCHEDULED_BACKUPS=0
TIME_UNIT=d
BACKUP_INTERVAL=7
fi
### Open main menu
main_menu