This commit is contained in:
2024-08-04 19:19:54 -05:00
parent fa148e0b3c
commit 78be1dff59
3 changed files with 16 additions and 16 deletions

View File

@@ -7,7 +7,7 @@ new_instance() {
USB='' USB=''
#It is possible to not create an instance after preparing,so check if this is the first #It is possible to not create an instance after preparing,so check if this is the first
if [ -f /etc/octoprint_instances ]; then if [ -f /etc/octodocker_instances ]; then
firstrun=false firstrun=false
else else
firstrun=true firstrun=true
@@ -85,7 +85,7 @@ new_instance() {
if prompt_confirm "Ready to begin instance creation?"; then if prompt_confirm "Ready to begin instance creation?"; then
PORT=5000 PORT=5000
PORTS_INUSE=$(join_by , $(cat /etc/octoprint_instances 2>/dev/null | sed -n -e 's/^.*\(port:\)\(.*\) udev:.*/\2/p')) PORTS_INUSE=$(join_by , $(cat /etc/octodocker_instances 2>/dev/null | sed -n -e 's/^.*\(port:\)\(.*\) udev:.*/\2/p'))
until [[ "${PORTS_INUSE}" != *"${PORT}"* ]]; do ((PORT++)); done until [[ "${PORTS_INUSE}" != *"${PORT}"* ]]; do ((PORT++)); done
echo Selected port is: $PORT echo Selected port is: $PORT
@@ -153,9 +153,9 @@ new_instance() {
#Append instance name to list for removal tool #Append instance name to list for removal tool
if [ -z "$UDEV" ] && [ -z "$USB" ]; then if [ -z "$UDEV" ] && [ -z "$USB" ]; then
echo "instance:$INSTANCE port:$PORT udev:false" >> /etc/octoprint_instances echo "instance:$INSTANCE port:$PORT udev:false" >> /etc/octodocker_instances
else else
echo "instance:$INSTANCE port:$PORT udev:true" >> /etc/octoprint_instances echo "instance:$INSTANCE port:$PORT udev:true" >> /etc/octodocker_instances
fi fi
if [ -n "$TEMPLATE" ]; then if [ -n "$TEMPLATE" ]; then
@@ -341,7 +341,7 @@ remove_instance() {
#remove files #remove files
rm -rf /opt/octoprint/s$opt rm -rf /opt/octoprint/s$opt
#remove from octoprint_instances #remove from octoprint_instances
sed -i "/$opt/d" /etc/octoprint_instances sed -i "/$opt/d" /etc/octodocker_instances
#remove haproxy entry #remove haproxy entry
if [ "$HAPROXY" == true ]; then if [ "$HAPROXY" == true ]; then
sed -i "/use_backend $opt/d" /etc/haproxy/haproxy.cfg sed -i "/use_backend $opt/d" /etc/haproxy/haproxy.cfg

View File

@@ -9,7 +9,7 @@ yellow=$(echo -en "\e[93m")
main_menu() { main_menu() {
VERSION=0.2 VERSION=0.3
#reset #reset
UDEV='' UDEV=''
TEMPUSB='' TEMPUSB=''
@@ -83,7 +83,7 @@ remove_instance_menu() {
echo echo
get_settings get_settings
if [ $SUDO_USER ]; then user=$SUDO_USER; fi if [ $SUDO_USER ]; then user=$SUDO_USER; fi
if [ -f "/etc/octoprint_instances" ]; then if [ -f "/etc/octodocker_instances" ]; then
PS3="${green}Select instance number to remove: ${white}" PS3="${green}Select instance number to remove: ${white}"
get_instances true get_instances true

18
util.sh
View File

@@ -88,8 +88,8 @@ back_up_all() {
get_instances() { get_instances() {
addquit=$1 addquit=$1
if [ -f /etc/octoprint_instances ]; then if [ -f /etc/octodocker_instances ]; then
readarray -t INSTANCE_ARR < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t INSTANCE_ARR < <(cat /etc/octodocker_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
if [ "$addquit" == true ]; then if [ "$addquit" == true ]; then
INSTANCE_ARR+=("Quit") INSTANCE_ARR+=("Quit")
fi fi
@@ -191,7 +191,7 @@ share_uploads() {
add_udev() { add_udev() {
#get instances that don't have a udev rule #get instances that don't have a udev rule
PS3="${green}Select instance to add udev rule: ${white}" PS3="${green}Select instance to add udev rule: ${white}"
readarray -t noudev < <(fgrep "udev:false" /etc/octoprint_instances 2> /dev/null | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t noudev < <(fgrep "udev:false" /etc/octodocker_instances 2> /dev/null | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
noudev+=("Quit") noudev+=("Quit")
select opt in "${noudev[@]}" select opt in "${noudev[@]}"
do do
@@ -203,7 +203,7 @@ add_udev() {
printer_udev false printer_udev false
printer_udev true printer_udev true
#this needs more thought #this needs more thought
sed -i "s/^\(instance:$INSTANCE port:.* udev:\)false/\1true/" /etc/octoprint_instances sed -i "s/^\(instance:$INSTANCE port:.* udev:\)false/\1true/" /etc/octodocker_instances
break break
done done
udevadm control --reload-rules udevadm control --reload-rules
@@ -214,7 +214,7 @@ add_udev() {
remove_udev() { remove_udev() {
PS3="${green}Select udev rule to remove: ${white}" PS3="${green}Select udev rule to remove: ${white}"
readarray -t udevs < <(fgrep "udev:true" /etc/octoprint_instances 2> /dev/null | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t udevs < <(fgrep "udev:true" /etc/octodocker_instances 2> /dev/null | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
udevs+=("Quit") udevs+=("Quit")
select opt in "${udevs[@]}" select opt in "${udevs[@]}"
do do
@@ -222,7 +222,7 @@ remove_udev() {
main_menu main_menu
fi fi
sed -i "/$opt/d" /etc/udev/rules.d/99-octoprint.rules sed -i "/$opt/d" /etc/udev/rules.d/99-octoprint.rules
sed -i "s/^\(instance:$opt port:.* udev:\)true/\1false/" /etc/octoprint_instances sed -i "s/^\(instance:$opt port:.* udev:\)true/\1false/" /etc/octodocker_instances
break break
done done
echo "${cyan}udev rule has been removed${white}" echo "${cyan}udev rule has been removed${white}"
@@ -243,7 +243,7 @@ add_udev_camera() {
INSTANCE=$opt INSTANCE=$opt
detect_camera detect_camera
write_cam_udev write_cam_udev
sed -i "s/^\(camera:$opt port:.* udev:\)false/\1true/" /etc/octoprint_instances sed -i "s/^\(camera:$opt port:.* udev:\)false/\1true/" /etc/octodocker_instances
break break
done done
udevadm control --reload-rules udevadm control --reload-rules
@@ -324,7 +324,7 @@ remove_everything() {
echo "Removing system stuff" echo "Removing system stuff"
rm /etc/octoprint_streamer 2>/dev/null rm /etc/octoprint_streamer 2>/dev/null
rm /etc/octodocker_deploy 2>/dev/null rm /etc/octodocker_deploy 2>/dev/null
rm /etc/octoprint_instances 2>/dev/null rm /etc/octodocker_instances 2>/dev/null
rm /etc/octoprint_cameras 2>/dev/null rm /etc/octoprint_cameras 2>/dev/null
rm /etc/udev/rules.d/99-octoprint.rules 2>/dev/null rm /etc/udev/rules.d/99-octoprint.rules 2>/dev/null
rm -rf /opt/octoprint/ustreamer 2>/dev/null rm -rf /opt/octoprint/ustreamer 2>/dev/null
@@ -377,7 +377,7 @@ diagnostics() {
logfile='octodocker_deploy_diagnostic.log' logfile='octodocker_deploy_diagnostic.log'
echo "octodocker_deploy diagnostic information. Please provide ALL output for support help" echo "octodocker_deploy diagnostic information. Please provide ALL output for support help"
diagnostic_output /etc/octodocker_deploy | log diagnostic_output /etc/octodocker_deploy | log
diagnostic_output /etc/octoprint_instances | log diagnostic_output /etc/octodocker_instances | log
diagnostic_output /etc/octoprint_cameras | log diagnostic_output /etc/octoprint_cameras | log
diagnostic_output /etc/udev/rules.d/99-octoprint.rules | log diagnostic_output /etc/udev/rules.d/99-octoprint.rules | log
ls -la /dev/octo* | log ls -la /dev/octo* | log