From 8f3af54251ce43ba0adc0f396151ffacb62901f7 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Tue, 5 Apr 2022 12:14:01 +0200 Subject: [PATCH] feat: outsource globals in own file Signed-off-by: Dominik Willner th33xitus@gmail.com --- kiauh.sh | 1 + scripts/backup.sh | 4 -- scripts/fluidd.sh | 5 --- scripts/globals.sh | 68 +++++++++++++++++++++++++++++++ scripts/klipper.sh | 9 ---- scripts/klipperscreen.sh | 7 ---- scripts/mainsail.sh | 6 --- scripts/mjpg-streamer.sh | 2 - scripts/moonraker-telegram-bot.sh | 7 ---- scripts/moonraker.sh | 8 ---- scripts/octoprint.sh | 4 -- scripts/pretty_gcode.sh | 4 -- scripts/utilities.sh | 10 ----- 13 files changed, 69 insertions(+), 66 deletions(-) create mode 100644 scripts/globals.sh diff --git a/kiauh.sh b/kiauh.sh index 93dbfe4..d7e58a7 100755 --- a/kiauh.sh +++ b/kiauh.sh @@ -78,6 +78,7 @@ function kiauh_update_avail(){ #} check_euid +set_globals init_ini kiauh_update_avail main_menu diff --git a/scripts/backup.sh b/scripts/backup.sh index ffa6158..67bdade 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -11,10 +11,6 @@ set -e -### global variables -BACKUP_DIR="${HOME}/kiauh-backups" -KLIPPER_CONFIG="$(get_klipper_cfg_dir)" - function get_date(){ current_date=$(date +"%y%m%d-%H%M") echo "${current_date}" diff --git a/scripts/fluidd.sh b/scripts/fluidd.sh index a15bd31..4ae6232 100644 --- a/scripts/fluidd.sh +++ b/scripts/fluidd.sh @@ -11,11 +11,6 @@ set -e -### global variables -FLUIDD_DIR="${HOME}/fluidd" -FLUIDD_REPO_API="https://api.github.com/repos/fluidd-core/fluidd/releases" -KLIPPER_CONFIG="$(get_klipper_cfg_dir)" - #===================================================# #================== INSTALL FLUIDD =================# #===================================================# diff --git a/scripts/globals.sh b/scripts/globals.sh new file mode 100644 index 0000000..455ce04 --- /dev/null +++ b/scripts/globals.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +#=======================================================================# +# Copyright (C) 2020 - 2022 Dominik Willner # +# # +# This file is part of KIAUH - Klipper Installation And Update Helper # +# https://github.com/th33xitus/kiauh # +# # +# This file may be distributed under the terms of the GNU GPLv3 license # +#=======================================================================# + +set -e + + + +function set_globals(){ + #=================== SYSTEM ===================# + SYSTEMD="/etc/systemd/system" + INITD="/etc/init.d" + ETCDEF="/etc/default" + + #=================== KIAUH ====================# + green=$(echo -en "\e[92m") + yellow=$(echo -en "\e[93m") + red=$(echo -en "\e[91m") + cyan=$(echo -en "\e[96m") + white=$(echo -en "\e[39m") + INI_FILE="${HOME}/.kiauh.ini" + LOGFILE="/tmp/kiauh.log" + BACKUP_DIR="${HOME}/kiauh-backups" + + #================== KLIPPER ===================# + KLIPPY_ENV="${HOME}/klippy-env" + KLIPPER_DIR="${HOME}/klipper" + KLIPPER_REPO="https://github.com/Klipper3d/klipper.git" + KLIPPER_CONFIG="$(get_klipper_cfg_dir)" + + #================= MOONRAKER ==================# + MOONRAKER_ENV="${HOME}/moonraker-env" + MOONRAKER_DIR="${HOME}/moonraker" + MOONRAKER_REPO="https://github.com/Arksine/moonraker.git" + + #================= MAINSAIL ===================# + MAINSAIL_DIR="${HOME}/mainsail" + MAINSAIL_REPO_API="https://api.github.com/repos/mainsail-crew/mainsail/releases" + MAINSAIL_TAGS="https://api.github.com/repos/mainsail-crew/mainsail/tags" + + #================== FLUIDD ====================# + FLUIDD_DIR="${HOME}/fluidd" + FLUIDD_REPO_API="https://api.github.com/repos/fluidd-core/fluidd/releases" + + #=============== KLIPPERSCREEN ================# + KLIPPERSCREEN_ENV_DIR="${HOME}/.KlipperScreen-env" + KLIPPERSCREEN_DIR="${HOME}/KlipperScreen" + KLIPPERSCREEN_REPO=https://github.com/jordanruthe/KlipperScreen.git + + #================ OCTOPRINT ===================# + OCTOPRINT_ENV="${HOME}/OctoPrint" + + #========== MOONRAKER-TELEGRAM-BOT ============# + MOONRAKER_TELEGRAM_BOT_ENV_DIR=${HOME}/moonraker-telegram-bot-env + MOONRAKER_TELEGRAM_BOT_DIR=${HOME}/moonraker-telegram-bot + NLEF_REPO=https://github.com/nlef/moonraker-telegram-bot.git + + #=============== PRETTY-GCODE =================# + PGC_FOR_KLIPPER_REPO="https://github.com/Kragrathea/pgcode" + PGC_DIR="${HOME}/pgcode" +} \ No newline at end of file diff --git a/scripts/klipper.sh b/scripts/klipper.sh index 7c4f642..453dd05 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -11,15 +11,6 @@ set -e -### global variables -SYSTEMD="/etc/systemd/system" -INITD="/etc/init.d" -ETCDEF="/etc/default" -KLIPPY_ENV="${HOME}/klippy-env" -KLIPPER_DIR="${HOME}/klipper" -KLIPPER_REPO="https://github.com/Klipper3d/klipper.git" -KLIPPER_CONFIG="$(get_klipper_cfg_dir)" - #=================================================# #================ INSTALL KLIPPER ================# #=================================================# diff --git a/scripts/klipperscreen.sh b/scripts/klipperscreen.sh index f05e40f..9c3d9cf 100644 --- a/scripts/klipperscreen.sh +++ b/scripts/klipperscreen.sh @@ -11,13 +11,6 @@ set -e -### global variables -SYSTEMD="/etc/systemd/system" -KLIPPERSCREEN_ENV_DIR="${HOME}/.KlipperScreen-env" -KLIPPERSCREEN_DIR="${HOME}/KlipperScreen" -KLIPPERSCREEN_REPO=https://github.com/jordanruthe/KlipperScreen.git -KLIPPER_CONFIG="$(get_klipper_cfg_dir)" - #===================================================# #============== INSTALL KLIPPERSCREEN ==============# #===================================================# diff --git a/scripts/mainsail.sh b/scripts/mainsail.sh index f18e184..eec7fd5 100644 --- a/scripts/mainsail.sh +++ b/scripts/mainsail.sh @@ -11,12 +11,6 @@ set -e -### global variables -MAINSAIL_DIR="${HOME}/mainsail" -MAINSAIL_REPO_API="https://api.github.com/repos/mainsail-crew/mainsail/releases" -MAINSAIL_TAGS="https://api.github.com/repos/mainsail-crew/mainsail/tags" -KLIPPER_CONFIG="$(get_klipper_cfg_dir)" - #===================================================# #================= INSTALL MAINSAIL ================# #===================================================# diff --git a/scripts/mjpg-streamer.sh b/scripts/mjpg-streamer.sh index 4081b6f..1cd2830 100644 --- a/scripts/mjpg-streamer.sh +++ b/scripts/mjpg-streamer.sh @@ -11,8 +11,6 @@ set -e -### base variables -SYSTEMD="/etc/systemd/system" WEBCAMD_SRC="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd" WEBCAM_TXT_SRC="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt" diff --git a/scripts/moonraker-telegram-bot.sh b/scripts/moonraker-telegram-bot.sh index 080b5e0..8ffca16 100644 --- a/scripts/moonraker-telegram-bot.sh +++ b/scripts/moonraker-telegram-bot.sh @@ -11,13 +11,6 @@ set -e -### global variables -SYSTEMD="/etc/systemd/system" -MOONRAKER_TELEGRAM_BOT_ENV_DIR=${HOME}/moonraker-telegram-bot-env -MOONRAKER_TELEGRAM_BOT_DIR=${HOME}/moonraker-telegram-bot -NLEF_REPO=https://github.com/nlef/moonraker-telegram-bot.git -KLIPPER_CONFIG="$(get_klipper_cfg_dir)" - #===================================================# #=========== REMOVE MOONRAKERTELEGRAMBOT ===========# #===================================================# diff --git a/scripts/moonraker.sh b/scripts/moonraker.sh index d35ac76..d7a6fcc 100644 --- a/scripts/moonraker.sh +++ b/scripts/moonraker.sh @@ -11,14 +11,6 @@ set -e -### global variables -SYSTEMD="/etc/systemd/system" -INITD="/etc/init.d" -ETCDEF="/etc/default" -MOONRAKER_ENV="${HOME}/moonraker-env" -MOONRAKER_DIR="${HOME}/moonraker" -MOONRAKER_REPO="https://github.com/Arksine/moonraker.git" - #===================================================# #================ INSTALL MOONRAKER ================# #===================================================# diff --git a/scripts/octoprint.sh b/scripts/octoprint.sh index 9dcc6aa..01552f7 100644 --- a/scripts/octoprint.sh +++ b/scripts/octoprint.sh @@ -11,10 +11,6 @@ set -e -### global variables -SYSTEMD="/etc/systemd/system" -OCTOPRINT_ENV="${HOME}/OctoPrint" - #=================================================# #=============== INSTALL OCTOPRINT ===============# #=================================================# diff --git a/scripts/pretty_gcode.sh b/scripts/pretty_gcode.sh index 22cd4c0..8ca1b53 100644 --- a/scripts/pretty_gcode.sh +++ b/scripts/pretty_gcode.sh @@ -11,10 +11,6 @@ set -e -### base variables -PGC_FOR_KLIPPER_REPO="https://github.com/Kragrathea/pgcode" -PGC_DIR="${HOME}/pgcode" - #=================================================# #================== INSTALL PGC ==================# #=================================================# diff --git a/scripts/utilities.sh b/scripts/utilities.sh index e2ec222..479814d 100644 --- a/scripts/utilities.sh +++ b/scripts/utilities.sh @@ -11,11 +11,6 @@ set -e -### global variables -SYSTEMD="/etc/systemd/system" -INI_FILE="${HOME}/.kiauh.ini" -LOGFILE="/tmp/kiauh.log" - #================================================# #=================== STARTUP ====================# #================================================# @@ -35,11 +30,6 @@ function check_euid(){ #================================================# #============= MESSAGE FORMATTING ===============# #================================================# -green=$(echo -en "\e[92m") -yellow=$(echo -en "\e[93m") -red=$(echo -en "\e[91m") -cyan=$(echo -en "\e[96m") -white=$(echo -en "\e[39m") function select_msg() { echo -e "${white}>>>>>> $1"