Unknown status, resuming project

This commit is contained in:
Elizabeth Cray 2024-07-29 21:18:31 -04:00
parent 51f933f048
commit 0954b57b30

View File

@ -2,14 +2,25 @@
# TODO: CHANGE KLIPPER PORTS # TODO: CHANGE KLIPPER PORTS
ROOT_DIR="$(dirname "$0")" SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do
TARGET=$(readlink "$SOURCE")
if [[ $TARGET == /* ]]; then
SOURCE=$TARGET
else
DIR=$( dirname "$SOURCE" )
SOURCE=$DIR/$TARGET
fi
done
RDIR=$( dirname "$SOURCE" )
ROOT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
cd $ROOT_DIR cd $ROOT_DIR
# Pull Klipper # Pull Klipper
git submodule update --init --recursive git submodule update --init --recursive
# Select Klipper Config # Select Klipper Config
cd dirs/klipper cd $ROOT_DIR/dirs/klipper
make menuconfig make menuconfig
CONFIG_FILES=(`ls config`) CONFIG_FILES=(`ls config`)
CONFIG_FILES+=("Enter_Manually") CONFIG_FILES+=("Enter_Manually")
@ -52,16 +63,18 @@ if [[ $DEVICE == "Enter_Manually" ]]; then
fi fi
# Name Printer # Name Printer
# Todo: avoid duplications
NAME_NOT_VALID=true NAME_NOT_VALID=true
while $NAME_NOT_VALID ; do while $NAME_NOT_VALID ; do
PRINTER_NAME="$(dialog --backtitle 'drwho@hackers.town' --inputbox 'Name This Printer' 8 40 \"${PRINTER_NAME}\" 3>&1 1>&2 2>&3)" PRINTER_NAME=$(dialog --backtitle 'drwho@hackers.town' --inputbox 'Name This Printer' 8 40 "${PRINTER_NAME}" 3>&1 1>&2 2>&3)
if [[ $PRINTER_NAME =~ ^[a-zA-Z0-9_-]+$ ]]; then if [[ $PRINTER_NAME =~ ^[a-zA-Z0-9_-]+$ ]]; then
NAME_NOT_VALID=false NAME_NOT_VALID=false
fi fi
done done
# Build Klipper # Build Klipper
cat $CONFIG_FILE | sed -e "s/^serial: .\+$/serial: \/dev\/serial\/by-id\/${DEVICE}/" > ./printer.cfg cp $CONFIG_FILE $ROOT_DIR/dirs/klipper/printer.cfg
sed -i -e "s/^serial: .\+$/serial: \/dev\/serial\/by-id\/${DEVICE}/g" "${ROOT_DIR}/dirs/klipper/printer.cfg"
make -j$(nproc) make -j$(nproc)
# Flash Firmware # Flash Firmware
@ -74,17 +87,17 @@ cat klipper/printer.cfg >> printer.cfg.tmp
mv printer.cfg.tmp printer_data/config/printer.cfg mv printer.cfg.tmp printer_data/config/printer.cfg
# Apply Edits to Configs # Apply Edits to Configs
cd $ROOT_DIR/dirs/print_data cd $ROOT_DIR/dirs/printer_data/config
cat config/moonraker.conf | sed -e "s/PRINTERNAME/$PRINTER_NAME/g" > config/moonraker.conf.tmp sed -i -e "s/PRINTERNAME/$PRINTER_NAME/g" "moonraker.conf"
mv config/moonraker.conf.tmp config/moonraker.conf
cat mainsail-config/client.cfg | sed -e "s/~\/printer_data/~\/$PRINTER_NAME\/printer_data/g" > mainsail-config/client.cfg.tmp cd $ROOT_DIR/dirs/mainsail-config
mv mainsail-config/client.cfg.tmp mainsail-config/client.cfg sed -i -e "s/~\/printer_data/~\/$PRINTER_NAME\/printer_data/g" "client.cfg"
FILES=(crowsnest moonraker klipper) cd $ROOT_DIR/config/services
# TODO: Add Crowsnest Support
FILES=(moonraker klipper)
for f in ${FILES[@]}; do for f in ${FILES[@]}; do
cat systemd/$f.service | sed -e "s/PRINTERNAME/$PRINTER_NAME/g" > systemd/$f.service.tmp sed -i -e "s/PRINTERNAME/$PRINTER_NAME/g" "${f}.service"
mv systemd/$f.service.tmp systemd/$f.service
done done
# Download Mainsail # Download Mainsail
@ -107,7 +120,8 @@ cd $ROOT_DIR/config/services
SERVICES=() SERVICES=()
for f in *.service; do for f in *.service; do
SERVICES+=($f) SERVICES+=($f)
cat $f | sed -e "s/PRINTERNAME/$PRINTER_NAME/g" > /etc/systemd/system/$PRINTERNAME-$f cp "${f}" "${PRINTER_NAME}-${f}"
sed -i -e "s/PRINTERNAME/$PRINTER_NAME/g" "${PRINTER_NAME}-${f}"
done done
# Install System Services # Install System Services
@ -117,3 +131,6 @@ for svc in ${SERVICES[@]}; do
sudo systemctl enable $PRINTER_NAME-$svc sudo systemctl enable $PRINTER_NAME-$svc
sudo systemctl start $PRINTER_NAME-$svc sudo systemctl start $PRINTER_NAME-$svc
done done
# Cleanup
rm -rf "${ROOT_DIR}/mainsail.zip"