updated service and improved menu
This commit is contained in:
@@ -1,17 +1,39 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if (( $EUID != 0 )); then
|
if (( $EUID != 0 )); then
|
||||||
echo "Please run as root"
|
echo "Please run as root (sudo)"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
|
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
|
||||||
|
|
||||||
echo "Please select the type of installation:"
|
PIDEFAULT="/home/$user/oprint/bin/octoprint"
|
||||||
echo "1 - OctoPi"
|
BUDEFAULT="/home/$user/OctoPrint/bin/octoprint"
|
||||||
echo "2 - Octobuntu"
|
OTHERDEFAULT=""
|
||||||
echo "3 - Other (few defaults)"
|
PS3='Installation type: '
|
||||||
read INSTALL
|
options=("OctoPi" "OctoBuntu" "Other" "Quit")
|
||||||
|
select opt in "${options[@]}"
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
"OctoPi")
|
||||||
|
DAEMONPATH=$PIDEFAULT
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"OctoBuntu")
|
||||||
|
DAEMONPATH=$BUDEFAULT
|
||||||
|
INSTALL=2
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"Other")
|
||||||
|
DAEMONPATH=$OTHERDEFAULT
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"Quit")
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*) echo "invalid option $REPLY";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
echo "UNPLUG PRINTER FROM USB"
|
echo "UNPLUG PRINTER FROM USB"
|
||||||
echo "Enter the name for new printer/instance:"
|
echo "Enter the name for new printer/instance:"
|
||||||
@@ -53,21 +75,6 @@ if [ -z "$OCTOUSER" ]; then
|
|||||||
OCTOUSER=$user
|
OCTOUSER=$user
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PIDEFAULT="/home/$user/oprint/bin/octoprint"
|
|
||||||
BUDEFAULT="/home/$user/octoprint/bin/octoprint"
|
|
||||||
OTHERDEFAULT=""
|
|
||||||
if [ $INSTALL=1 ]; then
|
|
||||||
DAEMONPATH=$PIDEFAULT
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $INSTALL=2 ]; then
|
|
||||||
DAEMONPATH=$BUDEFAULT
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $INSTALL=3 ]; then
|
|
||||||
DAEMONPATH=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Octoprint Executable Daemon Path [$DAEMONPATH]:"
|
echo "Octoprint Executable Daemon Path [$DAEMONPATH]:"
|
||||||
read OCTOPATH
|
read OCTOPATH
|
||||||
if [ -z "$OCTOPATH" ]; then
|
if [ -z "$OCTOPATH" ]; then
|
||||||
@@ -101,10 +108,17 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#check to make sure first run is complete
|
||||||
|
if grep -q 'firstRun: true' $BFOLD/config.yaml; then
|
||||||
|
echo "WARNING!! You should run $OCTOPATH serve and setup the base profile and admin user before continuing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
read -p "Auto-detect printer serial number for udev entry?" -n 1 -r
|
read -p "Auto-detect printer serial number for udev entry?" -n 1 -r
|
||||||
echo #new line
|
echo #new line
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||||
then
|
then
|
||||||
|
echo
|
||||||
#clear out journalctl - probably a better way to do this
|
#clear out journalctl - probably a better way to do this
|
||||||
journalctl --rotate > /dev/null 2>&1
|
journalctl --rotate > /dev/null 2>&1
|
||||||
journalctl --vacuum-time=1seconds > /dev/null 2>&1
|
journalctl --vacuum-time=1seconds > /dev/null 2>&1
|
||||||
@@ -123,19 +137,23 @@ then
|
|||||||
USB=$TEMPUSB
|
USB=$TEMPUSB
|
||||||
echo "Your printer will be setup at the following usb address:"
|
echo "Your printer will be setup at the following usb address:"
|
||||||
echo $USB
|
echo $USB
|
||||||
echo
|
echo
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Serial number detected as: $UDEV"
|
echo "Serial number detected as: $UDEV"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Octobuntu cameras
|
#Octobuntu cameras
|
||||||
if [ $INSTALL=2 ]; then
|
if [[ $INSTALL = 2 ]]; then
|
||||||
read -p "Would you like to auto detect an associated USB camera?" -n 1 -r
|
read -p "Would you like to auto detect an associated USB camera (experimental)?" -n 1 -r
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||||
then
|
then
|
||||||
|
echo
|
||||||
#clear out journalctl - probably a better way to do this
|
#clear out journalctl - probably a better way to do this
|
||||||
journalctl --rotate > /dev/null 2>&1
|
journalctl --rotate > /dev/null 2>&1
|
||||||
journalctl --vacuum-time=1seconds > /dev/null 2>&1
|
journalctl --vacuum-time=1seconds > /dev/null 2>&1
|
||||||
@@ -143,13 +161,15 @@ if [ $INSTALL=2 ]; then
|
|||||||
counter=0
|
counter=0
|
||||||
while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do
|
while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do
|
||||||
CAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*SerialNumber: //p')
|
CAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*SerialNumber: //p')
|
||||||
TEMPUSBCAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*cdc_acm \(.*\): tty.*/\1/p')
|
TEMPUSBCAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*uvcvideo \(.*\): tty.*/\1/p')
|
||||||
counter=$(( $counter + 1 ))
|
counter=$(( $counter + 1 ))
|
||||||
done
|
done
|
||||||
if [ -z "$CAM" ]; then
|
if [ -z "$CAM" ]; then
|
||||||
echo "Camera Serial Number not detected"
|
echo "Camera Serial Number not detected"
|
||||||
echo "Your camera should remain at the same USB position and hub. Its position in in udev is $TEMPUSBCAM"
|
echo "Your camera should remain at the same USB position and hub. Its position in in udev is $TEMPUSBCAM"
|
||||||
USBCAM=$TEMPUSBCAM
|
USBCAM=$TEMPUSBCAM
|
||||||
|
else
|
||||||
|
echo "Camera detected with serial number: $CAM"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -179,12 +199,12 @@ then
|
|||||||
#Octobuntu Cameras udev identifier - either Serial number or USB port
|
#Octobuntu Cameras udev identifier - either Serial number or USB port
|
||||||
#Serial Number
|
#Serial Number
|
||||||
if [ -n "$CAM" ]; then
|
if [ -n "$CAM" ]; then
|
||||||
echo SUBSYSTEM==\"v4l\", ATTRS{serial}==\"$CAM\", SYMLINK+=\"$INSTANCE_cam\" >> /etc/udev/rules.d/99-octoprint.rules
|
echo SUBSYSTEM==\"video4linux\", ATTRS{serial}==\"$CAM\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#USB port
|
#USB port
|
||||||
if [ -n "$USBCAM" ]; then
|
if [ -n "$USBCAM" ]; then
|
||||||
echo KERNELS==\"$USBCAM\",SUBSYSTEMS==\"v4l\",SYMLINK+=\"$INSTANCE_cam\" >> /etc/udev/rules.d/99-octoprint.rules
|
echo KERNELS==\"$USBCAM\",SUBSYSTEMS==\"video4linux\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#just to be on the safe side, add user to dialout
|
#just to be on the safe side, add user to dialout
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ Environment="HOST=127.0.0.1"
|
|||||||
Environment="PORT=NEWPORT"
|
Environment="PORT=NEWPORT"
|
||||||
Environment="BASEDIR=OCTOCONFIG/.NEWINSTANCE"
|
Environment="BASEDIR=OCTOCONFIG/.NEWINSTANCE"
|
||||||
Environment="CONFIGFILE=OCTOCONFIG/.NEWINSTANCE/config.yaml"
|
Environment="CONFIGFILE=OCTOCONFIG/.NEWINSTANCE/config.yaml"
|
||||||
Environment="EXEC=OCTOPATH"
|
|
||||||
Type=simple
|
|
||||||
User=OCTOUSER
|
User=OCTOUSER
|
||||||
ExecStart=${EXEC} serve --config=${CONFIGFILE} --basedir=${BASEDIR} --host=${HOST} --port=${PORT}
|
ExecStart=OCTOPATH serve --config=${CONFIGFILE} --basedir=${BASEDIR} --host=${HOST} --port=${PORT}
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Reference in New Issue
Block a user