refactor: fix #194

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-05-14 14:04:39 +02:00
parent 1f6745cc7b
commit 1d16235c24
11 changed files with 21 additions and 21 deletions

View File

@@ -13,9 +13,9 @@ set -e
clear clear
### sourcing all additional scripts ### sourcing all additional scripts
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )" KIAUH_SRCDIR="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")"
for script in "${SRCDIR}/kiauh/scripts/"*.sh; do . "${script}"; done for script in "${KIAUH_SRCDIR}/scripts/"*.sh; do . "${script}"; done
for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . "${script}"; done for script in "${KIAUH_SRCDIR}/scripts/ui/"*.sh; do . "${script}"; done
#===================================================# #===================================================#
#=================== UPDATE KIAUH ==================# #=================== UPDATE KIAUH ==================#
@@ -23,7 +23,7 @@ for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . "${script}"; done
function update_kiauh(){ function update_kiauh(){
status_msg "Updating KIAUH ..." status_msg "Updating KIAUH ..."
cd "${SRCDIR}/kiauh" cd "${KIAUH_SRCDIR}"
git reset --hard && git pull git reset --hard && git pull
ok_msg "Update complete! Please restart KIAUH." ok_msg "Update complete! Please restart KIAUH."
exit 0 exit 0
@@ -34,16 +34,16 @@ function update_kiauh(){
#===================================================# #===================================================#
function kiauh_update_avail(){ function kiauh_update_avail(){
[ ! -d "${SRCDIR}/kiauh/.git" ] && return [[ ! -d "${KIAUH_SRCDIR}/.git" ]] && return
local origin head local origin head
cd "${SRCDIR}/kiauh" cd "${KIAUH_SRCDIR}"
### abort if not on master branch ### abort if not on master branch
! git branch -a | grep -q "\* master" && return ! git branch -a | grep -q "\* master" && return
### compare commit hash ### compare commit hash
git fetch -q git fetch -q
origin=$(git rev-parse --short=8 origin/master) origin=$(git rev-parse --short=8 origin/master)
head=$(git rev-parse --short=8 HEAD) head=$(git rev-parse --short=8 HEAD)
if [ "${origin}" != "${head}" ]; then if [[ ${origin} != ${head} ]]; then
echo "true" echo "true"
fi fi
} }

View File

@@ -333,7 +333,7 @@ function fluidd_port_check(){
select_fluidd_port select_fluidd_port
fi fi
else else
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1) DEFAULT_PORT=$(grep listen "${KIAUH_SRCDIR}/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=${DEFAULT_PORT} SET_LISTEN_PORT=${DEFAULT_PORT}
fi fi
SET_NGINX_CFG="true" SET_NGINX_CFG="true"

View File

@@ -68,7 +68,7 @@ function setup_gcode_shell_command(){
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 "${SRCDIR}/kiauh/resources/gcode_shell_command.py" "${KLIPPER_DIR}/klippy/extras"; then if cp "${KIAUH_SRCDIR}/resources/gcode_shell_command.py" "${KLIPPER_DIR}/klippy/extras"; then
ok_msg "Done!" ok_msg "Done!"
else else
error_msg "Cannot copy file to target destination...Exiting!" error_msg "Cannot copy file to target destination...Exiting!"
@@ -102,7 +102,7 @@ function create_example_shell_command() {
path=$(echo "${cfg}" | rev | cut -d"/" -f2- | rev) path=$(echo "${cfg}" | rev | cut -d"/" -f2- | rev)
if [ ! -f "${path}/shell_command.cfg" ]; then if [ ! -f "${path}/shell_command.cfg" ]; then
status_msg "Copy shell_command.cfg to ${path} ..." status_msg "Copy shell_command.cfg to ${path} ..."
cp "${SRCDIR}/kiauh/resources/shell_command.cfg" "${path}" cp "${KIAUH_SRCDIR}/resources/shell_command.cfg" "${path}"
ok_msg "${path}/shell_command.cfg created!" ok_msg "${path}/shell_command.cfg created!"
### write the include to the very first line of the printer.cfg ### write the include to the very first line of the printer.cfg
sed -i "1 i [include shell_command.cfg]" "${cfg}" sed -i "1 i [include shell_command.cfg]" "${cfg}"

View File

@@ -27,7 +27,7 @@ function set_globals(){
white=$(echo -en "\e[39m") white=$(echo -en "\e[39m")
INI_FILE="${HOME}/.kiauh.ini" INI_FILE="${HOME}/.kiauh.ini"
LOGFILE="/tmp/kiauh.log" LOGFILE="/tmp/kiauh.log"
RESOURCES="${SRCDIR}/kiauh/resources" RESOURCES="${KIAUH_SRCDIR}/resources"
BACKUP_DIR="${HOME}/kiauh-backups" BACKUP_DIR="${HOME}/kiauh-backups"
#================== KLIPPER ===================# #================== KLIPPER ===================#

View File

@@ -250,7 +250,7 @@ function klipper_setup(){
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="${SRCDIR}/kiauh/resources/klipper.service" local service_template="${KIAUH_SRCDIR}/resources/klipper.service"
### replace all placeholders ### replace all placeholders
if [ ! -f "${service}" ]; then if [ ! -f "${service}" ]; then
status_msg "Creating Klipper Service ${i} ..." status_msg "Creating Klipper Service ${i} ..."
@@ -264,7 +264,7 @@ function write_klipper_service(){
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="${SRCDIR}/kiauh/resources/printer.cfg" local cfg_template="${KIAUH_SRCDIR}/resources/printer.cfg"
### create a config directory if it doesn't exist ### create a config directory if it doesn't exist
if ! [[ -d "${cfg_dir}" ]]; then if ! [[ -d "${cfg_dir}" ]]; then

View File

@@ -449,7 +449,7 @@ function mainsail_port_check(){
select_mainsail_port select_mainsail_port
fi fi
else else
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1) DEFAULT_PORT=$(grep listen "${KIAUH_SRCDIR}/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=${DEFAULT_PORT} SET_LISTEN_PORT=${DEFAULT_PORT}
fi fi
SET_NGINX_CFG="true" SET_NGINX_CFG="true"

View File

@@ -19,7 +19,7 @@ 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"
local service="${SRCDIR}/kiauh/resources/webcamd.service" local service="${KIAUH_SRCDIR}/resources/webcamd.service"
### return early if webcamd.service already exists ### return early if webcamd.service already exists
if [ -f "${SYSTEMD}/webcamd.service" ]; then if [ -f "${SYSTEMD}/webcamd.service" ]; then

View File

@@ -260,7 +260,7 @@ function create_telegram_bot_service(){
function write_telegram_bot_service(){ function write_telegram_bot_service(){
local i=${1} cfg=${2} service=${3} local i=${1} cfg=${2} service=${3}
local service_template="${SRCDIR}/kiauh/resources/moonraker-telegram-bot.service" local service_template="${KIAUH_SRCDIR}/resources/moonraker-telegram-bot.service"
### replace all placeholders ### replace all placeholders
if ! [[ -f "${service}" ]]; then if ! [[ -f "${service}" ]]; then

View File

@@ -239,7 +239,7 @@ function create_moonraker_conf(){
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="${SRCDIR}/kiauh/resources/moonraker.conf" local conf_template="${KIAUH_SRCDIR}/resources/moonraker.conf"
[ ! -d "${cfg_dir}" ] && mkdir -p "${cfg_dir}" [ ! -d "${cfg_dir}" ] && mkdir -p "${cfg_dir}"
if [ ! -f "${cfg}" ]; then if [ ! -f "${cfg}" ]; then
@@ -310,7 +310,7 @@ function create_moonraker_service(){
function write_moonraker_service(){ function write_moonraker_service(){
local i=${1} cfg_dir=${2} cfg=${3} log=${4} service=${5} local i=${1} cfg_dir=${2} cfg=${3} log=${4} service=${5}
local service_template="${SRCDIR}/kiauh/resources/moonraker.service" local service_template="${KIAUH_SRCDIR}/resources/moonraker.service"
### replace all placeholders ### replace all placeholders
if [ ! -f "${service}" ]; then if [ ! -f "${service}" ]; then

View File

@@ -12,11 +12,11 @@
set -e set -e
function change_klipper_repo_menu(){ function change_klipper_repo_menu(){
local repo_file="${SRCDIR}/kiauh/klipper_repos.txt" local repo_file="${KIAUH_SRCDIR}/klipper_repos.txt"
local repo branch repos=() branches=() local repo branch repos=() branches=()
if [[ ! -f ${repo_file} ]]; then if [[ ! -f ${repo_file} ]]; then
print_error "File not found:\n '${SRCDIR}/kiauh/klipper_repos.txt'" print_error "File not found:\n '${KIAUH_SRCDIR}/klipper_repos.txt'"
return return
fi fi

View File

@@ -31,7 +31,7 @@ function main_ui(){
function get_kiauh_version(){ function get_kiauh_version(){
local version local version
cd "${SRCDIR}/kiauh" 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}"
} }