14
kiauh.sh
14
kiauh.sh
@@ -13,9 +13,9 @@ set -e
|
||||
clear
|
||||
|
||||
### sourcing all additional scripts
|
||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||||
for script in "${SRCDIR}/kiauh/scripts/"*.sh; do . "${script}"; done
|
||||
for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . "${script}"; done
|
||||
KIAUH_SRCDIR="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")"
|
||||
for script in "${KIAUH_SRCDIR}/scripts/"*.sh; do . "${script}"; done
|
||||
for script in "${KIAUH_SRCDIR}/scripts/ui/"*.sh; do . "${script}"; done
|
||||
|
||||
#===================================================#
|
||||
#=================== UPDATE KIAUH ==================#
|
||||
@@ -23,7 +23,7 @@ for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . "${script}"; done
|
||||
|
||||
function update_kiauh(){
|
||||
status_msg "Updating KIAUH ..."
|
||||
cd "${SRCDIR}/kiauh"
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
git reset --hard && git pull
|
||||
ok_msg "Update complete! Please restart KIAUH."
|
||||
exit 0
|
||||
@@ -34,16 +34,16 @@ function update_kiauh(){
|
||||
#===================================================#
|
||||
|
||||
function kiauh_update_avail(){
|
||||
[ ! -d "${SRCDIR}/kiauh/.git" ] && return
|
||||
[[ ! -d "${KIAUH_SRCDIR}/.git" ]] && return
|
||||
local origin head
|
||||
cd "${SRCDIR}/kiauh"
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
### abort if not on master branch
|
||||
! git branch -a | grep -q "\* master" && return
|
||||
### compare commit hash
|
||||
git fetch -q
|
||||
origin=$(git rev-parse --short=8 origin/master)
|
||||
head=$(git rev-parse --short=8 HEAD)
|
||||
if [ "${origin}" != "${head}" ]; then
|
||||
if [[ ${origin} != ${head} ]]; then
|
||||
echo "true"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ function fluidd_port_check(){
|
||||
select_fluidd_port
|
||||
fi
|
||||
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}
|
||||
fi
|
||||
SET_NGINX_CFG="true"
|
||||
|
||||
@@ -68,7 +68,7 @@ function setup_gcode_shell_command(){
|
||||
function install_gcode_shell_command(){
|
||||
do_action_service "stop" "klipper"
|
||||
status_msg "Copy 'gcode_shell_command.py' to '${KLIPPER_DIR}/klippy/extras' ..."
|
||||
if cp "${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!"
|
||||
else
|
||||
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)
|
||||
if [ ! -f "${path}/shell_command.cfg" ]; then
|
||||
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!"
|
||||
### write the include to the very first line of the printer.cfg
|
||||
sed -i "1 i [include shell_command.cfg]" "${cfg}"
|
||||
|
||||
@@ -27,7 +27,7 @@ function set_globals(){
|
||||
white=$(echo -en "\e[39m")
|
||||
INI_FILE="${HOME}/.kiauh.ini"
|
||||
LOGFILE="/tmp/kiauh.log"
|
||||
RESOURCES="${SRCDIR}/kiauh/resources"
|
||||
RESOURCES="${KIAUH_SRCDIR}/resources"
|
||||
BACKUP_DIR="${HOME}/kiauh-backups"
|
||||
|
||||
#================== KLIPPER ===================#
|
||||
|
||||
@@ -250,7 +250,7 @@ function klipper_setup(){
|
||||
|
||||
function write_klipper_service(){
|
||||
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
|
||||
if [ ! -f "${service}" ]; then
|
||||
status_msg "Creating Klipper Service ${i} ..."
|
||||
@@ -264,7 +264,7 @@ function write_klipper_service(){
|
||||
|
||||
function write_example_printer_cfg(){
|
||||
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
|
||||
if ! [[ -d "${cfg_dir}" ]]; then
|
||||
|
||||
@@ -449,7 +449,7 @@ function mainsail_port_check(){
|
||||
select_mainsail_port
|
||||
fi
|
||||
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}
|
||||
fi
|
||||
SET_NGINX_CFG="true"
|
||||
|
||||
@@ -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 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 service="${SRCDIR}/kiauh/resources/webcamd.service"
|
||||
local service="${KIAUH_SRCDIR}/resources/webcamd.service"
|
||||
|
||||
### return early if webcamd.service already exists
|
||||
if [ -f "${SYSTEMD}/webcamd.service" ]; then
|
||||
|
||||
@@ -260,7 +260,7 @@ function create_telegram_bot_service(){
|
||||
|
||||
function write_telegram_bot_service(){
|
||||
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
|
||||
if ! [[ -f "${service}" ]]; then
|
||||
|
||||
@@ -239,7 +239,7 @@ function create_moonraker_conf(){
|
||||
|
||||
function write_moonraker_conf(){
|
||||
local cfg_dir=${1} cfg=${2} port=${3} log=${4} db=${5} uds=${6} lan=${7}
|
||||
local conf_template="${SRCDIR}/kiauh/resources/moonraker.conf"
|
||||
local conf_template="${KIAUH_SRCDIR}/resources/moonraker.conf"
|
||||
[ ! -d "${cfg_dir}" ] && mkdir -p "${cfg_dir}"
|
||||
|
||||
if [ ! -f "${cfg}" ]; then
|
||||
@@ -310,7 +310,7 @@ function create_moonraker_service(){
|
||||
|
||||
function write_moonraker_service(){
|
||||
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
|
||||
if [ ! -f "${service}" ]; then
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
set -e
|
||||
|
||||
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=()
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ function main_ui(){
|
||||
|
||||
function get_kiauh_version(){
|
||||
local version
|
||||
cd "${SRCDIR}/kiauh"
|
||||
cd "${KIAUH_SRCDIR}"
|
||||
version="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user