Unknown status, resuming project
This commit is contained in:
parent
51f933f048
commit
0954b57b30
43
setup.sh
43
setup.sh
@ -2,14 +2,25 @@
|
||||
|
||||
# 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
|
||||
|
||||
# Pull Klipper
|
||||
git submodule update --init --recursive
|
||||
|
||||
# Select Klipper Config
|
||||
cd dirs/klipper
|
||||
cd $ROOT_DIR/dirs/klipper
|
||||
make menuconfig
|
||||
CONFIG_FILES=(`ls config`)
|
||||
CONFIG_FILES+=("Enter_Manually")
|
||||
@ -52,16 +63,18 @@ if [[ $DEVICE == "Enter_Manually" ]]; then
|
||||
fi
|
||||
|
||||
# Name Printer
|
||||
# Todo: avoid duplications
|
||||
NAME_NOT_VALID=true
|
||||
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
|
||||
NAME_NOT_VALID=false
|
||||
fi
|
||||
done
|
||||
|
||||
# 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)
|
||||
|
||||
# Flash Firmware
|
||||
@ -74,17 +87,17 @@ cat klipper/printer.cfg >> printer.cfg.tmp
|
||||
mv printer.cfg.tmp printer_data/config/printer.cfg
|
||||
|
||||
# Apply Edits to Configs
|
||||
cd $ROOT_DIR/dirs/print_data
|
||||
cat config/moonraker.conf | sed -e "s/PRINTERNAME/$PRINTER_NAME/g" > config/moonraker.conf.tmp
|
||||
mv config/moonraker.conf.tmp config/moonraker.conf
|
||||
cd $ROOT_DIR/dirs/printer_data/config
|
||||
sed -i -e "s/PRINTERNAME/$PRINTER_NAME/g" "moonraker.conf"
|
||||
|
||||
cat mainsail-config/client.cfg | sed -e "s/~\/printer_data/~\/$PRINTER_NAME\/printer_data/g" > mainsail-config/client.cfg.tmp
|
||||
mv mainsail-config/client.cfg.tmp mainsail-config/client.cfg
|
||||
cd $ROOT_DIR/dirs/mainsail-config
|
||||
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
|
||||
cat systemd/$f.service | sed -e "s/PRINTERNAME/$PRINTER_NAME/g" > systemd/$f.service.tmp
|
||||
mv systemd/$f.service.tmp systemd/$f.service
|
||||
sed -i -e "s/PRINTERNAME/$PRINTER_NAME/g" "${f}.service"
|
||||
done
|
||||
|
||||
# Download Mainsail
|
||||
@ -107,7 +120,8 @@ cd $ROOT_DIR/config/services
|
||||
SERVICES=()
|
||||
for f in *.service; do
|
||||
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
|
||||
|
||||
# Install System Services
|
||||
@ -117,3 +131,6 @@ for svc in ${SERVICES[@]}; do
|
||||
sudo systemctl enable $PRINTER_NAME-$svc
|
||||
sudo systemctl start $PRINTER_NAME-$svc
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
rm -rf "${ROOT_DIR}/mainsail.zip"
|
||||
|
Loading…
Reference in New Issue
Block a user