octoprint-containers/octoprint/bin/run.sh-old

48 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Check for certificates and start haproxy
set -x
BaseDir=/opt/octoprint/data/octoprint
if [ ! -f ${BaseDir}/config.yaml ]; then
if [[ "${WITH_KLIPPER}" == "yes" ]]; then
echo "*** Copying initial config file and enabling klipper"
mkdir -p ${BaseDir}
yq -Y --arg octo_printer "${OCTO_PRINTER}" --arg printer_cfg "${PRINTER_CFG}" ' .serial.abortHeatupOnCancel = false \
| .serial.disconnectOnErrors = false \
| .serial.additionalPorts = [$octo_printer] \
| .serial.baudrate = 250000 \
| .serial.port = $octo_printer \
| .serial.timeout.communication = 40 \
| .serial.timeout.temperature = 9.0 \
| .serial.timeout.temperatureAutoreport = 3.0 \
| .serial.timeout.temperatureTargetSet = 6.0 \
| .serial.unknownCommandsNeedAck = true \
| .plugins.klipper._config_version = 2 \
| .plugins.klipper.configuration.configpath = "$octo_printer/$printer_cfg" \
| .plugins.klipper.configuration.logpath = "$octo_printer/klippy.log" \
| .plugins.klipper.connection.port = "$octo_printer/printer" \
| .plugins.tracking.enabled = false \
| .server.firstRun = false \
| .server.commands.serverRestartCommand = "/opt/octoprint/bin/restart.sh" \
| .server.commands.systemRestartCommand = "/opt/octoprint/bin/reboot.sh" \
| .server.commands.systemShutdownCommand = "/opt/octoprint/bin/poweroff.sh" \
| .server.onlineCheck.enabled = true \
| .server.onlineCheck.host = "94.247.43.254" \
| .server.pluginBlacklist.enabled = true \
| .server.seenWizards.backup = null \
| .server.seenWizards.corewizard = 3 \
| .server.seenWizards.tracking = null ' \
etc/config.yaml > ${BaseDir}/config.yaml
else
echo "*** Copying initial config file"
mkdir -p ${BaseDir}
cp etc/config.yaml ${BaseDir}
fi
fi
echo "*** Set permissions on $(dirname ${OCTO_PRINTER})"
chmod 775 $(dirname ${OCTO_PRINTER})
echo "*** Starting octoprint"
exec /opt/octoprint/OctoPrint/venv/bin/octoprint --basedir ${BaseDir} serve --iknowwhatimdoing