various housekeeping

This commit is contained in:
paukstelis
2022-05-17 10:57:40 -04:00
parent 31576116f6
commit 22ec9f2750

View File

@@ -70,12 +70,12 @@ new_instance () {
read INSTANCE read INSTANCE
if [ -z "$INSTANCE" ]; then if [ -z "$INSTANCE" ]; then
echo "No instance given. Exiting" | log echo "No instance given. Exiting" | log
exit 1 main_menu
fi fi
if test -f "/etc/systemd/system/$INSTANCE.service"; then if test -f "/etc/systemd/system/$INSTANCE.service"; then
echo "Already have an entry for $INSTANCE. Exiting." | log echo "Already have an entry for $INSTANCE. Exiting." | log
exit 1 main_menu
fi fi
echo "Port on which this instance will run (ENTER will increment from last value in /etc/octoprint_instances):" echo "Port on which this instance will run (ENTER will increment from last value in /etc/octoprint_instances):"
@@ -116,7 +116,7 @@ new_instance () {
echo "Executable path is valid" | log echo "Executable path is valid" | log
else else
echo "Exectuable path is not valid! Aborting" | log echo "Exectuable path is not valid! Aborting" | log
exit 1 main_menu
fi fi
echo "Octoprint Config Path (where the hidden instance directory will be) [/home/$user/]:" echo "Octoprint Config Path (where the hidden instance directory will be) [/home/$user/]:"
@@ -136,13 +136,13 @@ new_instance () {
echo "Template path is valid" | log echo "Template path is valid" | log
else else
echo "Template path is not valid! Aborting" | log echo "Template path is not valid! Aborting" | log
exit 1 main_menu
fi fi
#check to make sure first run is complete #check to make sure first run is complete
if grep -q 'firstRun: true' $BFOLD/config.yaml; then if grep -q 'firstRun: true' $BFOLD/config.yaml; then
echo "WARNING!! You must setup the base profile and admin user before continuing" | log echo "WARNING!! You must setup the base profile and admin user before continuing" | log
exit 1 main_menu
fi fi
if prompt_confirm "Begin auto-detect printer serial number for udev entry?" if prompt_confirm "Begin auto-detect printer serial number for udev entry?"
@@ -178,11 +178,14 @@ new_instance () {
#No serial number #No serial number
if [ -z "$UDEV" ]; then if [ -z "$UDEV" ]; then
echo "Printer Serial Number not detected" echo "Printer Serial Number not detected"
prompt_confirm "Do you want to use the physical USB port to assign the udev entry? If you use this any USB hubs and printers detected this way must stay plugged into the same USB positions on your machine as they are right now" || exit 0 if prompt_confirm "Do you want to use the physical USB port to assign the udev entry? If you use this any USB hubs and printers detected this way must stay plugged into the same USB positions on your machine as they are right now"; then
echo echo
USB=$TEMPUSB USB=$TEMPUSB
echo -e "Your printer will be setup at the following usb address:\033[0;34m $USB\033[0m" | log echo -e "Your printer will be setup at the following usb address:\033[0;34m $USB\033[0m" | log
echo echo
else
main_menu
fi
else else
echo -e "Serial number detected as: \033[0;34m $UDEV\033[0m" | log echo -e "Serial number detected as: \033[0;34m $UDEV\033[0m" | log
check_sn "$UDEV" check_sn "$UDEV"
@@ -289,7 +292,7 @@ write_camera() {
#Establish which streamer system is using, default mjpg-streamer #Establish which streamer system is using, default mjpg-streamer
STREAMER=$(cat /etc/octoprint_streamer) STREAMER=$(cat /etc/octoprint_streamer)
echo $STREAMER echo $STREAMER
if [ -z "$STREAMER"]; then if [ -z "$STREAMER" ]; then
$STREAMER='mjpg-streamer' $STREAMER='mjpg-streamer'
fi fi
@@ -509,13 +512,13 @@ deb_packages() {
-e libjpeg-dev \ -e libjpeg-dev \
-e libbsd-dev \ -e libbsd-dev \
| xargs apt-get install -y | log | xargs apt-get install -y | log
#pacakges to REMOVE go here #pacakges to REMOVE go here
apt-cache --generate pkgnames \ apt-cache --generate pkgnames \
| grep --line-regexp --fixed-strings \ | grep --line-regexp --fixed-strings \
-e brltty \ -e brltty \
| xargs apt-get remove -y | log | xargs apt-get remove -y | log
} }
prepare () { prepare () {
@@ -575,8 +578,10 @@ prepare () {
echo "They will be found at /home/$user/.old-octo" echo "They will be found at /home/$user/.old-octo"
if prompt_confirm "Continue with installation?"; then if prompt_confirm "Continue with installation?"; then
echo "Continuing installation." | log echo "Continuing installation." | log
systemctl stop octoprint.service
echo "Moving files to /home/$user/.old-octo" | log echo "Moving files to /home/$user/.old-octo" | log
mv /home/$user/.octoprint /home/$user/.old-octo mv /home/$user/.octoprint /home/$user/.old-octo
systemctl start octoprint.service
else else
main_menu main_menu
fi fi
@@ -635,7 +640,9 @@ prepare () {
echo 'Updating config.yaml' echo 'Updating config.yaml'
sudo -u $user mkdir /home/$user/.octoprint sudo -u $user mkdir /home/$user/.octoprint
sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml
echo
echo
echo
PS3='Which video streamer you would like to install?: ' PS3='Which video streamer you would like to install?: '
options=("mjpeg-streamer" "ustreamer" "None") options=("mjpeg-streamer" "ustreamer" "None")
select opt in "${options[@]}" select opt in "${options[@]}"
@@ -738,9 +745,9 @@ remove_everything() {
rm -rf /home/$user/OctoPrint rm -rf /home/$user/OctoPrint
systemctl daemon-reload systemctl daemon-reload
fi fi
} }
main_menu() { main_menu() {
#reset #reset
@@ -794,5 +801,5 @@ SCRIPTDIR=$(dirname $(readlink -f $0))
if [ "$1" == remove ]; then if [ "$1" == remove ]; then
remove_everything remove_everything
fi fi
main_menu main_menu