-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathhelper.sh
executable file
·72 lines (66 loc) · 2.28 KB
/
helper.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
#!/bin/sh
set -e
clear
HELPER_SCRIPT_FOLDER="$(dirname "$(readlink -f "$0")")"
for script in "${HELPER_SCRIPT_FOLDER}/scripts/"*.sh; do . "${script}"; done
for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/"*.sh; do . "${script}"; done
for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/K1/"*.sh; do . "${script}"; done
for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/3V3/"*.sh; do . "${script}"; done
for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/3KE/"*.sh; do . "${script}"; done
for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/10SE/"*.sh; do . "${script}"; done
function update_helper_script() {
echo -e "${white}"
echo -e "Info: Updating Creality Helper Script..."
cd "${HELPER_SCRIPT_FOLDER}"
git reset --hard && git pull
ok_msg "Creality Helper Script has been updated!"
echo -e " ${green}Please restart script to load the new version.${white}"
echo
exit 0
}
function update_available() {
[[ ! -d "${HELPER_SCRIPT_FOLDER}/.git" ]] && return
local remote current
cd "${HELPER_SCRIPT_FOLDER}"
! git branch -a | grep -q "\* main" && return
git fetch -q > /dev/null 2>&1
remote=$(git rev-parse --short=8 FETCH_HEAD)
current=$(git rev-parse --short=8 HEAD)
if [[ ${remote} != "${current}" ]]; then
echo "true"
fi
}
function update_menu() {
local update_available=$(update_available)
if [[ "$update_available" == "true" ]]; then
top_line
title "A new script version is available!" "${green}"
inner_line
hr
echo -e " │ ${cyan}It's recommended to keep script up to date. Updates usually ${white}│"
echo -e " │ ${cyan}contain bug fixes, important changes or new features. ${white}│"
echo -e " │ ${cyan}Please consider updating! ${white}│"
hr
echo -e " │ See changelog here: ${yellow}https://tinyurl.com/3sf3bzck ${white}│"
hr
bottom_line
local yn
while true; do
read -p " Do you want to update now? (${yellow}y${white}/${yellow}n${white}): ${yellow}" yn
case "${yn}" in
Y|y)
run "update_helper_script"
break;;
N|n)
break;;
*)
error_msg "Please select a correct choice!";;
esac
done
fi
}
rm -rf /root/.cache
set_paths
set_permissions
update_menu
main_menu