Files
octodocker_deploy/menu.sh
paukstelis 8d57a478be Rework (#94)
* split

* split2

* more splitting

* working

* towards working

* menu changes

* run through prepare

* minorfix

* octoprint_generic

* break in template

* replace daemonpath with octoexec

* move first install to instance

* move BASE to instance

* instance fix

* double period

* damn loop!

* add camera to deploy

* fix camera

* toward functional

* main_menu if not ready

* not equal or  -ne?

* template copy

* clean ups

* byid camera detect

* do byid detect by default

* classwebcam

* classicwebcam

* appned_value camera work

* use users for modification in cameras

* fancy colors

* updating colors

* status menu colors and cams

* surpress errors on no files

* remove most logging

* dnf mods

* selinux

* redirect error output to /dev/null

* package cleanup

* remove udev, cloud

* octopi update

* resource prepare from menu

* quick fix

* pacman fix

* more echos

* add udev flag in /etc/octoprint_deploy

* opensuse fixes

* zypper, minor fixes

* change_streamer

* diagnostics, octoprint_cameras, etc

* diagnostic menu

* logging for diagnostics

* add config.yaml to diagnostics

* add logging for config.yaml

* readme work, add deb_pacakges for octopi,

* README

* port fixing

* port fixes

* add deb_packages command for troubleshooting

* fix ports

* add octopi flag, I fucking hate octopi

* udev rule work

* add/remove udev

* menu fix

* menu fixes

* add detect printer for add_udev

* better detection for remove_udev

* remove udev

* working on sed for udev

* fixed udev remove

* camera udev

* add instace to add_udev_camera

* readme, cleanup

* choose what parts of template to copy

* rsync as user

* additionalPorts

* remove cameras from camera list
2023-06-25 17:09:01 -04:00

259 lines
6.2 KiB
Bash

#!/bin/bash
source $SCRIPTDIR/prepare.sh
white=$(echo -en "\e[39m")
green=$(echo -en "\e[92m")
magenta=$(echo -en "\e[35m")
cyan=$(echo -en "\e[96m")
yellow=$(echo -en "\e[93m")
main_menu() {
VERSION=1.0.0
#reset
UDEV=''
TEMPUSB=''
CAM=''
TEMPUSBCAM=''
INSTANCE=''
INSTALL=''
CAMHAPROXY=''
echo
echo
echo "${cyan}*************************${white}"
echo "${green}octoprint_deploy${white} $VERSION"
echo "${cyan}*************************${white}"
echo
PS3="${green}Select operation: ${white}"
if [ -f "/etc/octoprint_deploy" ]; then
options=("Add instance" "Delete instance" "Add Camera" "Delete Camera" "Utilities" "Backup Menu" "Update" "Quit")
else
options=("Prepare system" "Update" "Quit")
fi
select opt in "${options[@]}"
do
case $opt in
"Prepare system")
detect_installs
break
;;
"Add instance")
new_instance
break
;;
"Delete instance")
remove_instance_menu
break
;;
"Add Camera")
add_camera
break
;;
"Delete Camera")
remove_camera_menu
break
;;
"Utilities")
utility_menu
break
;;
"Backup Menu")
backup_menu
break
;;
"Update")
octo_deploy_update
break
;;
"Quit")
exit 1
;;
*) echo "invalid option $REPLY";;
esac
done
}
remove_instance_menu() {
echo
echo
get_settings
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
if [ -f "/etc/octoprint_instances" ]; then
PS3="${green}Select instance number to remove: ${white}"
get_instances true
select opt in "${INSTANCE_ARR[@]}"
do
if [ "$opt" == Quit ]; then
main_menu
fi
echo "Selected instance to remove: $opt"
break
done
if prompt_confirm "Do you want to remove everything associated with this instance?"; then
remove_instance $opt
fi
fi
main_menu
}
remove_camera_menu() {
get_settings
PS3="${green}Select camera number to remove: ${white}"
readarray -t cameras < <(cat /etc/octoprint_cameras | sed -n -e 's/^camera:\([[:graph:]]*\) .*/\1/p')
cameras+=("Quit")
select camera in "${cameras[@]}"
do
if [ "$camera" == Quit ]; then
main_menu
fi
echo "Removing udev, service files, and haproxy entry for $camera"
remove_camera $camera
main_menu
done
}
utility_menu() {
echo
echo
PS3="${green}Select an option: ${white}"
options=("Instance Status" "USB Port Testing" "Sync Users" "Share Uploads" "Change Streamer" "Set Global Config" "Udev Menu" "Diagnostic Output" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Instance Status")
instance_status
break
;;
"USB Port Testing")
usb_testing
break
;;
"Sync Users")
sync_users
break
;;
"Share Uploads")
share_uploads
break
;;
"Set Global Config")
global_config
break
;;
"Udev Menu")
udev_menu
break
;;
"Change Streamer")
change_streamer
break
;;
"Diagnostic Output")
diagnostics
break
;;
"Quit")
main_menu
break
;;*) echo "invalid option $REPLY";;
esac
done
}
udev_menu() {
echo
echo
PS3="${green}Select an option: ${white}"
options=("Add printer udev rule" "Remove printer udev rule" "Add camera udev rule" "Remove camera udev rule" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Add printer udev rule")
add_udev
break
;;
"Remove printer udev rule")
remove_udev
break
;;
"Add camera udev rule")
add_udev_camera
break
;;
"Remove camera udev rule")
remove_udev_camera
break
;;
"Quit")
main_menu
break
;;*) echo "invalid option $REPLY";;
esac
done
}
backup_menu() {
echo
echo
PS3="${green}Select an option: ${white}"
options=("Create Backup" "Restore Backup" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Create Backup")
create_menu
break
;;
"Restore Backup")
restore_menu
break
break
;;
"Quit")
main_menu
break
;;*) echo "invalid option $REPLY";;
esac
done
}
create_menu() {
echo
echo
PS3="${green}Select instance number to backup: ${white}"
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
options+=("Quit")
select opt in "${options[@]}"
do
if [ "$opt" == Quit ]; then
main_menu
fi
echo "Selected instance to backup: $opt"
back_up $opt
main_menu
done
}
restore_menu() {
echo
echo
PS3="${green}Select backup to restore: ${white}"
readarray -t options < <(ls /home/$user/*.tar.gz)
options+=("Quit")
select opt in "${options[@]}"
do
if [ "$opt" == Quit ] || [ "$opt" == generic ]; then
main_menu
fi
echo "Selected $opt to restore"
tar --same-owner -pxvf $opt
main_menu
done
}