style: whitespace between brackets in function declaration
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
4
kiauh.sh
4
kiauh.sh
@@ -21,7 +21,7 @@ for script in "${KIAUH_SRCDIR}/scripts/ui/"*.sh; do . "${script}"; done
|
||||
#=================== UPDATE KIAUH ==================#
|
||||
#===================================================#
|
||||
|
||||
function update_kiauh(){
|
||||
function update_kiauh() {
|
||||
status_msg "Updating KIAUH ..."
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
git reset --hard && git pull
|
||||
@@ -33,7 +33,7 @@ function update_kiauh(){
|
||||
#=================== KIAUH STATUS ==================#
|
||||
#===================================================#
|
||||
|
||||
function kiauh_update_avail(){
|
||||
function kiauh_update_avail() {
|
||||
[[ ! -d "${KIAUH_SRCDIR}/.git" ]] && return
|
||||
local origin head
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#####################################################################
|
||||
################ !!! DO NOT EDIT BELOW THIS LINE !!! ################
|
||||
#####################################################################
|
||||
grab_version(){
|
||||
grab_version() {
|
||||
if [ ! -z "$klipper_folder" ]; then
|
||||
cd "$klipper_folder"
|
||||
klipper_commit=$(git rev-parse --short=7 HEAD)
|
||||
@@ -49,7 +49,7 @@ grab_version(){
|
||||
fi
|
||||
}
|
||||
|
||||
push_config(){
|
||||
push_config() {
|
||||
cd $config_folder
|
||||
git pull
|
||||
git add .
|
||||
|
||||
@@ -11,18 +11,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
function get_date(){
|
||||
function get_date() {
|
||||
current_date=$(date +"%y%m%d-%H%M")
|
||||
echo "${current_date}"
|
||||
}
|
||||
|
||||
function check_for_backup_dir(){
|
||||
function check_for_backup_dir() {
|
||||
[ -d "${BACKUP_DIR}" ] && return
|
||||
status_msg "Create KIAUH backup directory ..."
|
||||
mkdir -p "${BACKUP_DIR}" && ok_msg "Directory created!"
|
||||
}
|
||||
|
||||
function backup_before_update(){
|
||||
function backup_before_update() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
# shellcheck disable=SC2154
|
||||
local state="${backup_before_update}"
|
||||
@@ -30,7 +30,7 @@ function backup_before_update(){
|
||||
backup_"${1}"
|
||||
}
|
||||
|
||||
function backup_printer_cfg(){
|
||||
function backup_printer_cfg() {
|
||||
check_for_backup_dir
|
||||
local current_date
|
||||
if [ -f "${PRINTER_CFG}" ]; then
|
||||
@@ -43,7 +43,7 @@ function backup_printer_cfg(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_klipper_config_dir(){
|
||||
function backup_klipper_config_dir() {
|
||||
check_for_backup_dir
|
||||
local current_date
|
||||
if [ -d "${KLIPPER_CONFIG}" ]; then
|
||||
@@ -59,7 +59,7 @@ function backup_klipper_config_dir(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_moonraker_database(){
|
||||
function backup_moonraker_database() {
|
||||
check_for_backup_dir
|
||||
local current_date databases target_dir
|
||||
|
||||
@@ -81,7 +81,7 @@ function backup_moonraker_database(){
|
||||
return
|
||||
}
|
||||
|
||||
function backup_klipper(){
|
||||
function backup_klipper() {
|
||||
local current_date
|
||||
if [ -d "${KLIPPER_DIR}" ] && [ -d "${KLIPPY_ENV}" ]; then
|
||||
status_msg "Creating Klipper backup ..."
|
||||
@@ -96,7 +96,7 @@ function backup_klipper(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_mainsail(){
|
||||
function backup_mainsail() {
|
||||
local current_date
|
||||
if [ -d "${MAINSAIL_DIR}" ]; then
|
||||
status_msg "Creating Mainsail backup ..."
|
||||
@@ -111,7 +111,7 @@ function backup_mainsail(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_fluidd(){
|
||||
function backup_fluidd() {
|
||||
local current_date
|
||||
if [ -d "${FLUIDD_DIR}" ]; then
|
||||
status_msg "Creating Fluidd backup ..."
|
||||
@@ -126,7 +126,7 @@ function backup_fluidd(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_moonraker(){
|
||||
function backup_moonraker() {
|
||||
local current_date
|
||||
if [ -d "${MOONRAKER_DIR}" ] && [ -d "${MOONRAKER_ENV}" ]; then
|
||||
status_msg "Creating Moonraker backup ..."
|
||||
@@ -141,7 +141,7 @@ function backup_moonraker(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_octoprint(){
|
||||
function backup_octoprint() {
|
||||
local current_date
|
||||
if [ -d "${OCTOPRINT_DIR}" ] && [ -d "${OCTOPRINT_CFG_DIR}" ]; then
|
||||
status_msg "Creating OctoPrint backup ..."
|
||||
@@ -156,7 +156,7 @@ function backup_octoprint(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_klipperscreen(){
|
||||
function backup_klipperscreen() {
|
||||
local current_date
|
||||
if [ -d "${KLIPPERSCREEN_DIR}" ] ; then
|
||||
status_msg "Creating KlipperScreen backup ..."
|
||||
@@ -171,7 +171,7 @@ function backup_klipperscreen(){
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_telegram_bot(){
|
||||
function backup_telegram_bot() {
|
||||
local current_date
|
||||
if [ -d "${MOONRAKER_TELEGRAM_BOT_DIR}" ] ; then
|
||||
status_msg "Creating MoonrakerTelegramBot backup ..."
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function init_flash_process(){
|
||||
function init_flash_process() {
|
||||
local method
|
||||
|
||||
### step 1: check for required userhgroups (tty & dialout)
|
||||
@@ -61,7 +61,7 @@ function init_flash_process(){
|
||||
#================================================#
|
||||
#=================== STEP 2 =====================#
|
||||
#================================================#
|
||||
function select_mcu_connection(){
|
||||
function select_mcu_connection() {
|
||||
top_border
|
||||
echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |"
|
||||
hr
|
||||
@@ -98,7 +98,7 @@ function select_mcu_connection(){
|
||||
done
|
||||
}
|
||||
|
||||
function print_detected_mcu_to_screen(){
|
||||
function print_detected_mcu_to_screen() {
|
||||
local i=1
|
||||
|
||||
if [ "${#mcu_list[@]}" -lt 1 ]; then
|
||||
@@ -117,7 +117,7 @@ function print_detected_mcu_to_screen(){
|
||||
#================================================#
|
||||
#=================== STEP 3 =====================#
|
||||
#================================================#
|
||||
function select_mcu_id(){
|
||||
function select_mcu_id() {
|
||||
local i=0 sel_index=0 method=${1}
|
||||
|
||||
if [ "${#mcu_list[@]}" -lt 1 ]; then
|
||||
@@ -179,7 +179,7 @@ function select_mcu_id(){
|
||||
done
|
||||
}
|
||||
|
||||
function start_flash_mcu(){
|
||||
function start_flash_mcu() {
|
||||
local device=${1}
|
||||
do_action_service "stop" "klipper"
|
||||
if make flash FLASH_DEVICE="${device}"; then
|
||||
@@ -191,7 +191,7 @@ function start_flash_mcu(){
|
||||
do_action_service "start" "klipper"
|
||||
}
|
||||
|
||||
function start_flash_sd(){
|
||||
function start_flash_sd() {
|
||||
local i=0 board_list=() device=${1}
|
||||
local flash_script="${HOME}/klipper/scripts/flash-sdcard.sh"
|
||||
|
||||
@@ -261,7 +261,7 @@ function start_flash_sd(){
|
||||
do_action_service "start" "klipper"
|
||||
}
|
||||
|
||||
function build_fw(){
|
||||
function build_fw() {
|
||||
local python_version
|
||||
|
||||
if [[ ! -d ${KLIPPER_DIR} || ! -d ${KLIPPY_ENV} ]]; then
|
||||
@@ -297,7 +297,7 @@ function build_fw(){
|
||||
#=================== HELPERS ====================#
|
||||
#================================================#
|
||||
|
||||
function get_usb_id(){
|
||||
function get_usb_id() {
|
||||
unset mcu_list
|
||||
sleep 1
|
||||
mcus=$(find /dev/serial/by-id/* 2>/dev/null)
|
||||
@@ -315,7 +315,7 @@ function get_uart_id() {
|
||||
done
|
||||
}
|
||||
|
||||
function show_flash_method_help(){
|
||||
function show_flash_method_help() {
|
||||
top_border
|
||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||
hr
|
||||
@@ -356,7 +356,7 @@ function show_flash_method_help(){
|
||||
done
|
||||
}
|
||||
|
||||
function show_mcu_connection_help(){
|
||||
function show_mcu_connection_help() {
|
||||
top_border
|
||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||
hr
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#================== INSTALL FLUIDD =================#
|
||||
#===================================================#
|
||||
|
||||
function install_fluidd(){
|
||||
function install_fluidd() {
|
||||
### exit early if moonraker not found
|
||||
if [ -z "$(moonraker_systemd)" ]; then
|
||||
local error="Moonraker not installed! Please install Moonraker first!"
|
||||
@@ -89,7 +89,7 @@ function install_fluidd(){
|
||||
print_confirm "Fluidd has been set up!"
|
||||
}
|
||||
|
||||
function install_fluidd_macros(){
|
||||
function install_fluidd_macros() {
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
@@ -121,7 +121,7 @@ function install_fluidd_macros(){
|
||||
return
|
||||
}
|
||||
|
||||
function download_fluidd_macros(){
|
||||
function download_fluidd_macros() {
|
||||
log_info "executing: download_fluidd_macros"
|
||||
local fluidd_cfg="https://raw.githubusercontent.com/fluidd-core/FluiddPI/master/src/modules/fluidd/filesystem/home/pi/klipper_config/fluidd.cfg"
|
||||
local configs
|
||||
@@ -154,7 +154,7 @@ function download_fluidd_macros(){
|
||||
fi
|
||||
}
|
||||
|
||||
function fluidd_setup(){
|
||||
function fluidd_setup() {
|
||||
local url
|
||||
url=$(get_fluidd_download_url)
|
||||
status_msg "Downloading Fluidd ..."
|
||||
@@ -175,13 +175,13 @@ function fluidd_setup(){
|
||||
#================== REMOVE FLUIDD ==================#
|
||||
#===================================================#
|
||||
|
||||
function remove_fluidd_dir(){
|
||||
function remove_fluidd_dir() {
|
||||
[ ! -d "${FLUIDD_DIR}" ] && return
|
||||
status_msg "Removing Fluidd directory ..."
|
||||
rm -rf "${FLUIDD_DIR}" && ok_msg "Directory removed!"
|
||||
}
|
||||
|
||||
function remove_fluidd_config(){
|
||||
function remove_fluidd_config() {
|
||||
if [ -e "/etc/nginx/sites-available/fluidd" ]; then
|
||||
status_msg "Removing Fluidd configuration for Nginx ..."
|
||||
sudo rm "/etc/nginx/sites-available/fluidd" && ok_msg "File removed!"
|
||||
@@ -192,7 +192,7 @@ function remove_fluidd_config(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_fluidd_logs(){
|
||||
function remove_fluidd_logs() {
|
||||
local files
|
||||
files=$(find /var/log/nginx -name "fluidd*")
|
||||
if [ -n "${files}" ]; then
|
||||
@@ -204,7 +204,7 @@ function remove_fluidd_logs(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_fluidd_log_symlinks(){
|
||||
function remove_fluidd_log_symlinks() {
|
||||
local files
|
||||
files=$(find "${KLIPPER_LOGS}" -name "fluidd*")
|
||||
if [ -n "${files}" ]; then
|
||||
@@ -216,7 +216,7 @@ function remove_fluidd_log_symlinks(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_fluidd(){
|
||||
function remove_fluidd() {
|
||||
remove_fluidd_dir
|
||||
remove_fluidd_config
|
||||
remove_fluidd_logs
|
||||
@@ -232,7 +232,7 @@ function remove_fluidd(){
|
||||
#================== UPDATE FLUIDD ==================#
|
||||
#===================================================#
|
||||
|
||||
function update_fluidd(){
|
||||
function update_fluidd() {
|
||||
backup_before_update "fluidd"
|
||||
status_msg "Updating Fluidd ..."
|
||||
fluidd_setup
|
||||
@@ -244,7 +244,7 @@ function update_fluidd(){
|
||||
#================== FLUIDD STATUS ==================#
|
||||
#===================================================#
|
||||
|
||||
function get_fluidd_status(){
|
||||
function get_fluidd_status() {
|
||||
local status
|
||||
local data_arr=("${FLUIDD_DIR}" "${NGINX_SA}/fluidd" "${NGINX_SE}/fluidd")
|
||||
|
||||
@@ -264,21 +264,21 @@ function get_fluidd_status(){
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_fluidd_version(){
|
||||
function get_local_fluidd_version() {
|
||||
local version
|
||||
[ ! -f "${FLUIDD_DIR}/.version" ] && return
|
||||
version=$(head -n 1 "${FLUIDD_DIR}/.version")
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
function get_remote_fluidd_version(){
|
||||
function get_remote_fluidd_version() {
|
||||
local version
|
||||
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
||||
version=$(get_fluidd_download_url | rev | cut -d"/" -f2 | rev)
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
function compare_fluidd_versions(){
|
||||
function compare_fluidd_versions() {
|
||||
unset FLUIDD_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_fluidd_version)"
|
||||
@@ -322,7 +322,7 @@ function get_fluidd_download_url() {
|
||||
fi
|
||||
}
|
||||
|
||||
function fluidd_port_check(){
|
||||
function fluidd_port_check() {
|
||||
if [ "${FLUIDD_ENABLED}" = "false" ]; then
|
||||
if [ "${SITE_ENABLED}" = "true" ]; then
|
||||
status_msg "Detected other enabled interfaces:"
|
||||
@@ -342,7 +342,7 @@ function fluidd_port_check(){
|
||||
fi
|
||||
}
|
||||
|
||||
function select_fluidd_port(){
|
||||
function select_fluidd_port() {
|
||||
if [ "${PORT_80_BLOCKED}" = "true" ]; then
|
||||
echo
|
||||
top_border
|
||||
@@ -373,7 +373,7 @@ function select_fluidd_port(){
|
||||
fi
|
||||
}
|
||||
|
||||
function patch_fluidd_update_manager(){
|
||||
function patch_fluidd_update_manager() {
|
||||
local moonraker_configs
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
|
||||
for conf in ${moonraker_configs}; do
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#======== INSTALL GCODE_SHELL_COMMAND.PY =========#
|
||||
#=================================================#
|
||||
|
||||
function setup_gcode_shell_command(){
|
||||
function setup_gcode_shell_command() {
|
||||
top_border
|
||||
echo -e "| You are about to install the G-Code Shell Command |"
|
||||
echo -e "| extension. Please make sure to read the instructions |"
|
||||
@@ -65,7 +65,7 @@ function setup_gcode_shell_command(){
|
||||
done
|
||||
}
|
||||
|
||||
function install_gcode_shell_command(){
|
||||
function install_gcode_shell_command() {
|
||||
do_action_service "stop" "klipper"
|
||||
status_msg "Copy 'gcode_shell_command.py' to '${KLIPPER_DIR}/klippy/extras' ..."
|
||||
if cp "${KIAUH_SRCDIR}/resources/gcode_shell_command.py" "${KLIPPER_DIR}/klippy/extras"; then
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# shellcheck disable=SC2034
|
||||
set -e
|
||||
|
||||
function set_globals(){
|
||||
function set_globals() {
|
||||
#=================== SYSTEM ===================#
|
||||
SYSTEMD="/etc/systemd/system"
|
||||
INITD="/etc/init.d"
|
||||
|
||||
@@ -35,7 +35,7 @@ function klipper_exists() {
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function klipper_setup_dialog(){
|
||||
function klipper_setup_dialog() {
|
||||
status_msg "Initializing Klipper installation ..."
|
||||
|
||||
local klipper_services
|
||||
@@ -148,7 +148,7 @@ function klipper_setup_dialog(){
|
||||
klipper_setup "${user_input[@]}"
|
||||
}
|
||||
|
||||
function install_klipper_packages(){
|
||||
function install_klipper_packages() {
|
||||
local packages python_version="${1}"
|
||||
local install_script="${HOME}/klipper/scripts/install-debian.sh"
|
||||
|
||||
@@ -184,7 +184,7 @@ function install_klipper_packages(){
|
||||
fi
|
||||
}
|
||||
|
||||
function create_klipper_virtualenv(){
|
||||
function create_klipper_virtualenv() {
|
||||
local python_version="${1}" py2_ver py3_ver
|
||||
|
||||
if [[ ${python_version} == "python2" ]]; then
|
||||
@@ -219,7 +219,7 @@ function create_klipper_virtualenv(){
|
||||
return
|
||||
}
|
||||
|
||||
function klipper_setup(){
|
||||
function klipper_setup() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
### index 0: python version, index 1: instance count, index 2-n: instance names (optional)
|
||||
local user_input=("${@}")
|
||||
@@ -273,7 +273,7 @@ function klipper_setup(){
|
||||
print_confirm "${confirm}" && return
|
||||
}
|
||||
|
||||
function write_klipper_service(){
|
||||
function write_klipper_service() {
|
||||
local i=${1} cfg=${2} log=${3} printer=${4} uds=${5} service=${6}
|
||||
local service_template="${KIAUH_SRCDIR}/resources/klipper.service"
|
||||
|
||||
@@ -288,7 +288,7 @@ function write_klipper_service(){
|
||||
fi
|
||||
}
|
||||
|
||||
function write_example_printer_cfg(){
|
||||
function write_example_printer_cfg() {
|
||||
local cfg_dir=${1} cfg=${2}
|
||||
local cfg_template="${KIAUH_SRCDIR}/resources/printer.cfg"
|
||||
|
||||
@@ -305,7 +305,7 @@ function write_example_printer_cfg(){
|
||||
fi
|
||||
}
|
||||
|
||||
function create_klipper_service(){
|
||||
function create_klipper_service() {
|
||||
local input=("${@}")
|
||||
local klipper_count=${input[0]} && unset "input[0]"
|
||||
local names=("${input[@]}") && unset "input[@]"
|
||||
@@ -438,7 +438,7 @@ function remove_klipper_env() {
|
||||
ok_msg "Directory removed!"
|
||||
}
|
||||
|
||||
function remove_klipper(){
|
||||
function remove_klipper() {
|
||||
remove_klipper_sysvinit
|
||||
remove_klipper_systemd
|
||||
remove_klipper_logs
|
||||
@@ -455,7 +455,7 @@ function remove_klipper(){
|
||||
#================ UPDATE KLIPPER ================#
|
||||
#================================================#
|
||||
|
||||
function update_klipper(){
|
||||
function update_klipper() {
|
||||
do_action_service "stop" "klipper"
|
||||
|
||||
if [[ ! -d ${KLIPPER_DIR} ]]; then
|
||||
@@ -478,7 +478,7 @@ function update_klipper(){
|
||||
#================ KLIPPER STATUS ================#
|
||||
#================================================#
|
||||
|
||||
function get_klipper_status(){
|
||||
function get_klipper_status() {
|
||||
local sf_count status py_ver
|
||||
sf_count="$(klipper_systemd | wc -w)"
|
||||
|
||||
@@ -515,7 +515,7 @@ function get_klipper_status(){
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_klipper_commit(){
|
||||
function get_local_klipper_commit() {
|
||||
[[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
@@ -524,7 +524,7 @@ function get_local_klipper_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function get_remote_klipper_commit(){
|
||||
function get_remote_klipper_commit() {
|
||||
[[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
@@ -533,7 +533,7 @@ function get_remote_klipper_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function compare_klipper_versions(){
|
||||
function compare_klipper_versions() {
|
||||
unset KLIPPER_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_klipper_commit)"
|
||||
|
||||
@@ -21,7 +21,7 @@ function klipperscreen_systemd() {
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function install_klipperscreen(){
|
||||
function install_klipperscreen() {
|
||||
### return early if python version check fails
|
||||
if [ "$(python3_check)" == "false" ]; then
|
||||
local error="Versioncheck failed! Python 3.7 or newer required!\n"
|
||||
@@ -38,7 +38,7 @@ function install_klipperscreen(){
|
||||
do_action_service "restart" "KlipperScreen"
|
||||
}
|
||||
|
||||
function klipperscreen_setup(){
|
||||
function klipperscreen_setup() {
|
||||
local dep=(wget curl unzip dfu-util)
|
||||
dependency_check "${dep[@]}"
|
||||
status_msg "Downloading KlipperScreen ..."
|
||||
@@ -56,7 +56,7 @@ function klipperscreen_setup(){
|
||||
#=============== REMOVE KLIPPERSCREEN ==============#
|
||||
#===================================================#
|
||||
|
||||
function remove_klipperscreen(){
|
||||
function remove_klipperscreen() {
|
||||
### remove KlipperScreen dir
|
||||
if [ -d "${KLIPPERSCREEN_DIR}" ]; then
|
||||
status_msg "Removing KlipperScreen directory ..."
|
||||
@@ -101,7 +101,7 @@ function remove_klipperscreen(){
|
||||
#=============== UPDATE KLIPPERSCREEN ==============#
|
||||
#===================================================#
|
||||
|
||||
function update_klipperscreen(){
|
||||
function update_klipperscreen() {
|
||||
local old_md5
|
||||
old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1)
|
||||
|
||||
@@ -123,7 +123,7 @@ function update_klipperscreen(){
|
||||
#=============== KLIPPERSCREEN STATUS ==============#
|
||||
#===================================================#
|
||||
|
||||
function get_klipperscreen_status(){
|
||||
function get_klipperscreen_status() {
|
||||
local sf_count status
|
||||
sf_count="$(klipperscreen_systemd | wc -w)"
|
||||
|
||||
@@ -147,7 +147,7 @@ function get_klipperscreen_status(){
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_klipperscreen_commit(){
|
||||
function get_local_klipperscreen_commit() {
|
||||
local commit
|
||||
[ ! -d "${KLIPPERSCREEN_DIR}" ] || [ ! -d "${KLIPPERSCREEN_DIR}"/.git ] && return
|
||||
cd "${KLIPPERSCREEN_DIR}"
|
||||
@@ -155,7 +155,7 @@ function get_local_klipperscreen_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function get_remote_klipperscreen_commit(){
|
||||
function get_remote_klipperscreen_commit() {
|
||||
local commit
|
||||
[ ! -d "${KLIPPERSCREEN_DIR}" ] || [ ! -d "${KLIPPERSCREEN_DIR}"/.git ] && return
|
||||
cd "${KLIPPERSCREEN_DIR}" && git fetch origin -q
|
||||
@@ -163,7 +163,7 @@ function get_remote_klipperscreen_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function compare_klipperscreen_versions(){
|
||||
function compare_klipperscreen_versions() {
|
||||
unset KLIPPERSCREEN_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_klipperscreen_commit)"
|
||||
@@ -185,7 +185,7 @@ function compare_klipperscreen_versions(){
|
||||
#=================== HELPERS ====================#
|
||||
#================================================#
|
||||
|
||||
function patch_klipperscreen_update_manager(){
|
||||
function patch_klipperscreen_update_manager() {
|
||||
local moonraker_configs
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
|
||||
for conf in ${moonraker_configs}; do
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#================= INSTALL MAINSAIL ================#
|
||||
#===================================================#
|
||||
|
||||
function install_mainsail(){
|
||||
function install_mainsail() {
|
||||
### exit early if moonraker not found
|
||||
if [ -z "$(moonraker_systemd)" ]; then
|
||||
local error="Moonraker not installed! Please install Moonraker first!"
|
||||
@@ -89,7 +89,7 @@ function install_mainsail(){
|
||||
print_confirm "Mainsail has been set up!"
|
||||
}
|
||||
|
||||
function install_mainsail_macros(){
|
||||
function install_mainsail_macros() {
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
@@ -121,7 +121,7 @@ function install_mainsail_macros(){
|
||||
return
|
||||
}
|
||||
|
||||
function download_mainsail_macros(){
|
||||
function download_mainsail_macros() {
|
||||
log_info "executing: download_mainsail_macros"
|
||||
local ms_cfg="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mainsail/filesystem/home/pi/klipper_config/mainsail.cfg"
|
||||
local configs
|
||||
@@ -154,7 +154,7 @@ function download_mainsail_macros(){
|
||||
fi
|
||||
}
|
||||
|
||||
function mainsail_setup(){
|
||||
function mainsail_setup() {
|
||||
local url
|
||||
url=$(get_mainsail_download_url)
|
||||
status_msg "Downloading Mainsail ..."
|
||||
@@ -180,13 +180,13 @@ function mainsail_setup(){
|
||||
#================= REMOVE MAINSAIL =================#
|
||||
#===================================================#
|
||||
|
||||
function remove_mainsail_dir(){
|
||||
function remove_mainsail_dir() {
|
||||
[ ! -d "${MAINSAIL_DIR}" ] && return
|
||||
status_msg "Removing Mainsail directory ..."
|
||||
rm -rf "${MAINSAIL_DIR}" && ok_msg "Directory removed!"
|
||||
}
|
||||
|
||||
function remove_mainsail_config(){
|
||||
function remove_mainsail_config() {
|
||||
if [ -e "/etc/nginx/sites-available/mainsail" ]; then
|
||||
status_msg "Removing Mainsail configuration for Nginx ..."
|
||||
sudo rm "/etc/nginx/sites-available/mainsail" && ok_msg "File removed!"
|
||||
@@ -197,7 +197,7 @@ function remove_mainsail_config(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_mainsail_logs(){
|
||||
function remove_mainsail_logs() {
|
||||
local files
|
||||
files=$(find /var/log/nginx -name "mainsail*")
|
||||
if [ -n "${files}" ]; then
|
||||
@@ -209,7 +209,7 @@ function remove_mainsail_logs(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_mainsail_log_symlinks(){
|
||||
function remove_mainsail_log_symlinks() {
|
||||
local files
|
||||
files=$(find "${KLIPPER_LOGS}" -name "mainsail*")
|
||||
if [ -n "${files}" ]; then
|
||||
@@ -221,7 +221,7 @@ function remove_mainsail_log_symlinks(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_mainsail(){
|
||||
function remove_mainsail() {
|
||||
remove_mainsail_dir
|
||||
remove_mainsail_config
|
||||
remove_mainsail_logs
|
||||
@@ -237,7 +237,7 @@ function remove_mainsail(){
|
||||
#================= UPDATE MAINSAIL =================#
|
||||
#===================================================#
|
||||
|
||||
function update_mainsail(){
|
||||
function update_mainsail() {
|
||||
backup_before_update "mainsail"
|
||||
status_msg "Updating Mainsail ..."
|
||||
mainsail_setup
|
||||
@@ -249,7 +249,7 @@ function update_mainsail(){
|
||||
#================= MAINSAIL STATUS =================#
|
||||
#===================================================#
|
||||
|
||||
function get_mainsail_status(){
|
||||
function get_mainsail_status() {
|
||||
local status
|
||||
local data_arr=("${MAINSAIL_DIR}" "${NGINX_SA}/mainsail" "${NGINX_SE}/mainsail")
|
||||
|
||||
@@ -269,21 +269,21 @@ function get_mainsail_status(){
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_mainsail_version(){
|
||||
function get_local_mainsail_version() {
|
||||
local version
|
||||
[ ! -f "${MAINSAIL_DIR}/.version" ] && return
|
||||
version=$(head -n 1 "${MAINSAIL_DIR}/.version")
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
function get_remote_mainsail_version(){
|
||||
function get_remote_mainsail_version() {
|
||||
local version
|
||||
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
||||
version=$(get_mainsail_download_url | rev | cut -d"/" -f2 | rev)
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
function compare_mainsail_versions(){
|
||||
function compare_mainsail_versions() {
|
||||
unset MAINSAIL_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_mainsail_version)"
|
||||
@@ -305,7 +305,7 @@ function compare_mainsail_versions(){
|
||||
#=========== MAINSAIL THEME INSTALLER ===========#
|
||||
#================================================#
|
||||
|
||||
function print_theme_list(){
|
||||
function print_theme_list() {
|
||||
local i=0 theme_list=${1}
|
||||
while IFS="," read -r col1 col2 col3 col4; do
|
||||
if [ "${col1}" != "name" ]; then
|
||||
@@ -315,7 +315,7 @@ function print_theme_list(){
|
||||
done <<< "${theme_list}"
|
||||
}
|
||||
|
||||
function ms_theme_installer_menu(){
|
||||
function ms_theme_installer_menu() {
|
||||
local theme_author theme_repo theme_name theme_note theme_url
|
||||
local theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/docs/master/_data/themes.csv"
|
||||
theme_list=$(curl -s -L "${theme_csv_url}")
|
||||
@@ -361,7 +361,7 @@ function ms_theme_installer_menu(){
|
||||
ms_theme_installer_menu
|
||||
}
|
||||
|
||||
function ms_theme_install(){
|
||||
function ms_theme_install() {
|
||||
local path moonraker_count theme_url=${1} theme_name theme_note
|
||||
theme_name=${2} theme_note=${3}
|
||||
|
||||
@@ -391,7 +391,7 @@ function ms_theme_install(){
|
||||
fi
|
||||
}
|
||||
|
||||
function ms_theme_delete(){
|
||||
function ms_theme_delete() {
|
||||
local path
|
||||
path="$(get_klipper_cfg_dir)"
|
||||
moonraker_count=$(moonraker_systemd | wc -w)
|
||||
@@ -438,7 +438,7 @@ function get_mainsail_download_url() {
|
||||
fi
|
||||
}
|
||||
|
||||
function mainsail_port_check(){
|
||||
function mainsail_port_check() {
|
||||
if [ "${MAINSAIL_ENABLED}" = "false" ]; then
|
||||
if [ "${SITE_ENABLED}" = "true" ]; then
|
||||
status_msg "Detected other enabled interfaces:"
|
||||
@@ -458,7 +458,7 @@ function mainsail_port_check(){
|
||||
fi
|
||||
}
|
||||
|
||||
function select_mainsail_port(){
|
||||
function select_mainsail_port() {
|
||||
if [ "${PORT_80_BLOCKED}" = "true" ]; then
|
||||
echo
|
||||
top_border
|
||||
@@ -489,13 +489,13 @@ function select_mainsail_port(){
|
||||
fi
|
||||
}
|
||||
|
||||
function enable_mainsail_remotemode(){
|
||||
function enable_mainsail_remotemode() {
|
||||
[ ! -f "${MAINSAIL_DIR}/config.json" ] && return
|
||||
rm -f "${MAINSAIL_DIR}/config.json"
|
||||
echo -e "{\n \"remoteMode\":true\n}" >> "${MAINSAIL_DIR}/config.json"
|
||||
}
|
||||
|
||||
function patch_mainsail_update_manager(){
|
||||
function patch_mainsail_update_manager() {
|
||||
local moonraker_configs
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
|
||||
for conf in ${moonraker_configs}; do
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#============= INSTALL MJPG-STREAMER =============#
|
||||
#=================================================#
|
||||
|
||||
function install_mjpg-streamer(){
|
||||
function install_mjpg-streamer() {
|
||||
local webcamd="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
|
||||
local webcam_txt="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt"
|
||||
local repo="https://github.com/jacksonliam/mjpg-streamer.git"
|
||||
@@ -149,7 +149,7 @@ EOF
|
||||
#============== REMOVE MJPG-STREAMER =============#
|
||||
#=================================================#
|
||||
|
||||
function remove_mjpg-streamer(){
|
||||
function remove_mjpg-streamer() {
|
||||
### remove MJPG-Streamer service
|
||||
if [ -e "${SYSTEMD}/webcamd.service" ]; then
|
||||
status_msg "Removing MJPG-Streamer service ..."
|
||||
|
||||
@@ -21,7 +21,7 @@ function telegram_bot_systemd() {
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function telegram_bot_setup_dialog(){
|
||||
function telegram_bot_setup_dialog() {
|
||||
status_msg "Initializing Telegram Bot installation ..."
|
||||
|
||||
### return early if moonraker is not installed
|
||||
@@ -107,7 +107,7 @@ function telegram_bot_setup_dialog(){
|
||||
telegram_bot_setup "${user_input[@]}"
|
||||
}
|
||||
|
||||
function install_telegram_bot_dependencies(){
|
||||
function install_telegram_bot_dependencies() {
|
||||
local packages
|
||||
local install_script="${MOONRAKER_TELEGRAM_BOT_DIR}/scripts/install.sh"
|
||||
|
||||
@@ -128,7 +128,7 @@ function install_telegram_bot_dependencies(){
|
||||
sudo apt-get install --yes "${packages[@]}"
|
||||
}
|
||||
|
||||
function create_telegram_bot_virtualenv(){
|
||||
function create_telegram_bot_virtualenv() {
|
||||
status_msg "Installing python virtual environment..."
|
||||
### always create a clean virtualenv
|
||||
[[ -d ${MOONRAKER_TELEGRAM_BOT_ENV_DIR} ]] && rm -rf "${MOONRAKER_TELEGRAM_BOT_ENV_DIR}"
|
||||
@@ -136,7 +136,7 @@ function create_telegram_bot_virtualenv(){
|
||||
"${MOONRAKER_TELEGRAM_BOT_ENV_DIR}"/bin/pip install -r "${MOONRAKER_TELEGRAM_BOT_DIR}/scripts/requirements.txt"
|
||||
}
|
||||
|
||||
function telegram_bot_setup(){
|
||||
function telegram_bot_setup() {
|
||||
local instance_arr=("${@}")
|
||||
### checking dependencies
|
||||
local dep=(git virtualenv)
|
||||
@@ -170,7 +170,7 @@ function telegram_bot_setup(){
|
||||
print_confirm "${confirm}" && return
|
||||
}
|
||||
|
||||
function create_telegram_conf(){
|
||||
function create_telegram_conf() {
|
||||
local input=("${@}")
|
||||
local telegram_bot_count=${input[0]} && unset "input[0]"
|
||||
local names=("${input[@]}") && unset "input[@]"
|
||||
@@ -204,7 +204,7 @@ function create_telegram_conf(){
|
||||
fi
|
||||
}
|
||||
|
||||
function write_telegram_conf(){
|
||||
function write_telegram_conf() {
|
||||
local cfg_dir=${1} cfg=${2} log=${3}
|
||||
local conf_template="${MOONRAKER_TELEGRAM_BOT_DIR}/scripts/base_install_template"
|
||||
[[ ! -d ${cfg_dir} ]] && mkdir -p "${cfg_dir}"
|
||||
@@ -219,7 +219,7 @@ function write_telegram_conf(){
|
||||
fi
|
||||
}
|
||||
|
||||
function create_telegram_bot_service(){
|
||||
function create_telegram_bot_service() {
|
||||
local input=("${@}")
|
||||
local instances=${input[0]} && unset "input[0]"
|
||||
local names=("${input[@]}") && unset "input[@]"
|
||||
@@ -259,7 +259,7 @@ function create_telegram_bot_service(){
|
||||
fi
|
||||
}
|
||||
|
||||
function write_telegram_bot_service(){
|
||||
function write_telegram_bot_service() {
|
||||
local i=${1} cfg=${2} log=${3} service=${4}
|
||||
local service_template="${KIAUH_SRCDIR}/resources/moonraker-telegram-bot.service"
|
||||
|
||||
@@ -326,7 +326,7 @@ function remove_telegram_bot_logs() {
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_telegram_bot(){
|
||||
function remove_telegram_bot() {
|
||||
remove_telegram_bot_systemd
|
||||
remove_telegram_bot_dir
|
||||
remove_telegram_bot_env
|
||||
@@ -340,7 +340,7 @@ function remove_telegram_bot(){
|
||||
#=========== UPDATE MOONRAKERTELEGRAMBOT ===========#
|
||||
#===================================================#
|
||||
|
||||
function update_telegram_bot(){
|
||||
function update_telegram_bot() {
|
||||
do_action_service "stop" "moonraker-telegram-bot"
|
||||
|
||||
if [[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} ]]; then
|
||||
@@ -363,7 +363,7 @@ function update_telegram_bot(){
|
||||
#=========== MOONRAKERTELEGRAMBOT STATUS ===========#
|
||||
#===================================================#
|
||||
|
||||
function get_telegram_bot_status(){
|
||||
function get_telegram_bot_status() {
|
||||
local sf_count status
|
||||
sf_count="$(telegram_bot_systemd | wc -w)"
|
||||
|
||||
@@ -387,7 +387,7 @@ function get_telegram_bot_status(){
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_telegram_bot_commit(){
|
||||
function get_local_telegram_bot_commit() {
|
||||
[[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} || ! -d "${MOONRAKER_TELEGRAM_BOT_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
@@ -396,7 +396,7 @@ function get_local_telegram_bot_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function get_remote_telegram_bot_commit(){
|
||||
function get_remote_telegram_bot_commit() {
|
||||
[[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} || ! -d "${MOONRAKER_TELEGRAM_BOT_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
@@ -405,7 +405,7 @@ function get_remote_telegram_bot_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function compare_telegram_bot_versions(){
|
||||
function compare_telegram_bot_versions() {
|
||||
unset MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_telegram_bot_commit)"
|
||||
|
||||
@@ -21,7 +21,7 @@ function moonraker_systemd() {
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function moonraker_setup_dialog(){
|
||||
function moonraker_setup_dialog() {
|
||||
status_msg "Initializing Moonraker installation ..."
|
||||
|
||||
### return early if python version check fails
|
||||
@@ -125,7 +125,7 @@ function moonraker_setup_dialog(){
|
||||
moonraker_setup "${user_input[@]}"
|
||||
}
|
||||
|
||||
function install_moonraker_dependencies(){
|
||||
function install_moonraker_dependencies() {
|
||||
local packages
|
||||
local install_script="${HOME}/moonraker/scripts/install-moonraker.sh"
|
||||
|
||||
@@ -146,7 +146,7 @@ function install_moonraker_dependencies(){
|
||||
sudo apt-get install --yes "${packages[@]}"
|
||||
}
|
||||
|
||||
function create_moonraker_virtualenv(){
|
||||
function create_moonraker_virtualenv() {
|
||||
status_msg "Installing python virtual environment..."
|
||||
### always create a clean virtualenv
|
||||
[[ -d ${MOONRAKER_ENV} ]] && rm -rf "${MOONRAKER_ENV}"
|
||||
@@ -156,7 +156,7 @@ function create_moonraker_virtualenv(){
|
||||
"${MOONRAKER_ENV}"/bin/pip install -r "${MOONRAKER_DIR}/scripts/moonraker-requirements.txt"
|
||||
}
|
||||
|
||||
function moonraker_setup(){
|
||||
function moonraker_setup() {
|
||||
local instance_arr=("${@}")
|
||||
### checking dependencies
|
||||
local dep=(git wget curl unzip dfu-util virtualenv)
|
||||
@@ -195,7 +195,7 @@ function moonraker_setup(){
|
||||
print_confirm "${confirm}" && print_mr_ip_list "${instance_arr[0]}" && return
|
||||
}
|
||||
|
||||
function create_moonraker_conf(){
|
||||
function create_moonraker_conf() {
|
||||
local input=("${@}")
|
||||
local moonraker_count=${input[0]} && unset "input[0]"
|
||||
local names=("${input[@]}") && unset "input[@]"
|
||||
@@ -237,7 +237,7 @@ function create_moonraker_conf(){
|
||||
fi
|
||||
}
|
||||
|
||||
function write_moonraker_conf(){
|
||||
function write_moonraker_conf() {
|
||||
local cfg_dir=${1} cfg=${2} port=${3} log=${4} db=${5} uds=${6} lan=${7}
|
||||
local conf_template="${KIAUH_SRCDIR}/resources/moonraker.conf"
|
||||
|
||||
@@ -261,7 +261,7 @@ function write_moonraker_conf(){
|
||||
fi
|
||||
}
|
||||
|
||||
function create_moonraker_service(){
|
||||
function create_moonraker_service() {
|
||||
local input=("${@}")
|
||||
local moonraker_count=${input[0]} && unset "input[0]"
|
||||
local names=("${input[@]}") && unset "input[@]"
|
||||
@@ -309,7 +309,7 @@ function create_moonraker_service(){
|
||||
fi
|
||||
}
|
||||
|
||||
function write_moonraker_service(){
|
||||
function write_moonraker_service() {
|
||||
local i=${1} cfg=${2} log=${3} service=${4}
|
||||
local service_template="${KIAUH_SRCDIR}/resources/moonraker.service"
|
||||
|
||||
@@ -325,7 +325,7 @@ function write_moonraker_service(){
|
||||
fi
|
||||
}
|
||||
|
||||
function print_mr_ip_list(){
|
||||
function print_mr_ip_list() {
|
||||
local ip count=${1} port=7125
|
||||
ip=$(hostname -I | cut -d" " -f1)
|
||||
|
||||
@@ -338,7 +338,7 @@ function print_mr_ip_list(){
|
||||
### introduced due to
|
||||
### https://github.com/Arksine/moonraker/issues/349
|
||||
### https://github.com/Arksine/moonraker/pull/346
|
||||
function moonraker_polkit(){
|
||||
function moonraker_polkit() {
|
||||
local has_sup
|
||||
|
||||
### check for required SupplementaryGroups entry in service files
|
||||
@@ -454,7 +454,7 @@ function remove_moonraker_nginx() {
|
||||
}
|
||||
|
||||
|
||||
function remove_moonraker(){
|
||||
function remove_moonraker() {
|
||||
remove_moonraker_sysvinit
|
||||
remove_moonraker_systemd
|
||||
remove_moonraker_logs
|
||||
@@ -472,7 +472,7 @@ function remove_moonraker(){
|
||||
#================ UPDATE MOONRAKER ================#
|
||||
#==================================================#
|
||||
|
||||
function update_moonraker(){
|
||||
function update_moonraker() {
|
||||
do_action_service "stop" "moonraker"
|
||||
|
||||
if [[ ! -d ${MOONRAKER_DIR} ]]; then
|
||||
@@ -498,7 +498,7 @@ function update_moonraker(){
|
||||
#================ MOONRAKER STATUS ================#
|
||||
#==================================================#
|
||||
|
||||
function get_moonraker_status(){
|
||||
function get_moonraker_status() {
|
||||
local sf_count status
|
||||
sf_count="$(moonraker_systemd | wc -w)"
|
||||
|
||||
@@ -523,7 +523,7 @@ function get_moonraker_status(){
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_moonraker_commit(){
|
||||
function get_local_moonraker_commit() {
|
||||
[[ ! -d ${MOONRAKER_DIR} || ! -d "${MOONRAKER_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
@@ -532,7 +532,7 @@ function get_local_moonraker_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function get_remote_moonraker_commit(){
|
||||
function get_remote_moonraker_commit() {
|
||||
[[ ! -d ${MOONRAKER_DIR} || ! -d "${MOONRAKER_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
@@ -541,7 +541,7 @@ function get_remote_moonraker_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function compare_moonraker_versions(){
|
||||
function compare_moonraker_versions() {
|
||||
unset MOONRAKER_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_moonraker_commit)"
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#=================== REMOVE NGINX ==================#
|
||||
#===================================================#
|
||||
|
||||
function remove_nginx(){
|
||||
function remove_nginx() {
|
||||
if [ -f "${SYSTEMD}/nginx.service" ]; then
|
||||
status_msg "Stopping Nginx service ..."
|
||||
sudo systemctl stop nginx && sudo systemctl disable nginx
|
||||
@@ -33,7 +33,7 @@ function remove_nginx(){
|
||||
#===================== HELPERS =====================#
|
||||
#===================================================#
|
||||
|
||||
function set_upstream_nginx_cfg(){
|
||||
function set_upstream_nginx_cfg() {
|
||||
local current_date
|
||||
current_date=$(get_date)
|
||||
local upstreams="${NGINX_CONFD}/upstreams.conf"
|
||||
@@ -60,7 +60,7 @@ function set_upstream_nginx_cfg(){
|
||||
[ ! -f "${common_vars}" ] && sudo cp "${RESOURCES}/common_vars.conf" "${common_vars}"
|
||||
}
|
||||
|
||||
function symlink_webui_nginx_log(){
|
||||
function symlink_webui_nginx_log() {
|
||||
local interface=${1} path="${KLIPPER_LOGS}"
|
||||
local access_log="/var/log/nginx/${interface}-access.log"
|
||||
local error_log="/var/log/nginx/${interface}-error.log"
|
||||
@@ -77,7 +77,7 @@ function symlink_webui_nginx_log(){
|
||||
fi
|
||||
}
|
||||
|
||||
function match_nginx_configs(){
|
||||
function match_nginx_configs() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
local require_service_restart="false"
|
||||
local upstreams="${NGINX_CONFD}/upstreams.conf"
|
||||
@@ -127,7 +127,7 @@ function match_nginx_configs(){
|
||||
[ "${require_service_restart}" == "true" ] && sudo systemctl restart nginx.service
|
||||
}
|
||||
|
||||
function process_disruptive_services(){
|
||||
function process_disruptive_services() {
|
||||
#handle haproxy service
|
||||
if [ "${DISABLE_HAPROXY}" = "true" ] || [ "${REMOVE_HAPROXY}" = "true" ]; then
|
||||
if systemctl is-active haproxy -q; then
|
||||
@@ -189,7 +189,7 @@ function process_disruptive_services(){
|
||||
fi
|
||||
}
|
||||
|
||||
function process_services_dialog(){
|
||||
function process_services_dialog() {
|
||||
#notify user about haproxy or lighttpd services found and possible issues
|
||||
if [ "${HAPROXY_FOUND}" = "true" ] || [ "${LIGHTTPD_FOUND}" = "true" ] || [ "${APACHE2_FOUND}" = "true" ]; then
|
||||
while true; do
|
||||
@@ -239,7 +239,7 @@ function process_services_dialog(){
|
||||
fi
|
||||
}
|
||||
|
||||
function set_nginx_cfg(){
|
||||
function set_nginx_cfg() {
|
||||
local interface=${1}
|
||||
if [ "${SET_NGINX_CFG}" = "true" ]; then
|
||||
local cfg="${RESOURCES}/${interface}"
|
||||
@@ -283,13 +283,13 @@ function set_nginx_cfg(){
|
||||
fi
|
||||
}
|
||||
|
||||
function read_listen_port(){
|
||||
function read_listen_port() {
|
||||
local port interface=${1}
|
||||
port=$(grep listen "/etc/nginx/sites-enabled/${interface}" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||
echo "${port}"
|
||||
}
|
||||
|
||||
function detect_enabled_sites(){
|
||||
function detect_enabled_sites() {
|
||||
MAINSAIL_ENABLED="false" FLUIDD_ENABLED="false" OCTOPRINT_ENABLED="false"
|
||||
#check if there is another UI config already installed and reads the port they are listening on
|
||||
if [ -e "/etc/nginx/sites-enabled/mainsail" ]; then
|
||||
|
||||
@@ -21,7 +21,7 @@ function octoprint_systemd() {
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function octoprint_setup_dialog(){
|
||||
function octoprint_setup_dialog() {
|
||||
status_msg "Initializing OctoPrint installation ..."
|
||||
|
||||
local klipper_services klipper_count user_input=() klipper_names=()
|
||||
@@ -97,7 +97,7 @@ function octoprint_setup_dialog(){
|
||||
octoprint_setup "${user_input[@]}"
|
||||
}
|
||||
|
||||
function octoprint_setup(){
|
||||
function octoprint_setup() {
|
||||
local instance_arr=("${@}")
|
||||
### check and install all dependencies
|
||||
local dep=(
|
||||
@@ -133,7 +133,7 @@ function octoprint_setup(){
|
||||
print_confirm "${confirm}" && print_op_ip_list "${instance_arr[0]}" && return
|
||||
}
|
||||
|
||||
function install_octoprint(){
|
||||
function install_octoprint() {
|
||||
|
||||
function install_octoprint_python_env() {
|
||||
local tmp="${1}"
|
||||
@@ -207,7 +207,7 @@ function install_octoprint(){
|
||||
fi
|
||||
}
|
||||
|
||||
function create_octoprint_service(){
|
||||
function create_octoprint_service() {
|
||||
local input=("${@}")
|
||||
local octoprint_count=${input[0]} && unset "input[0]"
|
||||
local names=("${input[@]}") && unset "input[@]"
|
||||
@@ -279,7 +279,7 @@ CONFIGYAML
|
||||
done
|
||||
}
|
||||
|
||||
function add_reboot_permission(){
|
||||
function add_reboot_permission() {
|
||||
#create a backup if file already exists
|
||||
if [[ -f /etc/sudoers.d/octoprint-shutdown ]]; then
|
||||
sudo mv /etc/sudoers.d/octoprint-shutdown /etc/sudoers.d/octoprint-shutdown.old
|
||||
@@ -293,7 +293,7 @@ function add_reboot_permission(){
|
||||
ok_msg "Permission set!"
|
||||
}
|
||||
|
||||
function print_op_ip_list(){
|
||||
function print_op_ip_list() {
|
||||
local ip octoprint_count="${1}" port=5000
|
||||
ip=$(hostname -I | cut -d" " -f1)
|
||||
|
||||
@@ -307,7 +307,7 @@ function print_op_ip_list(){
|
||||
#=============== REMOVE OCTOPRINT ================#
|
||||
#=================================================#
|
||||
|
||||
function remove_octoprint_service(){
|
||||
function remove_octoprint_service() {
|
||||
[[ -z "$(octoprint_systemd)" ]] && return
|
||||
|
||||
###remove all octoprint services
|
||||
@@ -326,14 +326,14 @@ function remove_octoprint_service(){
|
||||
sudo systemctl reset-failed
|
||||
}
|
||||
|
||||
function remove_octoprint_sudoers(){
|
||||
function remove_octoprint_sudoers() {
|
||||
[[ ! -f /etc/sudoers.d/octoprint-shutdown ]] && return
|
||||
|
||||
### remove sudoers file
|
||||
sudo rm -f /etc/sudoers.d/octoprint-shutdown
|
||||
}
|
||||
|
||||
function remove_octoprint_env(){
|
||||
function remove_octoprint_env() {
|
||||
local files
|
||||
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[0-9a-zA-Z]+)?" | sort)
|
||||
if [[ -n ${files} ]]; then
|
||||
@@ -345,7 +345,7 @@ function remove_octoprint_env(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_octoprint_dir(){
|
||||
function remove_octoprint_dir() {
|
||||
local files
|
||||
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/.octoprint(_[0-9a-zA-Z]+)?" | sort)
|
||||
if [[ -n ${files} ]]; then
|
||||
@@ -357,7 +357,7 @@ function remove_octoprint_dir(){
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_octoprint(){
|
||||
function remove_octoprint() {
|
||||
remove_octoprint_service
|
||||
remove_octoprint_sudoers
|
||||
remove_octoprint_env
|
||||
@@ -374,7 +374,7 @@ function remove_octoprint(){
|
||||
#=============== OCTOPRINT STATUS ================#
|
||||
#=================================================#
|
||||
|
||||
function get_octoprint_status(){
|
||||
function get_octoprint_status() {
|
||||
local sf_count env_count dir_count status
|
||||
sf_count="$(octoprint_systemd | wc -w)"
|
||||
env_count=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[0-9a-zA-Z]+)?" | wc -w)
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#================== INSTALL PGC ==================#
|
||||
#=================================================#
|
||||
|
||||
function install_pgc_for_klipper(){
|
||||
function install_pgc_for_klipper() {
|
||||
pgconfsrc="${PGC_DIR}/pgcode.local.conf"
|
||||
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
|
||||
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
|
||||
@@ -53,7 +53,7 @@ function install_pgc_for_klipper(){
|
||||
#=================== REMOVE PGC ==================#
|
||||
#=================================================#
|
||||
|
||||
function remove_prettygcode(){
|
||||
function remove_prettygcode() {
|
||||
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
|
||||
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
|
||||
if [ -d "${HOME}/pgcode" ] || [ -f "${pgconf}" ] || [ -L "${pgconfsl}" ]; then
|
||||
@@ -72,7 +72,7 @@ function remove_prettygcode(){
|
||||
#=================== UPDATE PGC ==================#
|
||||
#=================================================#
|
||||
|
||||
function update_pgc_for_klipper(){
|
||||
function update_pgc_for_klipper() {
|
||||
PGC_DIR="${HOME}/pgcode"
|
||||
status_msg "Updating PrettyGCode for Klipper ..."
|
||||
cd "${PGC_DIR}" && git pull
|
||||
@@ -83,7 +83,7 @@ function update_pgc_for_klipper(){
|
||||
#=================== PGC STATUS ==================#
|
||||
#=================================================#
|
||||
|
||||
function get_local_prettygcode_commit(){
|
||||
function get_local_prettygcode_commit() {
|
||||
local commit
|
||||
[ ! -d "${PGC_DIR}" ] || [ ! -d "${PGC_DIR}"/.git ] && return
|
||||
cd "${PGC_DIR}"
|
||||
@@ -91,7 +91,7 @@ function get_local_prettygcode_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function get_remote_prettygcode_commit(){
|
||||
function get_remote_prettygcode_commit() {
|
||||
local commit
|
||||
[ ! -d "${PGC_DIR}" ] || [ ! -d "${PGC_DIR}"/.git ] && return
|
||||
cd "${PGC_DIR}" && git fetch origin -q
|
||||
@@ -99,7 +99,7 @@ function get_remote_prettygcode_commit(){
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function compare_prettygcode_versions(){
|
||||
function compare_prettygcode_versions() {
|
||||
unset PGC_UPDATE_AVAIL
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_prettygcode_commit)"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function rollback_menu(){
|
||||
function rollback_menu() {
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function change_klipper_repo_menu(){
|
||||
function change_klipper_repo_menu() {
|
||||
local repo_file="${KIAUH_SRCDIR}/klipper_repos.txt"
|
||||
local repo branch repos=() branches=()
|
||||
|
||||
@@ -94,7 +94,7 @@ function change_klipper_repo_menu(){
|
||||
#=================== HELPERS ====================#
|
||||
#================================================#
|
||||
|
||||
function switch_klipper_repo(){
|
||||
function switch_klipper_repo() {
|
||||
local repo_url branch
|
||||
repo_url="https://github.com/${1}" branch=${2}
|
||||
status_msg "Switching Klipper repository..."
|
||||
@@ -106,7 +106,7 @@ function switch_klipper_repo(){
|
||||
do_action_service "start" "klipper"
|
||||
}
|
||||
|
||||
function show_custom_klipper_repo_help(){
|
||||
function show_custom_klipper_repo_help() {
|
||||
top_border
|
||||
echo -e "| ~~~~ < ? > Help: Custom Klipper repo < ? > ~~~~ |"
|
||||
hr
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function advanced_ui(){
|
||||
function advanced_ui() {
|
||||
top_border
|
||||
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${white} |"
|
||||
hr
|
||||
@@ -26,7 +26,7 @@ function advanced_ui(){
|
||||
back_footer
|
||||
}
|
||||
|
||||
function advanced_menu(){
|
||||
function advanced_menu() {
|
||||
do_action "" "advanced_ui"
|
||||
while true; do
|
||||
read -p "${cyan}####### Perform action:${white} " action
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function backup_ui(){
|
||||
function backup_ui() {
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
@@ -29,7 +29,7 @@ function backup_ui(){
|
||||
back_footer
|
||||
}
|
||||
|
||||
function backup_menu(){
|
||||
function backup_menu() {
|
||||
do_action "" "backup_ui"
|
||||
while true; do
|
||||
read -p "${cyan}####### Perform action:${white} " action
|
||||
|
||||
@@ -12,41 +12,41 @@
|
||||
set -e
|
||||
|
||||
#ui total width = 57 chars
|
||||
function top_border(){
|
||||
function top_border() {
|
||||
echo -e "/=======================================================\\"
|
||||
}
|
||||
|
||||
function bottom_border(){
|
||||
function bottom_border() {
|
||||
echo -e "\=======================================================/"
|
||||
}
|
||||
|
||||
function blank_line(){
|
||||
function blank_line() {
|
||||
echo -e "| |"
|
||||
}
|
||||
|
||||
function hr(){
|
||||
function hr() {
|
||||
echo -e "|-------------------------------------------------------|"
|
||||
}
|
||||
|
||||
function quit_footer(){
|
||||
function quit_footer() {
|
||||
hr
|
||||
echo -e "| ${red}Q) Quit${white} |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
function back_footer(){
|
||||
function back_footer() {
|
||||
hr
|
||||
echo -e "| ${green}B) « Back${white} |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
function back_help_footer(){
|
||||
function back_help_footer() {
|
||||
hr
|
||||
echo -e "| ${green}B) « Back${white} | ${yellow}H) Help [?]${white} |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
function print_header(){
|
||||
function print_header() {
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
|
||||
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
|
||||
@@ -54,7 +54,7 @@ function print_header(){
|
||||
bottom_border
|
||||
}
|
||||
|
||||
function do_action(){
|
||||
function do_action() {
|
||||
clear && print_header
|
||||
### $1 is the action the user wants to fire
|
||||
$1
|
||||
@@ -63,7 +63,7 @@ function do_action(){
|
||||
$2
|
||||
}
|
||||
|
||||
function deny_action(){
|
||||
function deny_action() {
|
||||
clear && print_header
|
||||
print_error "Invalid command!"
|
||||
$1
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function install_ui(){
|
||||
function install_ui() {
|
||||
top_border
|
||||
echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${white} |"
|
||||
hr
|
||||
@@ -32,7 +32,7 @@ function install_ui(){
|
||||
back_footer
|
||||
}
|
||||
|
||||
function install_menu(){
|
||||
function install_menu() {
|
||||
clear && print_header
|
||||
install_ui
|
||||
|
||||
@@ -66,7 +66,7 @@ function install_menu(){
|
||||
install_menu
|
||||
}
|
||||
|
||||
function select_klipper_python_version(){
|
||||
function select_klipper_python_version() {
|
||||
top_border
|
||||
echo -e "| Please select the preferred Python version. | "
|
||||
echo -e "| The recommended version is Python 2.7. | "
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function main_ui(){
|
||||
function main_ui() {
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
@@ -29,20 +29,20 @@ function main_ui(){
|
||||
quit_footer
|
||||
}
|
||||
|
||||
function get_kiauh_version(){
|
||||
function get_kiauh_version() {
|
||||
local version
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
version="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
function print_kiauh_version(){
|
||||
function print_kiauh_version() {
|
||||
local version
|
||||
version="$(printf "%-18s" "$(get_kiauh_version)")"
|
||||
echo "${cyan}${version}${white}"
|
||||
}
|
||||
|
||||
function print_status(){
|
||||
function print_status() {
|
||||
local status component="${1}"
|
||||
status=$(get_"${component}"_status)
|
||||
if [ "${status}" == "Not installed!" ]; then
|
||||
@@ -55,7 +55,7 @@ function print_status(){
|
||||
printf "%-28s" "${status}"
|
||||
}
|
||||
|
||||
function print_klipper_repo(){
|
||||
function print_klipper_repo() {
|
||||
read_kiauh_ini
|
||||
local repo klipper_status
|
||||
klipper_status=$(get_klipper_status)
|
||||
@@ -71,7 +71,7 @@ function print_klipper_repo(){
|
||||
printf "%-28s" "${repo}"
|
||||
}
|
||||
|
||||
function kiauh_update_dialog(){
|
||||
function kiauh_update_dialog() {
|
||||
[ ! "$(kiauh_update_avail)" == "true" ] && return
|
||||
top_border
|
||||
echo -e "|${green} New KIAUH update available! ${white}|"
|
||||
@@ -95,7 +95,7 @@ function kiauh_update_dialog(){
|
||||
done
|
||||
}
|
||||
|
||||
function main_menu(){
|
||||
function main_menu() {
|
||||
print_header
|
||||
#prompt for KIAUH update if update available
|
||||
kiauh_update_dialog
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function remove_ui(){
|
||||
function remove_ui() {
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} |"
|
||||
hr
|
||||
@@ -30,7 +30,7 @@ function remove_ui(){
|
||||
back_footer
|
||||
}
|
||||
|
||||
function remove_menu(){
|
||||
function remove_menu() {
|
||||
do_action "" "remove_ui"
|
||||
while true; do
|
||||
read -p "${cyan}####### Perform action:${white} " action
|
||||
|
||||
@@ -93,7 +93,7 @@ function settings_ui() {
|
||||
back_help_footer
|
||||
}
|
||||
|
||||
function show_settings_help(){
|
||||
function show_settings_help() {
|
||||
local choice default_cfg="${cyan}${HOME}/klipper_config${white}"
|
||||
|
||||
top_border
|
||||
@@ -144,7 +144,7 @@ function show_settings_help(){
|
||||
done
|
||||
}
|
||||
|
||||
function settings_menu(){
|
||||
function settings_menu() {
|
||||
local action
|
||||
|
||||
clear && print_header
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function update_ui(){
|
||||
function update_ui() {
|
||||
top_border
|
||||
echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${white} |"
|
||||
hr
|
||||
@@ -36,7 +36,7 @@ function update_ui(){
|
||||
back_footer
|
||||
}
|
||||
|
||||
function update_menu(){
|
||||
function update_menu() {
|
||||
unset update_arr
|
||||
do_action "" "update_ui"
|
||||
while true; do
|
||||
@@ -71,7 +71,7 @@ function update_menu(){
|
||||
update_menu
|
||||
}
|
||||
|
||||
function update_all(){
|
||||
function update_all() {
|
||||
while true; do
|
||||
if [ "${#update_arr[@]}" = "0" ]; then
|
||||
CONFIRM_MSG="Everything is already up to date!"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
function accept_upload_conditions(){
|
||||
function accept_upload_conditions() {
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~~~~ [ Upload Agreement ] ~~~~~~~~~~~~${white} |"
|
||||
hr
|
||||
@@ -45,7 +45,7 @@ function accept_upload_conditions(){
|
||||
done
|
||||
}
|
||||
|
||||
function upload_selection(){
|
||||
function upload_selection() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
local upload_agreed="${logupload_accepted}"
|
||||
[ "${upload_agreed}" = "false" ] && accept_upload_conditions
|
||||
@@ -54,7 +54,7 @@ function upload_selection(){
|
||||
local klipper_logs="${KLIPPER_LOGS}"
|
||||
local webif_logs="/var/log/nginx"
|
||||
|
||||
function find_logfile(){
|
||||
function find_logfile() {
|
||||
local name=${1} location=${2}
|
||||
for log in $(find "${location}" -maxdepth 1 -type f -name "${name}" | sort -g); do
|
||||
logfiles+=("${log}")
|
||||
@@ -98,7 +98,7 @@ function upload_selection(){
|
||||
done
|
||||
}
|
||||
|
||||
function upload_log(){
|
||||
function upload_log() {
|
||||
local link
|
||||
clear && print_header
|
||||
status_msg "Uploading ${1} ..."
|
||||
|
||||
@@ -15,7 +15,7 @@ set -e
|
||||
#=================== STARTUP ====================#
|
||||
#================================================#
|
||||
|
||||
function check_euid(){
|
||||
function check_euid() {
|
||||
if [[ ${EUID} -eq 0 ]]
|
||||
then
|
||||
echo -e "${red}"
|
||||
@@ -34,26 +34,26 @@ function check_euid(){
|
||||
function select_msg() {
|
||||
echo -e "${white} [➔] ${1}"
|
||||
}
|
||||
function status_msg(){
|
||||
function status_msg() {
|
||||
echo -e "\n${magenta}###### ${1}${white}"
|
||||
}
|
||||
function ok_msg(){
|
||||
function ok_msg() {
|
||||
echo -e "${green}[✓ OK] ${1}${white}"
|
||||
}
|
||||
function warn_msg(){
|
||||
function warn_msg() {
|
||||
echo -e "${yellow}>>>>>> ${1}${white}"
|
||||
}
|
||||
function error_msg(){
|
||||
function error_msg() {
|
||||
echo -e "${red}>>>>>> ${1}${white}"
|
||||
}
|
||||
function abort_msg(){
|
||||
function abort_msg() {
|
||||
echo -e "${red}<<<<<< ${1}${white}"
|
||||
}
|
||||
function title_msg(){
|
||||
function title_msg() {
|
||||
echo -e "${cyan}${1}${white}"
|
||||
}
|
||||
|
||||
function print_error(){
|
||||
function print_error() {
|
||||
[[ -z ${1} ]] && return
|
||||
echo -e "${red}"
|
||||
echo -e "#=======================================================#"
|
||||
@@ -62,7 +62,7 @@ function print_error(){
|
||||
echo -e "${white}"
|
||||
}
|
||||
|
||||
function print_confirm(){
|
||||
function print_confirm() {
|
||||
[[ -z ${1} ]] && return
|
||||
echo -e "${green}"
|
||||
echo -e "#=======================================================#"
|
||||
@@ -109,7 +109,7 @@ function log_error() {
|
||||
#=============== KIAUH SETTINGS =================#
|
||||
#================================================#
|
||||
|
||||
function read_kiauh_ini(){
|
||||
function read_kiauh_ini() {
|
||||
local func=${1}
|
||||
if [[ ! -f ${INI_FILE} ]]; then
|
||||
print_error "ERROR: File '~/.kiauh.ini' not found!"
|
||||
@@ -120,7 +120,7 @@ function read_kiauh_ini(){
|
||||
source "${INI_FILE}"
|
||||
}
|
||||
|
||||
function init_ini(){
|
||||
function init_ini() {
|
||||
### remove pre-version 4 ini files
|
||||
if [[ -f ${INI_FILE} ]] && ! grep -Eq "^# KIAUH v4\.0\.0$" "${INI_FILE}"; then
|
||||
rm "${INI_FILE}"
|
||||
@@ -161,7 +161,7 @@ function init_ini(){
|
||||
fetch_webui_ports
|
||||
}
|
||||
|
||||
function change_klipper_cfg_folder(){
|
||||
function change_klipper_cfg_folder() {
|
||||
local current_cfg_loc example_loc recommended_loc new_cfg_loc
|
||||
current_cfg_loc="$(get_klipper_cfg_dir)"
|
||||
example_loc=$(printf "%s/<your_config_folder>" "${HOME}")
|
||||
@@ -198,7 +198,7 @@ function change_klipper_cfg_folder(){
|
||||
done
|
||||
}
|
||||
|
||||
function set_klipper_cfg_path(){
|
||||
function set_klipper_cfg_path() {
|
||||
local current_cfg_loc="${1}" new_cfg_loc="${2}"
|
||||
local instance klipper_services moonraker_services moonraker_configs
|
||||
|
||||
@@ -321,7 +321,7 @@ function switch_fluidd_releasetype() {
|
||||
fi
|
||||
}
|
||||
|
||||
function toggle_backup_before_update(){
|
||||
function toggle_backup_before_update() {
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
local state="${backup_before_update}"
|
||||
if [[ ${state} = "false" ]]; then
|
||||
@@ -344,7 +344,7 @@ function set_custom_klipper_repo() {
|
||||
#=============== HANDLE SERVICES ================#
|
||||
#================================================#
|
||||
|
||||
function do_action_service(){
|
||||
function do_action_service() {
|
||||
local services action=${1} service=${2}
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/${service}(-[0-9a-zA-Z]+)?.service" | sort)
|
||||
if [[ -n ${services} ]]; then
|
||||
@@ -367,7 +367,7 @@ function do_action_service(){
|
||||
#================================================#
|
||||
|
||||
### returns 'true' if python version >= 3.7
|
||||
function python3_check(){
|
||||
function python3_check() {
|
||||
local major minor passed
|
||||
|
||||
major=$(python3 --version | cut -d" " -f2 | cut -d"." -f1)
|
||||
@@ -382,7 +382,7 @@ function python3_check(){
|
||||
echo "${passed}"
|
||||
}
|
||||
|
||||
function dependency_check(){
|
||||
function dependency_check() {
|
||||
local dep=( "${@}" )
|
||||
local packages
|
||||
status_msg "Checking for the following dependencies:"
|
||||
@@ -412,7 +412,7 @@ function dependency_check(){
|
||||
fi
|
||||
}
|
||||
|
||||
function system_check_webui(){
|
||||
function system_check_webui() {
|
||||
### check system for an installed haproxy service
|
||||
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
|
||||
HAPROXY_FOUND="true"
|
||||
@@ -429,7 +429,7 @@ function system_check_webui(){
|
||||
fi
|
||||
}
|
||||
|
||||
function fetch_webui_ports(){
|
||||
function fetch_webui_ports() {
|
||||
### read ports from possible installed interfaces and write them to ~/.kiauh.ini
|
||||
local port interfaces=("mainsail" "fluidd" "octoprint")
|
||||
for interface in "${interfaces[@]}"; do
|
||||
@@ -451,7 +451,7 @@ function fetch_webui_ports(){
|
||||
#=================== SYSTEM =====================#
|
||||
#================================================#
|
||||
|
||||
function check_system_updates(){
|
||||
function check_system_updates() {
|
||||
local updates_avail info_msg
|
||||
updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||
if [[ -n ${updates_avail} ]]; then
|
||||
@@ -465,7 +465,7 @@ function check_system_updates(){
|
||||
echo "${info_msg}"
|
||||
}
|
||||
|
||||
function update_system(){
|
||||
function update_system() {
|
||||
status_msg "Updating System ..."
|
||||
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y; then
|
||||
print_confirm "Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}"
|
||||
@@ -474,7 +474,7 @@ function update_system(){
|
||||
fi
|
||||
}
|
||||
|
||||
function check_usergroups(){
|
||||
function check_usergroups() {
|
||||
local group_dialout group_tty
|
||||
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
|
||||
group_dialout="false"
|
||||
@@ -523,7 +523,7 @@ function check_usergroups(){
|
||||
fi
|
||||
}
|
||||
|
||||
function set_custom_hostname(){
|
||||
function set_custom_hostname() {
|
||||
echo
|
||||
top_border
|
||||
echo -e "| Changing the hostname of this machine allows you to |"
|
||||
@@ -550,7 +550,7 @@ function set_custom_hostname(){
|
||||
done
|
||||
}
|
||||
|
||||
function change_hostname(){
|
||||
function change_hostname() {
|
||||
local new_hostname regex="^[^\-\_]+([0-9a-z]\-{0,1})+[^\-\_]+$"
|
||||
echo
|
||||
top_border
|
||||
@@ -584,7 +584,7 @@ function change_hostname(){
|
||||
done
|
||||
}
|
||||
|
||||
function set_hostname(){
|
||||
function set_hostname() {
|
||||
local new_hostname=${1} current_date
|
||||
#check for dependencies
|
||||
local dep=(avahi-daemon)
|
||||
|
||||
Reference in New Issue
Block a user