24 lines
592 B
Bash
24 lines
592 B
Bash
#!/usr/bin/env sh
|
|
# SPDX-License-Identifier: GPL-3.0
|
|
# Denis Kanuf <https://denkn.at>
|
|
|
|
device=$(hostname)
|
|
|
|
if [ "$device" = "${device#ttyUSB}" ]
|
|
then
|
|
>&2 echo "not a container for running octoprint - no device"
|
|
exit 0
|
|
|
|
elif [ -e "/dev/$device" ]
|
|
then
|
|
> /local/env echo OCTOPRINT_HOST=0.0.0.0
|
|
>>/local/env echo OCTOPRINT_PORT=$((2000+${device#*USB}))
|
|
install -o octoprint -g octoprint -m 700 -d /var/lib/octoprint
|
|
/usr/bin/systemctl enable --no-block --now octoprint.service
|
|
/usr/bin/systemctl disable octoprint-init.service
|
|
|
|
else
|
|
>&2 echo "Device not found: $device"
|
|
exit 1
|
|
fi
|