From 3ad7d0668a101c4e18724ecbea5ab6b7af020af5 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Sat, 15 Oct 2022 11:33:25 -0400 Subject: [PATCH] scripts: add data-path-fix script This script can be used to fix broken installations on MainsailOS and FluiddPi distributions running a single instance of Moonraker. Signed-off-by: Eric Callahan --- scripts/data-path-fix.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/data-path-fix.sh diff --git a/scripts/data-path-fix.sh b/scripts/data-path-fix.sh new file mode 100755 index 0000000..553e6c1 --- /dev/null +++ b/scripts/data-path-fix.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Data Path Fix for legacy MainsailOS and FluiddPi installations running +# a single instance of Moonraker with a default configuration + +DATA_PATH="${HOME}/printer_data" +DATA_PATH_BKP="${HOME}/.broken_printer_data" +DB_PATH="${HOME}/.moonraker_database" +CONFIG_PATH="${HOME}/klipper_config" +LOG_PATH="${HOME}/klipper_logs" +GCODE_PATH="${HOME}/gcode_files" +MOOONRAKER_CONF="${CONFIG_PATH}/moonraker.conf" +MOONRAKER_LOG="${LOG_PATH}/moonraker.log" + +[ ! -d "${DB_PATH}" ] && echo "Error: unable to find database: ${DB_PATH}" && exit 1 +[ ! -f "${MOOONRAKER_CONF}" ] && echo "Error: unable to find config: ${MOOONRAKER_CONF}" && exit 1 +[ ! -d "${LOG_PATH}" ] && echo "Error: unable to find log path: ${LOG_PATH}" && exit 1 +[ ! -d "${GCODE_PATH}" ] && echo "Error: unable to find gcode path: ${GCODE_PATH}" && exit 1 + +sudo systemctl stop moonraker + +[ -d "${DATA_PATH_BKP}" ] && rm -rf ${DATA_PATH_BKP} +[ -d "${DATA_PATH}" ] && echo "Moving broken datapath to ${DATA_PATH_BKP}" && mv ${DATA_PATH} ${DATA_PATH_BKP} + +mkdir ${DATA_PATH} + +echo "Creating symbolic links..." +ln -s ${DB_PATH} "$DATA_PATH/database" +ln -s ${GCODE_PATH} "$DATA_PATH/gcodes" +ln -s ${LOG_PATH} "$DATA_PATH/logs" +ln -s ${CONFIG_PATH} "$DATA_PATH/config" + +~/moonraker-env/bin/python -mlmdb -e ${DB_PATH} -d moonraker edit --delete=validate_install + +echo "Running install script" + +~/moonraker/scripts/install-moonraker.sh -f -c ${MOOONRAKER_CONF} -l ${MOONRAKER_LOG}