From c7ce5ad36c03c224e4be82ad6391924bd44c2df3 Mon Sep 17 00:00:00 2001 From: Yifei Ding Date: Mon, 8 Nov 2021 17:05:14 -0800 Subject: [PATCH] script: move constants to dedicated files --- kiauh.sh | 43 +--------------------------- scripts/constants/constants.sh | 52 ++++++++++++++++++++++++++++++++++ scripts/constants/strings.sh | 7 +++++ scripts/functions.sh | 3 -- 4 files changed, 60 insertions(+), 45 deletions(-) create mode 100755 scripts/constants/constants.sh create mode 100644 scripts/constants/strings.sh diff --git a/kiauh.sh b/kiauh.sh index b0bb55f..0ca7ea7 100755 --- a/kiauh.sh +++ b/kiauh.sh @@ -15,51 +15,10 @@ default=$(echo -en "\e[39m") ### sourcing all additional scripts SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )" +for script in "${SRCDIR}/kiauh/scripts/constants/"*.sh; do . $script; done for script in "${SRCDIR}/kiauh/scripts/"*.sh; do . $script; done for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . $script; done -### set important directories -#klipper -KLIPPER_DIR=${HOME}/klipper -KLIPPY_ENV=${HOME}/klippy-env -#nginx -NGINX_SA=/etc/nginx/sites-available -NGINX_SE=/etc/nginx/sites-enabled -NGINX_CONFD=/etc/nginx/conf.d -#moonraker -MOONRAKER_DIR=${HOME}/moonraker -MOONRAKER_ENV=${HOME}/moonraker-env -#mainsail -MAINSAIL_DIR=${HOME}/mainsail -#fluidd -FLUIDD_DIR=${HOME}/fluidd -#dwc2 -DWC2FK_DIR=${HOME}/dwc2-for-klipper-socket -DWC_ENV_DIR=${HOME}/dwc-env -DWC2_DIR=${HOME}/duetwebcontrol -#octoprint -OCTOPRINT_DIR=${HOME}/OctoPrint -#KlipperScreen -KLIPPERSCREEN_DIR=${HOME}/KlipperScreen -KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env -#MoonrakerTelegramBot -MOONRAKER_TELEGRAM_BOT_DIR=${HOME}/moonraker-telegram-bot -MOONRAKER_TELEGRAM_BOT_ENV_DIR=${HOME}/moonraker-telegram-bot-env -#misc -INI_FILE=${HOME}/.kiauh.ini -BACKUP_DIR=${HOME}/kiauh-backups - -### set github repos -KLIPPER_REPO=https://github.com/Klipper3d/klipper.git -ARKSINE_REPO=https://github.com/Arksine/klipper.git -DMBUTYUGIN_REPO=https://github.com/dmbutyugin/klipper.git -DWC2FK_REPO=https://github.com/Stephan3/dwc2-for-klipper-socket.git -KLIPPERSCREEN_REPO=https://github.com/jordanruthe/KlipperScreen.git -NLEF_REPO=https://github.com/nlef/moonraker-telegram-bot.git -#branches -BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing -BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping - ### set some messages warn_msg(){ echo -e "${red} $1${default}" diff --git a/scripts/constants/constants.sh b/scripts/constants/constants.sh new file mode 100755 index 0000000..68c44ed --- /dev/null +++ b/scripts/constants/constants.sh @@ -0,0 +1,52 @@ +### set important directories + +#kiauh.sh +#klipper +KLIPPER_DIR=${HOME}/klipper +KLIPPY_ENV=${HOME}/klippy-env +#nginx +NGINX_SA=/etc/nginx/sites-available +NGINX_SE=/etc/nginx/sites-enabled +NGINX_CONFD=/etc/nginx/conf.d +#moonraker +MOONRAKER_DIR=${HOME}/moonraker +MOONRAKER_ENV=${HOME}/moonraker-env +#mainsail +MAINSAIL_DIR=${HOME}/mainsail +#fluidd +FLUIDD_DIR=${HOME}/fluidd +#dwc2 +DWC2FK_DIR=${HOME}/dwc2-for-klipper-socket +DWC_ENV_DIR=${HOME}/dwc-env +DWC2_DIR=${HOME}/duetwebcontrol +#octoprint +OCTOPRINT_DIR=${HOME}/OctoPrint +#KlipperScreen +KLIPPERSCREEN_DIR=${HOME}/KlipperScreen +KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env +#MoonrakerTelegramBot +MOONRAKER_TELEGRAM_BOT_DIR=${HOME}/moonraker-telegram-bot +MOONRAKER_TELEGRAM_BOT_ENV_DIR=${HOME}/moonraker-telegram-bot-env +#misc +INI_FILE=${HOME}/.kiauh.ini +BACKUP_DIR=${HOME}/kiauh-backups + +### set github repos +KLIPPER_REPO=https://github.com/Klipper3d/klipper.git +ARKSINE_REPO=https://github.com/Arksine/klipper.git +DMBUTYUGIN_REPO=https://github.com/dmbutyugin/klipper.git +DWC2FK_REPO=https://github.com/Stephan3/dwc2-for-klipper-socket.git +KLIPPERSCREEN_REPO=https://github.com/jordanruthe/KlipperScreen.git +NLEF_REPO=https://github.com/nlef/moonraker-telegram-bot.git +#branches +BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing +BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping + +###Whiptail +KIAUH_WHIPTAIL_WIDTH=64 +KIAUH_WHIPTAIL_HEIGHT=30 + +#functions.sh +### base variables +SYSTEMDDIR="/etc/systemd/system" + diff --git a/scripts/constants/strings.sh b/scripts/constants/strings.sh new file mode 100644 index 0000000..2bb451a --- /dev/null +++ b/scripts/constants/strings.sh @@ -0,0 +1,7 @@ +# shellcheck shell=bash + +### Universal Strings +# Universal +KIAUH_TITLE="KIAUH - Klipper Installation And Update Helper" + + diff --git a/scripts/functions.sh b/scripts/functions.sh index d4fa030..a9535c1 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -1,6 +1,3 @@ -### base variables -SYSTEMDDIR="/etc/systemd/system" - # setting up some frequently used functions check_euid(){ if [ "$EUID" -eq 0 ]