style: whitespace between brackets in function declaration

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-05-14 19:49:53 +02:00
parent b5572118de
commit 294aa47420
28 changed files with 214 additions and 214 deletions

View File

@@ -21,7 +21,7 @@ for script in "${KIAUH_SRCDIR}/scripts/ui/"*.sh; do . "${script}"; done
#=================== UPDATE KIAUH ==================# #=================== UPDATE KIAUH ==================#
#===================================================# #===================================================#
function update_kiauh(){ function update_kiauh() {
status_msg "Updating KIAUH ..." status_msg "Updating KIAUH ..."
cd "${KIAUH_SRCDIR}" cd "${KIAUH_SRCDIR}"
git reset --hard && git pull git reset --hard && git pull
@@ -33,7 +33,7 @@ function update_kiauh(){
#=================== KIAUH STATUS ==================# #=================== KIAUH STATUS ==================#
#===================================================# #===================================================#
function kiauh_update_avail(){ function kiauh_update_avail() {
[[ ! -d "${KIAUH_SRCDIR}/.git" ]] && return [[ ! -d "${KIAUH_SRCDIR}/.git" ]] && return
local origin head local origin head
cd "${KIAUH_SRCDIR}" cd "${KIAUH_SRCDIR}"

View File

@@ -26,7 +26,7 @@
##################################################################### #####################################################################
################ !!! DO NOT EDIT BELOW THIS LINE !!! ################ ################ !!! DO NOT EDIT BELOW THIS LINE !!! ################
##################################################################### #####################################################################
grab_version(){ grab_version() {
if [ ! -z "$klipper_folder" ]; then if [ ! -z "$klipper_folder" ]; then
cd "$klipper_folder" cd "$klipper_folder"
klipper_commit=$(git rev-parse --short=7 HEAD) klipper_commit=$(git rev-parse --short=7 HEAD)
@@ -49,7 +49,7 @@ grab_version(){
fi fi
} }
push_config(){ push_config() {
cd $config_folder cd $config_folder
git pull git pull
git add . git add .

View File

@@ -11,18 +11,18 @@
set -e set -e
function get_date(){ function get_date() {
current_date=$(date +"%y%m%d-%H%M") current_date=$(date +"%y%m%d-%H%M")
echo "${current_date}" echo "${current_date}"
} }
function check_for_backup_dir(){ function check_for_backup_dir() {
[ -d "${BACKUP_DIR}" ] && return [ -d "${BACKUP_DIR}" ] && return
status_msg "Create KIAUH backup directory ..." status_msg "Create KIAUH backup directory ..."
mkdir -p "${BACKUP_DIR}" && ok_msg "Directory created!" mkdir -p "${BACKUP_DIR}" && ok_msg "Directory created!"
} }
function backup_before_update(){ function backup_before_update() {
read_kiauh_ini "${FUNCNAME[0]}" read_kiauh_ini "${FUNCNAME[0]}"
# shellcheck disable=SC2154 # shellcheck disable=SC2154
local state="${backup_before_update}" local state="${backup_before_update}"
@@ -30,7 +30,7 @@ function backup_before_update(){
backup_"${1}" backup_"${1}"
} }
function backup_printer_cfg(){ function backup_printer_cfg() {
check_for_backup_dir check_for_backup_dir
local current_date local current_date
if [ -f "${PRINTER_CFG}" ]; then if [ -f "${PRINTER_CFG}" ]; then
@@ -43,7 +43,7 @@ function backup_printer_cfg(){
fi fi
} }
function backup_klipper_config_dir(){ function backup_klipper_config_dir() {
check_for_backup_dir check_for_backup_dir
local current_date local current_date
if [ -d "${KLIPPER_CONFIG}" ]; then if [ -d "${KLIPPER_CONFIG}" ]; then
@@ -59,7 +59,7 @@ function backup_klipper_config_dir(){
fi fi
} }
function backup_moonraker_database(){ function backup_moonraker_database() {
check_for_backup_dir check_for_backup_dir
local current_date databases target_dir local current_date databases target_dir
@@ -81,7 +81,7 @@ function backup_moonraker_database(){
return return
} }
function backup_klipper(){ function backup_klipper() {
local current_date local current_date
if [ -d "${KLIPPER_DIR}" ] && [ -d "${KLIPPY_ENV}" ]; then if [ -d "${KLIPPER_DIR}" ] && [ -d "${KLIPPY_ENV}" ]; then
status_msg "Creating Klipper backup ..." status_msg "Creating Klipper backup ..."
@@ -96,7 +96,7 @@ function backup_klipper(){
fi fi
} }
function backup_mainsail(){ function backup_mainsail() {
local current_date local current_date
if [ -d "${MAINSAIL_DIR}" ]; then if [ -d "${MAINSAIL_DIR}" ]; then
status_msg "Creating Mainsail backup ..." status_msg "Creating Mainsail backup ..."
@@ -111,7 +111,7 @@ function backup_mainsail(){
fi fi
} }
function backup_fluidd(){ function backup_fluidd() {
local current_date local current_date
if [ -d "${FLUIDD_DIR}" ]; then if [ -d "${FLUIDD_DIR}" ]; then
status_msg "Creating Fluidd backup ..." status_msg "Creating Fluidd backup ..."
@@ -126,7 +126,7 @@ function backup_fluidd(){
fi fi
} }
function backup_moonraker(){ function backup_moonraker() {
local current_date local current_date
if [ -d "${MOONRAKER_DIR}" ] && [ -d "${MOONRAKER_ENV}" ]; then if [ -d "${MOONRAKER_DIR}" ] && [ -d "${MOONRAKER_ENV}" ]; then
status_msg "Creating Moonraker backup ..." status_msg "Creating Moonraker backup ..."
@@ -141,7 +141,7 @@ function backup_moonraker(){
fi fi
} }
function backup_octoprint(){ function backup_octoprint() {
local current_date local current_date
if [ -d "${OCTOPRINT_DIR}" ] && [ -d "${OCTOPRINT_CFG_DIR}" ]; then if [ -d "${OCTOPRINT_DIR}" ] && [ -d "${OCTOPRINT_CFG_DIR}" ]; then
status_msg "Creating OctoPrint backup ..." status_msg "Creating OctoPrint backup ..."
@@ -156,7 +156,7 @@ function backup_octoprint(){
fi fi
} }
function backup_klipperscreen(){ function backup_klipperscreen() {
local current_date local current_date
if [ -d "${KLIPPERSCREEN_DIR}" ] ; then if [ -d "${KLIPPERSCREEN_DIR}" ] ; then
status_msg "Creating KlipperScreen backup ..." status_msg "Creating KlipperScreen backup ..."
@@ -171,7 +171,7 @@ function backup_klipperscreen(){
fi fi
} }
function backup_telegram_bot(){ function backup_telegram_bot() {
local current_date local current_date
if [ -d "${MOONRAKER_TELEGRAM_BOT_DIR}" ] ; then if [ -d "${MOONRAKER_TELEGRAM_BOT_DIR}" ] ; then
status_msg "Creating MoonrakerTelegramBot backup ..." status_msg "Creating MoonrakerTelegramBot backup ..."

View File

@@ -11,7 +11,7 @@
set -e set -e
function init_flash_process(){ function init_flash_process() {
local method local method
### step 1: check for required userhgroups (tty & dialout) ### step 1: check for required userhgroups (tty & dialout)
@@ -61,7 +61,7 @@ function init_flash_process(){
#================================================# #================================================#
#=================== STEP 2 =====================# #=================== STEP 2 =====================#
#================================================# #================================================#
function select_mcu_connection(){ function select_mcu_connection() {
top_border top_border
echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |" echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |"
hr hr
@@ -98,7 +98,7 @@ function select_mcu_connection(){
done done
} }
function print_detected_mcu_to_screen(){ function print_detected_mcu_to_screen() {
local i=1 local i=1
if [ "${#mcu_list[@]}" -lt 1 ]; then if [ "${#mcu_list[@]}" -lt 1 ]; then
@@ -117,7 +117,7 @@ function print_detected_mcu_to_screen(){
#================================================# #================================================#
#=================== STEP 3 =====================# #=================== STEP 3 =====================#
#================================================# #================================================#
function select_mcu_id(){ function select_mcu_id() {
local i=0 sel_index=0 method=${1} local i=0 sel_index=0 method=${1}
if [ "${#mcu_list[@]}" -lt 1 ]; then if [ "${#mcu_list[@]}" -lt 1 ]; then
@@ -179,7 +179,7 @@ function select_mcu_id(){
done done
} }
function start_flash_mcu(){ function start_flash_mcu() {
local device=${1} local device=${1}
do_action_service "stop" "klipper" do_action_service "stop" "klipper"
if make flash FLASH_DEVICE="${device}"; then if make flash FLASH_DEVICE="${device}"; then
@@ -191,7 +191,7 @@ function start_flash_mcu(){
do_action_service "start" "klipper" do_action_service "start" "klipper"
} }
function start_flash_sd(){ function start_flash_sd() {
local i=0 board_list=() device=${1} local i=0 board_list=() device=${1}
local flash_script="${HOME}/klipper/scripts/flash-sdcard.sh" local flash_script="${HOME}/klipper/scripts/flash-sdcard.sh"
@@ -261,7 +261,7 @@ function start_flash_sd(){
do_action_service "start" "klipper" do_action_service "start" "klipper"
} }
function build_fw(){ function build_fw() {
local python_version local python_version
if [[ ! -d ${KLIPPER_DIR} || ! -d ${KLIPPY_ENV} ]]; then if [[ ! -d ${KLIPPER_DIR} || ! -d ${KLIPPY_ENV} ]]; then
@@ -297,7 +297,7 @@ function build_fw(){
#=================== HELPERS ====================# #=================== HELPERS ====================#
#================================================# #================================================#
function get_usb_id(){ function get_usb_id() {
unset mcu_list unset mcu_list
sleep 1 sleep 1
mcus=$(find /dev/serial/by-id/* 2>/dev/null) mcus=$(find /dev/serial/by-id/* 2>/dev/null)
@@ -315,7 +315,7 @@ function get_uart_id() {
done done
} }
function show_flash_method_help(){ function show_flash_method_help() {
top_border top_border
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |" echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
hr hr
@@ -356,7 +356,7 @@ function show_flash_method_help(){
done done
} }
function show_mcu_connection_help(){ function show_mcu_connection_help() {
top_border top_border
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |" echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
hr hr

View File

@@ -15,7 +15,7 @@ set -e
#================== INSTALL FLUIDD =================# #================== INSTALL FLUIDD =================#
#===================================================# #===================================================#
function install_fluidd(){ function install_fluidd() {
### exit early if moonraker not found ### exit early if moonraker not found
if [ -z "$(moonraker_systemd)" ]; then if [ -z "$(moonraker_systemd)" ]; then
local error="Moonraker not installed! Please install Moonraker first!" local error="Moonraker not installed! Please install Moonraker first!"
@@ -89,7 +89,7 @@ function install_fluidd(){
print_confirm "Fluidd has been set up!" print_confirm "Fluidd has been set up!"
} }
function install_fluidd_macros(){ function install_fluidd_macros() {
while true; do while true; do
echo echo
top_border top_border
@@ -121,7 +121,7 @@ function install_fluidd_macros(){
return return
} }
function download_fluidd_macros(){ function download_fluidd_macros() {
log_info "executing: 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 fluidd_cfg="https://raw.githubusercontent.com/fluidd-core/FluiddPI/master/src/modules/fluidd/filesystem/home/pi/klipper_config/fluidd.cfg"
local configs local configs
@@ -154,7 +154,7 @@ function download_fluidd_macros(){
fi fi
} }
function fluidd_setup(){ function fluidd_setup() {
local url local url
url=$(get_fluidd_download_url) url=$(get_fluidd_download_url)
status_msg "Downloading Fluidd ..." status_msg "Downloading Fluidd ..."
@@ -175,13 +175,13 @@ function fluidd_setup(){
#================== REMOVE FLUIDD ==================# #================== REMOVE FLUIDD ==================#
#===================================================# #===================================================#
function remove_fluidd_dir(){ function remove_fluidd_dir() {
[ ! -d "${FLUIDD_DIR}" ] && return [ ! -d "${FLUIDD_DIR}" ] && return
status_msg "Removing Fluidd directory ..." status_msg "Removing Fluidd directory ..."
rm -rf "${FLUIDD_DIR}" && ok_msg "Directory removed!" rm -rf "${FLUIDD_DIR}" && ok_msg "Directory removed!"
} }
function remove_fluidd_config(){ function remove_fluidd_config() {
if [ -e "/etc/nginx/sites-available/fluidd" ]; then if [ -e "/etc/nginx/sites-available/fluidd" ]; then
status_msg "Removing Fluidd configuration for Nginx ..." status_msg "Removing Fluidd configuration for Nginx ..."
sudo rm "/etc/nginx/sites-available/fluidd" && ok_msg "File removed!" sudo rm "/etc/nginx/sites-available/fluidd" && ok_msg "File removed!"
@@ -192,7 +192,7 @@ function remove_fluidd_config(){
fi fi
} }
function remove_fluidd_logs(){ function remove_fluidd_logs() {
local files local files
files=$(find /var/log/nginx -name "fluidd*") files=$(find /var/log/nginx -name "fluidd*")
if [ -n "${files}" ]; then if [ -n "${files}" ]; then
@@ -204,7 +204,7 @@ function remove_fluidd_logs(){
fi fi
} }
function remove_fluidd_log_symlinks(){ function remove_fluidd_log_symlinks() {
local files local files
files=$(find "${KLIPPER_LOGS}" -name "fluidd*") files=$(find "${KLIPPER_LOGS}" -name "fluidd*")
if [ -n "${files}" ]; then if [ -n "${files}" ]; then
@@ -216,7 +216,7 @@ function remove_fluidd_log_symlinks(){
fi fi
} }
function remove_fluidd(){ function remove_fluidd() {
remove_fluidd_dir remove_fluidd_dir
remove_fluidd_config remove_fluidd_config
remove_fluidd_logs remove_fluidd_logs
@@ -232,7 +232,7 @@ function remove_fluidd(){
#================== UPDATE FLUIDD ==================# #================== UPDATE FLUIDD ==================#
#===================================================# #===================================================#
function update_fluidd(){ function update_fluidd() {
backup_before_update "fluidd" backup_before_update "fluidd"
status_msg "Updating Fluidd ..." status_msg "Updating Fluidd ..."
fluidd_setup fluidd_setup
@@ -244,7 +244,7 @@ function update_fluidd(){
#================== FLUIDD STATUS ==================# #================== FLUIDD STATUS ==================#
#===================================================# #===================================================#
function get_fluidd_status(){ function get_fluidd_status() {
local status local status
local data_arr=("${FLUIDD_DIR}" "${NGINX_SA}/fluidd" "${NGINX_SE}/fluidd") local data_arr=("${FLUIDD_DIR}" "${NGINX_SA}/fluidd" "${NGINX_SE}/fluidd")
@@ -264,21 +264,21 @@ function get_fluidd_status(){
echo "${status}" echo "${status}"
} }
function get_local_fluidd_version(){ function get_local_fluidd_version() {
local version local version
[ ! -f "${FLUIDD_DIR}/.version" ] && return [ ! -f "${FLUIDD_DIR}/.version" ] && return
version=$(head -n 1 "${FLUIDD_DIR}/.version") version=$(head -n 1 "${FLUIDD_DIR}/.version")
echo "${version}" echo "${version}"
} }
function get_remote_fluidd_version(){ function get_remote_fluidd_version() {
local version local version
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
version=$(get_fluidd_download_url | rev | cut -d"/" -f2 | rev) version=$(get_fluidd_download_url | rev | cut -d"/" -f2 | rev)
echo "${version}" echo "${version}"
} }
function compare_fluidd_versions(){ function compare_fluidd_versions() {
unset FLUIDD_UPDATE_AVAIL unset FLUIDD_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_fluidd_version)" local_ver="$(get_local_fluidd_version)"
@@ -322,7 +322,7 @@ function get_fluidd_download_url() {
fi fi
} }
function fluidd_port_check(){ function fluidd_port_check() {
if [ "${FLUIDD_ENABLED}" = "false" ]; then if [ "${FLUIDD_ENABLED}" = "false" ]; then
if [ "${SITE_ENABLED}" = "true" ]; then if [ "${SITE_ENABLED}" = "true" ]; then
status_msg "Detected other enabled interfaces:" status_msg "Detected other enabled interfaces:"
@@ -342,7 +342,7 @@ function fluidd_port_check(){
fi fi
} }
function select_fluidd_port(){ function select_fluidd_port() {
if [ "${PORT_80_BLOCKED}" = "true" ]; then if [ "${PORT_80_BLOCKED}" = "true" ]; then
echo echo
top_border top_border
@@ -373,7 +373,7 @@ function select_fluidd_port(){
fi fi
} }
function patch_fluidd_update_manager(){ function patch_fluidd_update_manager() {
local moonraker_configs local moonraker_configs
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort) moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
for conf in ${moonraker_configs}; do for conf in ${moonraker_configs}; do

View File

@@ -15,7 +15,7 @@ set -e
#======== INSTALL GCODE_SHELL_COMMAND.PY =========# #======== INSTALL GCODE_SHELL_COMMAND.PY =========#
#=================================================# #=================================================#
function setup_gcode_shell_command(){ function setup_gcode_shell_command() {
top_border top_border
echo -e "| You are about to install the G-Code Shell Command |" echo -e "| You are about to install the G-Code Shell Command |"
echo -e "| extension. Please make sure to read the instructions |" echo -e "| extension. Please make sure to read the instructions |"
@@ -65,7 +65,7 @@ function setup_gcode_shell_command(){
done done
} }
function install_gcode_shell_command(){ function install_gcode_shell_command() {
do_action_service "stop" "klipper" do_action_service "stop" "klipper"
status_msg "Copy 'gcode_shell_command.py' to '${KLIPPER_DIR}/klippy/extras' ..." 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 if cp "${KIAUH_SRCDIR}/resources/gcode_shell_command.py" "${KLIPPER_DIR}/klippy/extras"; then

View File

@@ -12,7 +12,7 @@
# shellcheck disable=SC2034 # shellcheck disable=SC2034
set -e set -e
function set_globals(){ function set_globals() {
#=================== SYSTEM ===================# #=================== SYSTEM ===================#
SYSTEMD="/etc/systemd/system" SYSTEMD="/etc/systemd/system"
INITD="/etc/init.d" INITD="/etc/init.d"

View File

@@ -35,7 +35,7 @@ function klipper_exists() {
echo "${services}" echo "${services}"
} }
function klipper_setup_dialog(){ function klipper_setup_dialog() {
status_msg "Initializing Klipper installation ..." status_msg "Initializing Klipper installation ..."
local klipper_services local klipper_services
@@ -148,7 +148,7 @@ function klipper_setup_dialog(){
klipper_setup "${user_input[@]}" klipper_setup "${user_input[@]}"
} }
function install_klipper_packages(){ function install_klipper_packages() {
local packages python_version="${1}" local packages python_version="${1}"
local install_script="${HOME}/klipper/scripts/install-debian.sh" local install_script="${HOME}/klipper/scripts/install-debian.sh"
@@ -184,7 +184,7 @@ function install_klipper_packages(){
fi fi
} }
function create_klipper_virtualenv(){ function create_klipper_virtualenv() {
local python_version="${1}" py2_ver py3_ver local python_version="${1}" py2_ver py3_ver
if [[ ${python_version} == "python2" ]]; then if [[ ${python_version} == "python2" ]]; then
@@ -219,7 +219,7 @@ function create_klipper_virtualenv(){
return return
} }
function klipper_setup(){ function klipper_setup() {
read_kiauh_ini "${FUNCNAME[0]}" read_kiauh_ini "${FUNCNAME[0]}"
### index 0: python version, index 1: instance count, index 2-n: instance names (optional) ### index 0: python version, index 1: instance count, index 2-n: instance names (optional)
local user_input=("${@}") local user_input=("${@}")
@@ -273,7 +273,7 @@ function klipper_setup(){
print_confirm "${confirm}" && return 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 i=${1} cfg=${2} log=${3} printer=${4} uds=${5} service=${6}
local service_template="${KIAUH_SRCDIR}/resources/klipper.service" local service_template="${KIAUH_SRCDIR}/resources/klipper.service"
@@ -288,7 +288,7 @@ function write_klipper_service(){
fi fi
} }
function write_example_printer_cfg(){ function write_example_printer_cfg() {
local cfg_dir=${1} cfg=${2} local cfg_dir=${1} cfg=${2}
local cfg_template="${KIAUH_SRCDIR}/resources/printer.cfg" local cfg_template="${KIAUH_SRCDIR}/resources/printer.cfg"
@@ -305,7 +305,7 @@ function write_example_printer_cfg(){
fi fi
} }
function create_klipper_service(){ function create_klipper_service() {
local input=("${@}") local input=("${@}")
local klipper_count=${input[0]} && unset "input[0]" local klipper_count=${input[0]} && unset "input[0]"
local names=("${input[@]}") && unset "input[@]" local names=("${input[@]}") && unset "input[@]"
@@ -438,7 +438,7 @@ function remove_klipper_env() {
ok_msg "Directory removed!" ok_msg "Directory removed!"
} }
function remove_klipper(){ function remove_klipper() {
remove_klipper_sysvinit remove_klipper_sysvinit
remove_klipper_systemd remove_klipper_systemd
remove_klipper_logs remove_klipper_logs
@@ -455,7 +455,7 @@ function remove_klipper(){
#================ UPDATE KLIPPER ================# #================ UPDATE KLIPPER ================#
#================================================# #================================================#
function update_klipper(){ function update_klipper() {
do_action_service "stop" "klipper" do_action_service "stop" "klipper"
if [[ ! -d ${KLIPPER_DIR} ]]; then if [[ ! -d ${KLIPPER_DIR} ]]; then
@@ -478,7 +478,7 @@ function update_klipper(){
#================ KLIPPER STATUS ================# #================ KLIPPER STATUS ================#
#================================================# #================================================#
function get_klipper_status(){ function get_klipper_status() {
local sf_count status py_ver local sf_count status py_ver
sf_count="$(klipper_systemd | wc -w)" sf_count="$(klipper_systemd | wc -w)"
@@ -515,7 +515,7 @@ function get_klipper_status(){
echo "${status}" echo "${status}"
} }
function get_local_klipper_commit(){ function get_local_klipper_commit() {
[[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return [[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return
local commit local commit
@@ -524,7 +524,7 @@ function get_local_klipper_commit(){
echo "${commit}" echo "${commit}"
} }
function get_remote_klipper_commit(){ function get_remote_klipper_commit() {
[[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return [[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return
local commit local commit
@@ -533,7 +533,7 @@ function get_remote_klipper_commit(){
echo "${commit}" echo "${commit}"
} }
function compare_klipper_versions(){ function compare_klipper_versions() {
unset KLIPPER_UPDATE_AVAIL unset KLIPPER_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_klipper_commit)" local_ver="$(get_local_klipper_commit)"

View File

@@ -21,7 +21,7 @@ function klipperscreen_systemd() {
echo "${services}" echo "${services}"
} }
function install_klipperscreen(){ function install_klipperscreen() {
### return early if python version check fails ### return early if python version check fails
if [ "$(python3_check)" == "false" ]; then if [ "$(python3_check)" == "false" ]; then
local error="Versioncheck failed! Python 3.7 or newer required!\n" local error="Versioncheck failed! Python 3.7 or newer required!\n"
@@ -38,7 +38,7 @@ function install_klipperscreen(){
do_action_service "restart" "KlipperScreen" do_action_service "restart" "KlipperScreen"
} }
function klipperscreen_setup(){ function klipperscreen_setup() {
local dep=(wget curl unzip dfu-util) local dep=(wget curl unzip dfu-util)
dependency_check "${dep[@]}" dependency_check "${dep[@]}"
status_msg "Downloading KlipperScreen ..." status_msg "Downloading KlipperScreen ..."
@@ -56,7 +56,7 @@ function klipperscreen_setup(){
#=============== REMOVE KLIPPERSCREEN ==============# #=============== REMOVE KLIPPERSCREEN ==============#
#===================================================# #===================================================#
function remove_klipperscreen(){ function remove_klipperscreen() {
### remove KlipperScreen dir ### remove KlipperScreen dir
if [ -d "${KLIPPERSCREEN_DIR}" ]; then if [ -d "${KLIPPERSCREEN_DIR}" ]; then
status_msg "Removing KlipperScreen directory ..." status_msg "Removing KlipperScreen directory ..."
@@ -101,7 +101,7 @@ function remove_klipperscreen(){
#=============== UPDATE KLIPPERSCREEN ==============# #=============== UPDATE KLIPPERSCREEN ==============#
#===================================================# #===================================================#
function update_klipperscreen(){ function update_klipperscreen() {
local old_md5 local old_md5
old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1) old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1)
@@ -123,7 +123,7 @@ function update_klipperscreen(){
#=============== KLIPPERSCREEN STATUS ==============# #=============== KLIPPERSCREEN STATUS ==============#
#===================================================# #===================================================#
function get_klipperscreen_status(){ function get_klipperscreen_status() {
local sf_count status local sf_count status
sf_count="$(klipperscreen_systemd | wc -w)" sf_count="$(klipperscreen_systemd | wc -w)"
@@ -147,7 +147,7 @@ function get_klipperscreen_status(){
echo "${status}" echo "${status}"
} }
function get_local_klipperscreen_commit(){ function get_local_klipperscreen_commit() {
local commit local commit
[ ! -d "${KLIPPERSCREEN_DIR}" ] || [ ! -d "${KLIPPERSCREEN_DIR}"/.git ] && return [ ! -d "${KLIPPERSCREEN_DIR}" ] || [ ! -d "${KLIPPERSCREEN_DIR}"/.git ] && return
cd "${KLIPPERSCREEN_DIR}" cd "${KLIPPERSCREEN_DIR}"
@@ -155,7 +155,7 @@ function get_local_klipperscreen_commit(){
echo "${commit}" echo "${commit}"
} }
function get_remote_klipperscreen_commit(){ function get_remote_klipperscreen_commit() {
local commit local commit
[ ! -d "${KLIPPERSCREEN_DIR}" ] || [ ! -d "${KLIPPERSCREEN_DIR}"/.git ] && return [ ! -d "${KLIPPERSCREEN_DIR}" ] || [ ! -d "${KLIPPERSCREEN_DIR}"/.git ] && return
cd "${KLIPPERSCREEN_DIR}" && git fetch origin -q cd "${KLIPPERSCREEN_DIR}" && git fetch origin -q
@@ -163,7 +163,7 @@ function get_remote_klipperscreen_commit(){
echo "${commit}" echo "${commit}"
} }
function compare_klipperscreen_versions(){ function compare_klipperscreen_versions() {
unset KLIPPERSCREEN_UPDATE_AVAIL unset KLIPPERSCREEN_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_klipperscreen_commit)" local_ver="$(get_local_klipperscreen_commit)"
@@ -185,7 +185,7 @@ function compare_klipperscreen_versions(){
#=================== HELPERS ====================# #=================== HELPERS ====================#
#================================================# #================================================#
function patch_klipperscreen_update_manager(){ function patch_klipperscreen_update_manager() {
local moonraker_configs local moonraker_configs
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort) moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
for conf in ${moonraker_configs}; do for conf in ${moonraker_configs}; do

View File

@@ -15,7 +15,7 @@ set -e
#================= INSTALL MAINSAIL ================# #================= INSTALL MAINSAIL ================#
#===================================================# #===================================================#
function install_mainsail(){ function install_mainsail() {
### exit early if moonraker not found ### exit early if moonraker not found
if [ -z "$(moonraker_systemd)" ]; then if [ -z "$(moonraker_systemd)" ]; then
local error="Moonraker not installed! Please install Moonraker first!" local error="Moonraker not installed! Please install Moonraker first!"
@@ -89,7 +89,7 @@ function install_mainsail(){
print_confirm "Mainsail has been set up!" print_confirm "Mainsail has been set up!"
} }
function install_mainsail_macros(){ function install_mainsail_macros() {
while true; do while true; do
echo echo
top_border top_border
@@ -121,7 +121,7 @@ function install_mainsail_macros(){
return return
} }
function download_mainsail_macros(){ function download_mainsail_macros() {
log_info "executing: 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 ms_cfg="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mainsail/filesystem/home/pi/klipper_config/mainsail.cfg"
local configs local configs
@@ -154,7 +154,7 @@ function download_mainsail_macros(){
fi fi
} }
function mainsail_setup(){ function mainsail_setup() {
local url local url
url=$(get_mainsail_download_url) url=$(get_mainsail_download_url)
status_msg "Downloading Mainsail ..." status_msg "Downloading Mainsail ..."
@@ -180,13 +180,13 @@ function mainsail_setup(){
#================= REMOVE MAINSAIL =================# #================= REMOVE MAINSAIL =================#
#===================================================# #===================================================#
function remove_mainsail_dir(){ function remove_mainsail_dir() {
[ ! -d "${MAINSAIL_DIR}" ] && return [ ! -d "${MAINSAIL_DIR}" ] && return
status_msg "Removing Mainsail directory ..." status_msg "Removing Mainsail directory ..."
rm -rf "${MAINSAIL_DIR}" && ok_msg "Directory removed!" rm -rf "${MAINSAIL_DIR}" && ok_msg "Directory removed!"
} }
function remove_mainsail_config(){ function remove_mainsail_config() {
if [ -e "/etc/nginx/sites-available/mainsail" ]; then if [ -e "/etc/nginx/sites-available/mainsail" ]; then
status_msg "Removing Mainsail configuration for Nginx ..." status_msg "Removing Mainsail configuration for Nginx ..."
sudo rm "/etc/nginx/sites-available/mainsail" && ok_msg "File removed!" sudo rm "/etc/nginx/sites-available/mainsail" && ok_msg "File removed!"
@@ -197,7 +197,7 @@ function remove_mainsail_config(){
fi fi
} }
function remove_mainsail_logs(){ function remove_mainsail_logs() {
local files local files
files=$(find /var/log/nginx -name "mainsail*") files=$(find /var/log/nginx -name "mainsail*")
if [ -n "${files}" ]; then if [ -n "${files}" ]; then
@@ -209,7 +209,7 @@ function remove_mainsail_logs(){
fi fi
} }
function remove_mainsail_log_symlinks(){ function remove_mainsail_log_symlinks() {
local files local files
files=$(find "${KLIPPER_LOGS}" -name "mainsail*") files=$(find "${KLIPPER_LOGS}" -name "mainsail*")
if [ -n "${files}" ]; then if [ -n "${files}" ]; then
@@ -221,7 +221,7 @@ function remove_mainsail_log_symlinks(){
fi fi
} }
function remove_mainsail(){ function remove_mainsail() {
remove_mainsail_dir remove_mainsail_dir
remove_mainsail_config remove_mainsail_config
remove_mainsail_logs remove_mainsail_logs
@@ -237,7 +237,7 @@ function remove_mainsail(){
#================= UPDATE MAINSAIL =================# #================= UPDATE MAINSAIL =================#
#===================================================# #===================================================#
function update_mainsail(){ function update_mainsail() {
backup_before_update "mainsail" backup_before_update "mainsail"
status_msg "Updating Mainsail ..." status_msg "Updating Mainsail ..."
mainsail_setup mainsail_setup
@@ -249,7 +249,7 @@ function update_mainsail(){
#================= MAINSAIL STATUS =================# #================= MAINSAIL STATUS =================#
#===================================================# #===================================================#
function get_mainsail_status(){ function get_mainsail_status() {
local status local status
local data_arr=("${MAINSAIL_DIR}" "${NGINX_SA}/mainsail" "${NGINX_SE}/mainsail") local data_arr=("${MAINSAIL_DIR}" "${NGINX_SA}/mainsail" "${NGINX_SE}/mainsail")
@@ -269,21 +269,21 @@ function get_mainsail_status(){
echo "${status}" echo "${status}"
} }
function get_local_mainsail_version(){ function get_local_mainsail_version() {
local version local version
[ ! -f "${MAINSAIL_DIR}/.version" ] && return [ ! -f "${MAINSAIL_DIR}/.version" ] && return
version=$(head -n 1 "${MAINSAIL_DIR}/.version") version=$(head -n 1 "${MAINSAIL_DIR}/.version")
echo "${version}" echo "${version}"
} }
function get_remote_mainsail_version(){ function get_remote_mainsail_version() {
local version local version
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
version=$(get_mainsail_download_url | rev | cut -d"/" -f2 | rev) version=$(get_mainsail_download_url | rev | cut -d"/" -f2 | rev)
echo "${version}" echo "${version}"
} }
function compare_mainsail_versions(){ function compare_mainsail_versions() {
unset MAINSAIL_UPDATE_AVAIL unset MAINSAIL_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_mainsail_version)" local_ver="$(get_local_mainsail_version)"
@@ -305,7 +305,7 @@ function compare_mainsail_versions(){
#=========== MAINSAIL THEME INSTALLER ===========# #=========== MAINSAIL THEME INSTALLER ===========#
#================================================# #================================================#
function print_theme_list(){ function print_theme_list() {
local i=0 theme_list=${1} local i=0 theme_list=${1}
while IFS="," read -r col1 col2 col3 col4; do while IFS="," read -r col1 col2 col3 col4; do
if [ "${col1}" != "name" ]; then if [ "${col1}" != "name" ]; then
@@ -315,7 +315,7 @@ function print_theme_list(){
done <<< "${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_author theme_repo theme_name theme_note theme_url
local theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/docs/master/_data/themes.csv" local theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/docs/master/_data/themes.csv"
theme_list=$(curl -s -L "${theme_csv_url}") theme_list=$(curl -s -L "${theme_csv_url}")
@@ -361,7 +361,7 @@ function ms_theme_installer_menu(){
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 local path moonraker_count theme_url=${1} theme_name theme_note
theme_name=${2} theme_note=${3} theme_name=${2} theme_note=${3}
@@ -391,7 +391,7 @@ function ms_theme_install(){
fi fi
} }
function ms_theme_delete(){ function ms_theme_delete() {
local path local path
path="$(get_klipper_cfg_dir)" path="$(get_klipper_cfg_dir)"
moonraker_count=$(moonraker_systemd | wc -w) moonraker_count=$(moonraker_systemd | wc -w)
@@ -438,7 +438,7 @@ function get_mainsail_download_url() {
fi fi
} }
function mainsail_port_check(){ function mainsail_port_check() {
if [ "${MAINSAIL_ENABLED}" = "false" ]; then if [ "${MAINSAIL_ENABLED}" = "false" ]; then
if [ "${SITE_ENABLED}" = "true" ]; then if [ "${SITE_ENABLED}" = "true" ]; then
status_msg "Detected other enabled interfaces:" status_msg "Detected other enabled interfaces:"
@@ -458,7 +458,7 @@ function mainsail_port_check(){
fi fi
} }
function select_mainsail_port(){ function select_mainsail_port() {
if [ "${PORT_80_BLOCKED}" = "true" ]; then if [ "${PORT_80_BLOCKED}" = "true" ]; then
echo echo
top_border top_border
@@ -489,13 +489,13 @@ function select_mainsail_port(){
fi fi
} }
function enable_mainsail_remotemode(){ function enable_mainsail_remotemode() {
[ ! -f "${MAINSAIL_DIR}/config.json" ] && return [ ! -f "${MAINSAIL_DIR}/config.json" ] && return
rm -f "${MAINSAIL_DIR}/config.json" rm -f "${MAINSAIL_DIR}/config.json"
echo -e "{\n \"remoteMode\":true\n}" >> "${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 local moonraker_configs
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort) moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
for conf in ${moonraker_configs}; do for conf in ${moonraker_configs}; do

View File

@@ -15,7 +15,7 @@ set -e
#============= INSTALL MJPG-STREAMER =============# #============= 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 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 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" local repo="https://github.com/jacksonliam/mjpg-streamer.git"
@@ -149,7 +149,7 @@ EOF
#============== REMOVE MJPG-STREAMER =============# #============== REMOVE MJPG-STREAMER =============#
#=================================================# #=================================================#
function remove_mjpg-streamer(){ function remove_mjpg-streamer() {
### remove MJPG-Streamer service ### remove MJPG-Streamer service
if [ -e "${SYSTEMD}/webcamd.service" ]; then if [ -e "${SYSTEMD}/webcamd.service" ]; then
status_msg "Removing MJPG-Streamer service ..." status_msg "Removing MJPG-Streamer service ..."

View File

@@ -21,7 +21,7 @@ function telegram_bot_systemd() {
echo "${services}" echo "${services}"
} }
function telegram_bot_setup_dialog(){ function telegram_bot_setup_dialog() {
status_msg "Initializing Telegram Bot installation ..." status_msg "Initializing Telegram Bot installation ..."
### return early if moonraker is not installed ### return early if moonraker is not installed
@@ -107,7 +107,7 @@ function telegram_bot_setup_dialog(){
telegram_bot_setup "${user_input[@]}" telegram_bot_setup "${user_input[@]}"
} }
function install_telegram_bot_dependencies(){ function install_telegram_bot_dependencies() {
local packages local packages
local install_script="${MOONRAKER_TELEGRAM_BOT_DIR}/scripts/install.sh" 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[@]}" sudo apt-get install --yes "${packages[@]}"
} }
function create_telegram_bot_virtualenv(){ function create_telegram_bot_virtualenv() {
status_msg "Installing python virtual environment..." status_msg "Installing python virtual environment..."
### always create a clean virtualenv ### always create a clean virtualenv
[[ -d ${MOONRAKER_TELEGRAM_BOT_ENV_DIR} ]] && rm -rf "${MOONRAKER_TELEGRAM_BOT_ENV_DIR}" [[ -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" "${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=("${@}") local instance_arr=("${@}")
### checking dependencies ### checking dependencies
local dep=(git virtualenv) local dep=(git virtualenv)
@@ -170,7 +170,7 @@ function telegram_bot_setup(){
print_confirm "${confirm}" && return print_confirm "${confirm}" && return
} }
function create_telegram_conf(){ function create_telegram_conf() {
local input=("${@}") local input=("${@}")
local telegram_bot_count=${input[0]} && unset "input[0]" local telegram_bot_count=${input[0]} && unset "input[0]"
local names=("${input[@]}") && unset "input[@]" local names=("${input[@]}") && unset "input[@]"
@@ -204,7 +204,7 @@ function create_telegram_conf(){
fi fi
} }
function write_telegram_conf(){ function write_telegram_conf() {
local cfg_dir=${1} cfg=${2} log=${3} local cfg_dir=${1} cfg=${2} log=${3}
local conf_template="${MOONRAKER_TELEGRAM_BOT_DIR}/scripts/base_install_template" local conf_template="${MOONRAKER_TELEGRAM_BOT_DIR}/scripts/base_install_template"
[[ ! -d ${cfg_dir} ]] && mkdir -p "${cfg_dir}" [[ ! -d ${cfg_dir} ]] && mkdir -p "${cfg_dir}"
@@ -219,7 +219,7 @@ function write_telegram_conf(){
fi fi
} }
function create_telegram_bot_service(){ function create_telegram_bot_service() {
local input=("${@}") local input=("${@}")
local instances=${input[0]} && unset "input[0]" local instances=${input[0]} && unset "input[0]"
local names=("${input[@]}") && unset "input[@]" local names=("${input[@]}") && unset "input[@]"
@@ -259,7 +259,7 @@ function create_telegram_bot_service(){
fi fi
} }
function write_telegram_bot_service(){ function write_telegram_bot_service() {
local i=${1} cfg=${2} log=${3} service=${4} local i=${1} cfg=${2} log=${3} service=${4}
local service_template="${KIAUH_SRCDIR}/resources/moonraker-telegram-bot.service" local service_template="${KIAUH_SRCDIR}/resources/moonraker-telegram-bot.service"
@@ -326,7 +326,7 @@ function remove_telegram_bot_logs() {
fi fi
} }
function remove_telegram_bot(){ function remove_telegram_bot() {
remove_telegram_bot_systemd remove_telegram_bot_systemd
remove_telegram_bot_dir remove_telegram_bot_dir
remove_telegram_bot_env remove_telegram_bot_env
@@ -340,7 +340,7 @@ function remove_telegram_bot(){
#=========== UPDATE MOONRAKERTELEGRAMBOT ===========# #=========== UPDATE MOONRAKERTELEGRAMBOT ===========#
#===================================================# #===================================================#
function update_telegram_bot(){ function update_telegram_bot() {
do_action_service "stop" "moonraker-telegram-bot" do_action_service "stop" "moonraker-telegram-bot"
if [[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} ]]; then if [[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} ]]; then
@@ -363,7 +363,7 @@ function update_telegram_bot(){
#=========== MOONRAKERTELEGRAMBOT STATUS ===========# #=========== MOONRAKERTELEGRAMBOT STATUS ===========#
#===================================================# #===================================================#
function get_telegram_bot_status(){ function get_telegram_bot_status() {
local sf_count status local sf_count status
sf_count="$(telegram_bot_systemd | wc -w)" sf_count="$(telegram_bot_systemd | wc -w)"
@@ -387,7 +387,7 @@ function get_telegram_bot_status(){
echo "${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 [[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} || ! -d "${MOONRAKER_TELEGRAM_BOT_DIR}/.git" ]] && return
local commit local commit
@@ -396,7 +396,7 @@ function get_local_telegram_bot_commit(){
echo "${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 [[ ! -d ${MOONRAKER_TELEGRAM_BOT_DIR} || ! -d "${MOONRAKER_TELEGRAM_BOT_DIR}/.git" ]] && return
local commit local commit
@@ -405,7 +405,7 @@ function get_remote_telegram_bot_commit(){
echo "${commit}" echo "${commit}"
} }
function compare_telegram_bot_versions(){ function compare_telegram_bot_versions() {
unset MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL unset MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_telegram_bot_commit)" local_ver="$(get_local_telegram_bot_commit)"

View File

@@ -21,7 +21,7 @@ function moonraker_systemd() {
echo "${services}" echo "${services}"
} }
function moonraker_setup_dialog(){ function moonraker_setup_dialog() {
status_msg "Initializing Moonraker installation ..." status_msg "Initializing Moonraker installation ..."
### return early if python version check fails ### return early if python version check fails
@@ -125,7 +125,7 @@ function moonraker_setup_dialog(){
moonraker_setup "${user_input[@]}" moonraker_setup "${user_input[@]}"
} }
function install_moonraker_dependencies(){ function install_moonraker_dependencies() {
local packages local packages
local install_script="${HOME}/moonraker/scripts/install-moonraker.sh" local install_script="${HOME}/moonraker/scripts/install-moonraker.sh"
@@ -146,7 +146,7 @@ function install_moonraker_dependencies(){
sudo apt-get install --yes "${packages[@]}" sudo apt-get install --yes "${packages[@]}"
} }
function create_moonraker_virtualenv(){ function create_moonraker_virtualenv() {
status_msg "Installing python virtual environment..." status_msg "Installing python virtual environment..."
### always create a clean virtualenv ### always create a clean virtualenv
[[ -d ${MOONRAKER_ENV} ]] && rm -rf "${MOONRAKER_ENV}" [[ -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" "${MOONRAKER_ENV}"/bin/pip install -r "${MOONRAKER_DIR}/scripts/moonraker-requirements.txt"
} }
function moonraker_setup(){ function moonraker_setup() {
local instance_arr=("${@}") local instance_arr=("${@}")
### checking dependencies ### checking dependencies
local dep=(git wget curl unzip dfu-util virtualenv) 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 print_confirm "${confirm}" && print_mr_ip_list "${instance_arr[0]}" && return
} }
function create_moonraker_conf(){ function create_moonraker_conf() {
local input=("${@}") local input=("${@}")
local moonraker_count=${input[0]} && unset "input[0]" local moonraker_count=${input[0]} && unset "input[0]"
local names=("${input[@]}") && unset "input[@]" local names=("${input[@]}") && unset "input[@]"
@@ -237,7 +237,7 @@ function create_moonraker_conf(){
fi 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 cfg_dir=${1} cfg=${2} port=${3} log=${4} db=${5} uds=${6} lan=${7}
local conf_template="${KIAUH_SRCDIR}/resources/moonraker.conf" local conf_template="${KIAUH_SRCDIR}/resources/moonraker.conf"
@@ -261,7 +261,7 @@ function write_moonraker_conf(){
fi fi
} }
function create_moonraker_service(){ function create_moonraker_service() {
local input=("${@}") local input=("${@}")
local moonraker_count=${input[0]} && unset "input[0]" local moonraker_count=${input[0]} && unset "input[0]"
local names=("${input[@]}") && unset "input[@]" local names=("${input[@]}") && unset "input[@]"
@@ -309,7 +309,7 @@ function create_moonraker_service(){
fi fi
} }
function write_moonraker_service(){ function write_moonraker_service() {
local i=${1} cfg=${2} log=${3} service=${4} local i=${1} cfg=${2} log=${3} service=${4}
local service_template="${KIAUH_SRCDIR}/resources/moonraker.service" local service_template="${KIAUH_SRCDIR}/resources/moonraker.service"
@@ -325,7 +325,7 @@ function write_moonraker_service(){
fi fi
} }
function print_mr_ip_list(){ function print_mr_ip_list() {
local ip count=${1} port=7125 local ip count=${1} port=7125
ip=$(hostname -I | cut -d" " -f1) ip=$(hostname -I | cut -d" " -f1)
@@ -338,7 +338,7 @@ function print_mr_ip_list(){
### introduced due to ### introduced due to
### https://github.com/Arksine/moonraker/issues/349 ### https://github.com/Arksine/moonraker/issues/349
### https://github.com/Arksine/moonraker/pull/346 ### https://github.com/Arksine/moonraker/pull/346
function moonraker_polkit(){ function moonraker_polkit() {
local has_sup local has_sup
### check for required SupplementaryGroups entry in service files ### 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_sysvinit
remove_moonraker_systemd remove_moonraker_systemd
remove_moonraker_logs remove_moonraker_logs
@@ -472,7 +472,7 @@ function remove_moonraker(){
#================ UPDATE MOONRAKER ================# #================ UPDATE MOONRAKER ================#
#==================================================# #==================================================#
function update_moonraker(){ function update_moonraker() {
do_action_service "stop" "moonraker" do_action_service "stop" "moonraker"
if [[ ! -d ${MOONRAKER_DIR} ]]; then if [[ ! -d ${MOONRAKER_DIR} ]]; then
@@ -498,7 +498,7 @@ function update_moonraker(){
#================ MOONRAKER STATUS ================# #================ MOONRAKER STATUS ================#
#==================================================# #==================================================#
function get_moonraker_status(){ function get_moonraker_status() {
local sf_count status local sf_count status
sf_count="$(moonraker_systemd | wc -w)" sf_count="$(moonraker_systemd | wc -w)"
@@ -523,7 +523,7 @@ function get_moonraker_status(){
echo "${status}" echo "${status}"
} }
function get_local_moonraker_commit(){ function get_local_moonraker_commit() {
[[ ! -d ${MOONRAKER_DIR} || ! -d "${MOONRAKER_DIR}/.git" ]] && return [[ ! -d ${MOONRAKER_DIR} || ! -d "${MOONRAKER_DIR}/.git" ]] && return
local commit local commit
@@ -532,7 +532,7 @@ function get_local_moonraker_commit(){
echo "${commit}" echo "${commit}"
} }
function get_remote_moonraker_commit(){ function get_remote_moonraker_commit() {
[[ ! -d ${MOONRAKER_DIR} || ! -d "${MOONRAKER_DIR}/.git" ]] && return [[ ! -d ${MOONRAKER_DIR} || ! -d "${MOONRAKER_DIR}/.git" ]] && return
local commit local commit
@@ -541,7 +541,7 @@ function get_remote_moonraker_commit(){
echo "${commit}" echo "${commit}"
} }
function compare_moonraker_versions(){ function compare_moonraker_versions() {
unset MOONRAKER_UPDATE_AVAIL unset MOONRAKER_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_moonraker_commit)" local_ver="$(get_local_moonraker_commit)"

View File

@@ -15,7 +15,7 @@ set -e
#=================== REMOVE NGINX ==================# #=================== REMOVE NGINX ==================#
#===================================================# #===================================================#
function remove_nginx(){ function remove_nginx() {
if [ -f "${SYSTEMD}/nginx.service" ]; then if [ -f "${SYSTEMD}/nginx.service" ]; then
status_msg "Stopping Nginx service ..." status_msg "Stopping Nginx service ..."
sudo systemctl stop nginx && sudo systemctl disable nginx sudo systemctl stop nginx && sudo systemctl disable nginx
@@ -33,7 +33,7 @@ function remove_nginx(){
#===================== HELPERS =====================# #===================== HELPERS =====================#
#===================================================# #===================================================#
function set_upstream_nginx_cfg(){ function set_upstream_nginx_cfg() {
local current_date local current_date
current_date=$(get_date) current_date=$(get_date)
local upstreams="${NGINX_CONFD}/upstreams.conf" 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}" [ ! -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 interface=${1} path="${KLIPPER_LOGS}"
local access_log="/var/log/nginx/${interface}-access.log" local access_log="/var/log/nginx/${interface}-access.log"
local error_log="/var/log/nginx/${interface}-error.log" local error_log="/var/log/nginx/${interface}-error.log"
@@ -77,7 +77,7 @@ function symlink_webui_nginx_log(){
fi fi
} }
function match_nginx_configs(){ function match_nginx_configs() {
read_kiauh_ini "${FUNCNAME[0]}" read_kiauh_ini "${FUNCNAME[0]}"
local require_service_restart="false" local require_service_restart="false"
local upstreams="${NGINX_CONFD}/upstreams.conf" local upstreams="${NGINX_CONFD}/upstreams.conf"
@@ -127,7 +127,7 @@ function match_nginx_configs(){
[ "${require_service_restart}" == "true" ] && sudo systemctl restart nginx.service [ "${require_service_restart}" == "true" ] && sudo systemctl restart nginx.service
} }
function process_disruptive_services(){ function process_disruptive_services() {
#handle haproxy service #handle haproxy service
if [ "${DISABLE_HAPROXY}" = "true" ] || [ "${REMOVE_HAPROXY}" = "true" ]; then if [ "${DISABLE_HAPROXY}" = "true" ] || [ "${REMOVE_HAPROXY}" = "true" ]; then
if systemctl is-active haproxy -q; then if systemctl is-active haproxy -q; then
@@ -189,7 +189,7 @@ function process_disruptive_services(){
fi fi
} }
function process_services_dialog(){ function process_services_dialog() {
#notify user about haproxy or lighttpd services found and possible issues #notify user about haproxy or lighttpd services found and possible issues
if [ "${HAPROXY_FOUND}" = "true" ] || [ "${LIGHTTPD_FOUND}" = "true" ] || [ "${APACHE2_FOUND}" = "true" ]; then if [ "${HAPROXY_FOUND}" = "true" ] || [ "${LIGHTTPD_FOUND}" = "true" ] || [ "${APACHE2_FOUND}" = "true" ]; then
while true; do while true; do
@@ -239,7 +239,7 @@ function process_services_dialog(){
fi fi
} }
function set_nginx_cfg(){ function set_nginx_cfg() {
local interface=${1} local interface=${1}
if [ "${SET_NGINX_CFG}" = "true" ]; then if [ "${SET_NGINX_CFG}" = "true" ]; then
local cfg="${RESOURCES}/${interface}" local cfg="${RESOURCES}/${interface}"
@@ -283,13 +283,13 @@ function set_nginx_cfg(){
fi fi
} }
function read_listen_port(){ function read_listen_port() {
local port interface=${1} local port interface=${1}
port=$(grep listen "/etc/nginx/sites-enabled/${interface}" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1) port=$(grep listen "/etc/nginx/sites-enabled/${interface}" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
echo "${port}" echo "${port}"
} }
function detect_enabled_sites(){ function detect_enabled_sites() {
MAINSAIL_ENABLED="false" FLUIDD_ENABLED="false" OCTOPRINT_ENABLED="false" 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 #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 if [ -e "/etc/nginx/sites-enabled/mainsail" ]; then

View File

@@ -21,7 +21,7 @@ function octoprint_systemd() {
echo "${services}" echo "${services}"
} }
function octoprint_setup_dialog(){ function octoprint_setup_dialog() {
status_msg "Initializing OctoPrint installation ..." status_msg "Initializing OctoPrint installation ..."
local klipper_services klipper_count user_input=() klipper_names=() local klipper_services klipper_count user_input=() klipper_names=()
@@ -97,7 +97,7 @@ function octoprint_setup_dialog(){
octoprint_setup "${user_input[@]}" octoprint_setup "${user_input[@]}"
} }
function octoprint_setup(){ function octoprint_setup() {
local instance_arr=("${@}") local instance_arr=("${@}")
### check and install all dependencies ### check and install all dependencies
local dep=( local dep=(
@@ -133,7 +133,7 @@ function octoprint_setup(){
print_confirm "${confirm}" && print_op_ip_list "${instance_arr[0]}" && return print_confirm "${confirm}" && print_op_ip_list "${instance_arr[0]}" && return
} }
function install_octoprint(){ function install_octoprint() {
function install_octoprint_python_env() { function install_octoprint_python_env() {
local tmp="${1}" local tmp="${1}"
@@ -207,7 +207,7 @@ function install_octoprint(){
fi fi
} }
function create_octoprint_service(){ function create_octoprint_service() {
local input=("${@}") local input=("${@}")
local octoprint_count=${input[0]} && unset "input[0]" local octoprint_count=${input[0]} && unset "input[0]"
local names=("${input[@]}") && unset "input[@]" local names=("${input[@]}") && unset "input[@]"
@@ -279,7 +279,7 @@ CONFIGYAML
done done
} }
function add_reboot_permission(){ function add_reboot_permission() {
#create a backup if file already exists #create a backup if file already exists
if [[ -f /etc/sudoers.d/octoprint-shutdown ]]; then if [[ -f /etc/sudoers.d/octoprint-shutdown ]]; then
sudo mv /etc/sudoers.d/octoprint-shutdown /etc/sudoers.d/octoprint-shutdown.old 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!" ok_msg "Permission set!"
} }
function print_op_ip_list(){ function print_op_ip_list() {
local ip octoprint_count="${1}" port=5000 local ip octoprint_count="${1}" port=5000
ip=$(hostname -I | cut -d" " -f1) ip=$(hostname -I | cut -d" " -f1)
@@ -307,7 +307,7 @@ function print_op_ip_list(){
#=============== REMOVE OCTOPRINT ================# #=============== REMOVE OCTOPRINT ================#
#=================================================# #=================================================#
function remove_octoprint_service(){ function remove_octoprint_service() {
[[ -z "$(octoprint_systemd)" ]] && return [[ -z "$(octoprint_systemd)" ]] && return
###remove all octoprint services ###remove all octoprint services
@@ -326,14 +326,14 @@ function remove_octoprint_service(){
sudo systemctl reset-failed sudo systemctl reset-failed
} }
function remove_octoprint_sudoers(){ function remove_octoprint_sudoers() {
[[ ! -f /etc/sudoers.d/octoprint-shutdown ]] && return [[ ! -f /etc/sudoers.d/octoprint-shutdown ]] && return
### remove sudoers file ### remove sudoers file
sudo rm -f /etc/sudoers.d/octoprint-shutdown sudo rm -f /etc/sudoers.d/octoprint-shutdown
} }
function remove_octoprint_env(){ function remove_octoprint_env() {
local files local files
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[0-9a-zA-Z]+)?" | sort) files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[0-9a-zA-Z]+)?" | sort)
if [[ -n ${files} ]]; then if [[ -n ${files} ]]; then
@@ -345,7 +345,7 @@ function remove_octoprint_env(){
fi fi
} }
function remove_octoprint_dir(){ function remove_octoprint_dir() {
local files local files
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/.octoprint(_[0-9a-zA-Z]+)?" | sort) files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/.octoprint(_[0-9a-zA-Z]+)?" | sort)
if [[ -n ${files} ]]; then if [[ -n ${files} ]]; then
@@ -357,7 +357,7 @@ function remove_octoprint_dir(){
fi fi
} }
function remove_octoprint(){ function remove_octoprint() {
remove_octoprint_service remove_octoprint_service
remove_octoprint_sudoers remove_octoprint_sudoers
remove_octoprint_env remove_octoprint_env
@@ -374,7 +374,7 @@ function remove_octoprint(){
#=============== OCTOPRINT STATUS ================# #=============== OCTOPRINT STATUS ================#
#=================================================# #=================================================#
function get_octoprint_status(){ function get_octoprint_status() {
local sf_count env_count dir_count status local sf_count env_count dir_count status
sf_count="$(octoprint_systemd | wc -w)" sf_count="$(octoprint_systemd | wc -w)"
env_count=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[0-9a-zA-Z]+)?" | wc -w) env_count=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[0-9a-zA-Z]+)?" | wc -w)

View File

@@ -15,7 +15,7 @@ set -e
#================== INSTALL PGC ==================# #================== INSTALL PGC ==================#
#=================================================# #=================================================#
function install_pgc_for_klipper(){ function install_pgc_for_klipper() {
pgconfsrc="${PGC_DIR}/pgcode.local.conf" pgconfsrc="${PGC_DIR}/pgcode.local.conf"
pgconf="/etc/nginx/sites-available/pgcode.local.conf" pgconf="/etc/nginx/sites-available/pgcode.local.conf"
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf" pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
@@ -53,7 +53,7 @@ function install_pgc_for_klipper(){
#=================== REMOVE PGC ==================# #=================== REMOVE PGC ==================#
#=================================================# #=================================================#
function remove_prettygcode(){ function remove_prettygcode() {
pgconf="/etc/nginx/sites-available/pgcode.local.conf" pgconf="/etc/nginx/sites-available/pgcode.local.conf"
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf" pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
if [ -d "${HOME}/pgcode" ] || [ -f "${pgconf}" ] || [ -L "${pgconfsl}" ]; then if [ -d "${HOME}/pgcode" ] || [ -f "${pgconf}" ] || [ -L "${pgconfsl}" ]; then
@@ -72,7 +72,7 @@ function remove_prettygcode(){
#=================== UPDATE PGC ==================# #=================== UPDATE PGC ==================#
#=================================================# #=================================================#
function update_pgc_for_klipper(){ function update_pgc_for_klipper() {
PGC_DIR="${HOME}/pgcode" PGC_DIR="${HOME}/pgcode"
status_msg "Updating PrettyGCode for Klipper ..." status_msg "Updating PrettyGCode for Klipper ..."
cd "${PGC_DIR}" && git pull cd "${PGC_DIR}" && git pull
@@ -83,7 +83,7 @@ function update_pgc_for_klipper(){
#=================== PGC STATUS ==================# #=================== PGC STATUS ==================#
#=================================================# #=================================================#
function get_local_prettygcode_commit(){ function get_local_prettygcode_commit() {
local commit local commit
[ ! -d "${PGC_DIR}" ] || [ ! -d "${PGC_DIR}"/.git ] && return [ ! -d "${PGC_DIR}" ] || [ ! -d "${PGC_DIR}"/.git ] && return
cd "${PGC_DIR}" cd "${PGC_DIR}"
@@ -91,7 +91,7 @@ function get_local_prettygcode_commit(){
echo "${commit}" echo "${commit}"
} }
function get_remote_prettygcode_commit(){ function get_remote_prettygcode_commit() {
local commit local commit
[ ! -d "${PGC_DIR}" ] || [ ! -d "${PGC_DIR}"/.git ] && return [ ! -d "${PGC_DIR}" ] || [ ! -d "${PGC_DIR}"/.git ] && return
cd "${PGC_DIR}" && git fetch origin -q cd "${PGC_DIR}" && git fetch origin -q
@@ -99,7 +99,7 @@ function get_remote_prettygcode_commit(){
echo "${commit}" echo "${commit}"
} }
function compare_prettygcode_versions(){ function compare_prettygcode_versions() {
unset PGC_UPDATE_AVAIL unset PGC_UPDATE_AVAIL
local versions local_ver remote_ver local versions local_ver remote_ver
local_ver="$(get_local_prettygcode_commit)" local_ver="$(get_local_prettygcode_commit)"

View File

@@ -11,7 +11,7 @@
set -e set -e
function rollback_menu(){ function rollback_menu() {
top_border top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") |" echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") |"
hr hr

View File

@@ -11,7 +11,7 @@
set -e set -e
function change_klipper_repo_menu(){ function change_klipper_repo_menu() {
local repo_file="${KIAUH_SRCDIR}/klipper_repos.txt" local repo_file="${KIAUH_SRCDIR}/klipper_repos.txt"
local repo branch repos=() branches=() local repo branch repos=() branches=()
@@ -94,7 +94,7 @@ function change_klipper_repo_menu(){
#=================== HELPERS ====================# #=================== HELPERS ====================#
#================================================# #================================================#
function switch_klipper_repo(){ function switch_klipper_repo() {
local repo_url branch local repo_url branch
repo_url="https://github.com/${1}" branch=${2} repo_url="https://github.com/${1}" branch=${2}
status_msg "Switching Klipper repository..." status_msg "Switching Klipper repository..."
@@ -106,7 +106,7 @@ function switch_klipper_repo(){
do_action_service "start" "klipper" do_action_service "start" "klipper"
} }
function show_custom_klipper_repo_help(){ function show_custom_klipper_repo_help() {
top_border top_border
echo -e "| ~~~~ < ? > Help: Custom Klipper repo < ? > ~~~~ |" echo -e "| ~~~~ < ? > Help: Custom Klipper repo < ? > ~~~~ |"
hr hr

View File

@@ -11,7 +11,7 @@
set -e set -e
function advanced_ui(){ function advanced_ui() {
top_border top_border
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${white} |" echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${white} |"
hr hr
@@ -26,7 +26,7 @@ function advanced_ui(){
back_footer back_footer
} }
function advanced_menu(){ function advanced_menu() {
do_action "" "advanced_ui" do_action "" "advanced_ui"
while true; do while true; do
read -p "${cyan}####### Perform action:${white} " action read -p "${cyan}####### Perform action:${white} " action

View File

@@ -11,7 +11,7 @@
set -e set -e
function backup_ui(){ function backup_ui() {
top_border top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") |" echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") |"
hr hr
@@ -29,7 +29,7 @@ function backup_ui(){
back_footer back_footer
} }
function backup_menu(){ function backup_menu() {
do_action "" "backup_ui" do_action "" "backup_ui"
while true; do while true; do
read -p "${cyan}####### Perform action:${white} " action read -p "${cyan}####### Perform action:${white} " action

View File

@@ -12,41 +12,41 @@
set -e set -e
#ui total width = 57 chars #ui total width = 57 chars
function top_border(){ function top_border() {
echo -e "/=======================================================\\" echo -e "/=======================================================\\"
} }
function bottom_border(){ function bottom_border() {
echo -e "\=======================================================/" echo -e "\=======================================================/"
} }
function blank_line(){ function blank_line() {
echo -e "| |" echo -e "| |"
} }
function hr(){ function hr() {
echo -e "|-------------------------------------------------------|" echo -e "|-------------------------------------------------------|"
} }
function quit_footer(){ function quit_footer() {
hr hr
echo -e "| ${red}Q) Quit${white} |" echo -e "| ${red}Q) Quit${white} |"
bottom_border bottom_border
} }
function back_footer(){ function back_footer() {
hr hr
echo -e "| ${green}B) « Back${white} |" echo -e "| ${green}B) « Back${white} |"
bottom_border bottom_border
} }
function back_help_footer(){ function back_help_footer() {
hr hr
echo -e "| ${green}B) « Back${white} | ${yellow}H) Help [?]${white} |" echo -e "| ${green}B) « Back${white} | ${yellow}H) Help [?]${white} |"
bottom_border bottom_border
} }
function print_header(){ function print_header() {
top_border top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |" echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |" echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
@@ -54,7 +54,7 @@ function print_header(){
bottom_border bottom_border
} }
function do_action(){ function do_action() {
clear && print_header clear && print_header
### $1 is the action the user wants to fire ### $1 is the action the user wants to fire
$1 $1
@@ -63,7 +63,7 @@ function do_action(){
$2 $2
} }
function deny_action(){ function deny_action() {
clear && print_header clear && print_header
print_error "Invalid command!" print_error "Invalid command!"
$1 $1

View File

@@ -11,7 +11,7 @@
set -e set -e
function install_ui(){ function install_ui() {
top_border top_border
echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${white} |" echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${white} |"
hr hr
@@ -32,7 +32,7 @@ function install_ui(){
back_footer back_footer
} }
function install_menu(){ function install_menu() {
clear && print_header clear && print_header
install_ui install_ui
@@ -66,7 +66,7 @@ function install_menu(){
install_menu install_menu
} }
function select_klipper_python_version(){ function select_klipper_python_version() {
top_border top_border
echo -e "| Please select the preferred Python version. | " echo -e "| Please select the preferred Python version. | "
echo -e "| The recommended version is Python 2.7. | " echo -e "| The recommended version is Python 2.7. | "

View File

@@ -11,7 +11,7 @@
set -e set -e
function main_ui(){ function main_ui() {
top_border top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |" echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
hr hr
@@ -29,20 +29,20 @@ function main_ui(){
quit_footer quit_footer
} }
function get_kiauh_version(){ function get_kiauh_version() {
local version local version
cd "${KIAUH_SRCDIR}" cd "${KIAUH_SRCDIR}"
version="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)" version="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
echo "${version}" echo "${version}"
} }
function print_kiauh_version(){ function print_kiauh_version() {
local version local version
version="$(printf "%-18s" "$(get_kiauh_version)")" version="$(printf "%-18s" "$(get_kiauh_version)")"
echo "${cyan}${version}${white}" echo "${cyan}${version}${white}"
} }
function print_status(){ function print_status() {
local status component="${1}" local status component="${1}"
status=$(get_"${component}"_status) status=$(get_"${component}"_status)
if [ "${status}" == "Not installed!" ]; then if [ "${status}" == "Not installed!" ]; then
@@ -55,7 +55,7 @@ function print_status(){
printf "%-28s" "${status}" printf "%-28s" "${status}"
} }
function print_klipper_repo(){ function print_klipper_repo() {
read_kiauh_ini read_kiauh_ini
local repo klipper_status local repo klipper_status
klipper_status=$(get_klipper_status) klipper_status=$(get_klipper_status)
@@ -71,7 +71,7 @@ function print_klipper_repo(){
printf "%-28s" "${repo}" printf "%-28s" "${repo}"
} }
function kiauh_update_dialog(){ function kiauh_update_dialog() {
[ ! "$(kiauh_update_avail)" == "true" ] && return [ ! "$(kiauh_update_avail)" == "true" ] && return
top_border top_border
echo -e "|${green} New KIAUH update available! ${white}|" echo -e "|${green} New KIAUH update available! ${white}|"
@@ -95,7 +95,7 @@ function kiauh_update_dialog(){
done done
} }
function main_menu(){ function main_menu() {
print_header print_header
#prompt for KIAUH update if update available #prompt for KIAUH update if update available
kiauh_update_dialog kiauh_update_dialog

View File

@@ -11,7 +11,7 @@
set -e set -e
function remove_ui(){ function remove_ui() {
top_border top_border
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} |" echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} |"
hr hr
@@ -30,7 +30,7 @@ function remove_ui(){
back_footer back_footer
} }
function remove_menu(){ function remove_menu() {
do_action "" "remove_ui" do_action "" "remove_ui"
while true; do while true; do
read -p "${cyan}####### Perform action:${white} " action read -p "${cyan}####### Perform action:${white} " action

View File

@@ -93,7 +93,7 @@ function settings_ui() {
back_help_footer back_help_footer
} }
function show_settings_help(){ function show_settings_help() {
local choice default_cfg="${cyan}${HOME}/klipper_config${white}" local choice default_cfg="${cyan}${HOME}/klipper_config${white}"
top_border top_border
@@ -144,7 +144,7 @@ function show_settings_help(){
done done
} }
function settings_menu(){ function settings_menu() {
local action local action
clear && print_header clear && print_header

View File

@@ -11,7 +11,7 @@
set -e set -e
function update_ui(){ function update_ui() {
top_border top_border
echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${white} |" echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${white} |"
hr hr
@@ -36,7 +36,7 @@ function update_ui(){
back_footer back_footer
} }
function update_menu(){ function update_menu() {
unset update_arr unset update_arr
do_action "" "update_ui" do_action "" "update_ui"
while true; do while true; do
@@ -71,7 +71,7 @@ function update_menu(){
update_menu update_menu
} }
function update_all(){ function update_all() {
while true; do while true; do
if [ "${#update_arr[@]}" = "0" ]; then if [ "${#update_arr[@]}" = "0" ]; then
CONFIRM_MSG="Everything is already up to date!" CONFIRM_MSG="Everything is already up to date!"

View File

@@ -11,7 +11,7 @@
set -e set -e
function accept_upload_conditions(){ function accept_upload_conditions() {
top_border top_border
echo -e "| ${red}~~~~~~~~~~~ [ Upload Agreement ] ~~~~~~~~~~~~${white} |" echo -e "| ${red}~~~~~~~~~~~ [ Upload Agreement ] ~~~~~~~~~~~~${white} |"
hr hr
@@ -45,7 +45,7 @@ function accept_upload_conditions(){
done done
} }
function upload_selection(){ function upload_selection() {
read_kiauh_ini "${FUNCNAME[0]}" read_kiauh_ini "${FUNCNAME[0]}"
local upload_agreed="${logupload_accepted}" local upload_agreed="${logupload_accepted}"
[ "${upload_agreed}" = "false" ] && accept_upload_conditions [ "${upload_agreed}" = "false" ] && accept_upload_conditions
@@ -54,7 +54,7 @@ function upload_selection(){
local klipper_logs="${KLIPPER_LOGS}" local klipper_logs="${KLIPPER_LOGS}"
local webif_logs="/var/log/nginx" local webif_logs="/var/log/nginx"
function find_logfile(){ function find_logfile() {
local name=${1} location=${2} local name=${1} location=${2}
for log in $(find "${location}" -maxdepth 1 -type f -name "${name}" | sort -g); do for log in $(find "${location}" -maxdepth 1 -type f -name "${name}" | sort -g); do
logfiles+=("${log}") logfiles+=("${log}")
@@ -98,7 +98,7 @@ function upload_selection(){
done done
} }
function upload_log(){ function upload_log() {
local link local link
clear && print_header clear && print_header
status_msg "Uploading ${1} ..." status_msg "Uploading ${1} ..."

View File

@@ -15,7 +15,7 @@ set -e
#=================== STARTUP ====================# #=================== STARTUP ====================#
#================================================# #================================================#
function check_euid(){ function check_euid() {
if [[ ${EUID} -eq 0 ]] if [[ ${EUID} -eq 0 ]]
then then
echo -e "${red}" echo -e "${red}"
@@ -34,26 +34,26 @@ function check_euid(){
function select_msg() { function select_msg() {
echo -e "${white} [➔] ${1}" echo -e "${white} [➔] ${1}"
} }
function status_msg(){ function status_msg() {
echo -e "\n${magenta}###### ${1}${white}" echo -e "\n${magenta}###### ${1}${white}"
} }
function ok_msg(){ function ok_msg() {
echo -e "${green}[✓ OK] ${1}${white}" echo -e "${green}[✓ OK] ${1}${white}"
} }
function warn_msg(){ function warn_msg() {
echo -e "${yellow}>>>>>> ${1}${white}" echo -e "${yellow}>>>>>> ${1}${white}"
} }
function error_msg(){ function error_msg() {
echo -e "${red}>>>>>> ${1}${white}" echo -e "${red}>>>>>> ${1}${white}"
} }
function abort_msg(){ function abort_msg() {
echo -e "${red}<<<<<< ${1}${white}" echo -e "${red}<<<<<< ${1}${white}"
} }
function title_msg(){ function title_msg() {
echo -e "${cyan}${1}${white}" echo -e "${cyan}${1}${white}"
} }
function print_error(){ function print_error() {
[[ -z ${1} ]] && return [[ -z ${1} ]] && return
echo -e "${red}" echo -e "${red}"
echo -e "#=======================================================#" echo -e "#=======================================================#"
@@ -62,7 +62,7 @@ function print_error(){
echo -e "${white}" echo -e "${white}"
} }
function print_confirm(){ function print_confirm() {
[[ -z ${1} ]] && return [[ -z ${1} ]] && return
echo -e "${green}" echo -e "${green}"
echo -e "#=======================================================#" echo -e "#=======================================================#"
@@ -109,7 +109,7 @@ function log_error() {
#=============== KIAUH SETTINGS =================# #=============== KIAUH SETTINGS =================#
#================================================# #================================================#
function read_kiauh_ini(){ function read_kiauh_ini() {
local func=${1} local func=${1}
if [[ ! -f ${INI_FILE} ]]; then if [[ ! -f ${INI_FILE} ]]; then
print_error "ERROR: File '~/.kiauh.ini' not found!" print_error "ERROR: File '~/.kiauh.ini' not found!"
@@ -120,7 +120,7 @@ function read_kiauh_ini(){
source "${INI_FILE}" source "${INI_FILE}"
} }
function init_ini(){ function init_ini() {
### remove pre-version 4 ini files ### remove pre-version 4 ini files
if [[ -f ${INI_FILE} ]] && ! grep -Eq "^# KIAUH v4\.0\.0$" "${INI_FILE}"; then if [[ -f ${INI_FILE} ]] && ! grep -Eq "^# KIAUH v4\.0\.0$" "${INI_FILE}"; then
rm "${INI_FILE}" rm "${INI_FILE}"
@@ -161,7 +161,7 @@ function init_ini(){
fetch_webui_ports fetch_webui_ports
} }
function change_klipper_cfg_folder(){ function change_klipper_cfg_folder() {
local current_cfg_loc example_loc recommended_loc new_cfg_loc local current_cfg_loc example_loc recommended_loc new_cfg_loc
current_cfg_loc="$(get_klipper_cfg_dir)" current_cfg_loc="$(get_klipper_cfg_dir)"
example_loc=$(printf "%s/<your_config_folder>" "${HOME}") example_loc=$(printf "%s/<your_config_folder>" "${HOME}")
@@ -198,7 +198,7 @@ function change_klipper_cfg_folder(){
done done
} }
function set_klipper_cfg_path(){ function set_klipper_cfg_path() {
local current_cfg_loc="${1}" new_cfg_loc="${2}" local current_cfg_loc="${1}" new_cfg_loc="${2}"
local instance klipper_services moonraker_services moonraker_configs local instance klipper_services moonraker_services moonraker_configs
@@ -321,7 +321,7 @@ function switch_fluidd_releasetype() {
fi fi
} }
function toggle_backup_before_update(){ function toggle_backup_before_update() {
read_kiauh_ini "${FUNCNAME[0]}" read_kiauh_ini "${FUNCNAME[0]}"
local state="${backup_before_update}" local state="${backup_before_update}"
if [[ ${state} = "false" ]]; then if [[ ${state} = "false" ]]; then
@@ -344,7 +344,7 @@ function set_custom_klipper_repo() {
#=============== HANDLE SERVICES ================# #=============== HANDLE SERVICES ================#
#================================================# #================================================#
function do_action_service(){ function do_action_service() {
local services action=${1} service=${2} local services action=${1} service=${2}
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/${service}(-[0-9a-zA-Z]+)?.service" | sort) services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/${service}(-[0-9a-zA-Z]+)?.service" | sort)
if [[ -n ${services} ]]; then if [[ -n ${services} ]]; then
@@ -367,7 +367,7 @@ function do_action_service(){
#================================================# #================================================#
### returns 'true' if python version >= 3.7 ### returns 'true' if python version >= 3.7
function python3_check(){ function python3_check() {
local major minor passed local major minor passed
major=$(python3 --version | cut -d" " -f2 | cut -d"." -f1) major=$(python3 --version | cut -d" " -f2 | cut -d"." -f1)
@@ -382,7 +382,7 @@ function python3_check(){
echo "${passed}" echo "${passed}"
} }
function dependency_check(){ function dependency_check() {
local dep=( "${@}" ) local dep=( "${@}" )
local packages local packages
status_msg "Checking for the following dependencies:" status_msg "Checking for the following dependencies:"
@@ -412,7 +412,7 @@ function dependency_check(){
fi fi
} }
function system_check_webui(){ function system_check_webui() {
### check system for an installed haproxy service ### check system for an installed haproxy service
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
HAPROXY_FOUND="true" HAPROXY_FOUND="true"
@@ -429,7 +429,7 @@ function system_check_webui(){
fi fi
} }
function fetch_webui_ports(){ function fetch_webui_ports() {
### read ports from possible installed interfaces and write them to ~/.kiauh.ini ### read ports from possible installed interfaces and write them to ~/.kiauh.ini
local port interfaces=("mainsail" "fluidd" "octoprint") local port interfaces=("mainsail" "fluidd" "octoprint")
for interface in "${interfaces[@]}"; do for interface in "${interfaces[@]}"; do
@@ -451,7 +451,7 @@ function fetch_webui_ports(){
#=================== SYSTEM =====================# #=================== SYSTEM =====================#
#================================================# #================================================#
function check_system_updates(){ function check_system_updates() {
local updates_avail info_msg local updates_avail info_msg
updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d") updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d")
if [[ -n ${updates_avail} ]]; then if [[ -n ${updates_avail} ]]; then
@@ -465,7 +465,7 @@ function check_system_updates(){
echo "${info_msg}" echo "${info_msg}"
} }
function update_system(){ function update_system() {
status_msg "Updating System ..." status_msg "Updating System ..."
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y; then 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}" 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 fi
} }
function check_usergroups(){ function check_usergroups() {
local group_dialout group_tty local group_dialout group_tty
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
group_dialout="false" group_dialout="false"
@@ -523,7 +523,7 @@ function check_usergroups(){
fi fi
} }
function set_custom_hostname(){ function set_custom_hostname() {
echo echo
top_border top_border
echo -e "| Changing the hostname of this machine allows you to |" echo -e "| Changing the hostname of this machine allows you to |"
@@ -550,7 +550,7 @@ function set_custom_hostname(){
done done
} }
function change_hostname(){ function change_hostname() {
local new_hostname regex="^[^\-\_]+([0-9a-z]\-{0,1})+[^\-\_]+$" local new_hostname regex="^[^\-\_]+([0-9a-z]\-{0,1})+[^\-\_]+$"
echo echo
top_border top_border
@@ -584,7 +584,7 @@ function change_hostname(){
done done
} }
function set_hostname(){ function set_hostname() {
local new_hostname=${1} current_date local new_hostname=${1} current_date
#check for dependencies #check for dependencies
local dep=(avahi-daemon) local dep=(avahi-daemon)