first 0.1.9

This commit is contained in:
paukstelis
2022-11-06 08:24:50 -05:00
parent 46cb0fbb33
commit a37b4fd195
2 changed files with 117 additions and 25 deletions

View File

@@ -58,6 +58,8 @@ These files provide a bash script for quickly deploying multiple octoprint insta
* Change udev rules for an instance with `sudo octoprint_deploy/octoprint_deploy.sh replace` * Change udev rules for an instance with `sudo octoprint_deploy/octoprint_deploy.sh replace`
* Always a good idea to update octoprint_deploy from time-to-time with `git -C octoprint_deploy pull` * Always a good idea to update octoprint_deploy from time-to-time with `git -C octoprint_deploy pull`
# Recent Changes # Recent Changes
* Add detection for ch34x driver. This is used by Weedo printers and must be compiled.
* Utility sub-menu
* Filter out `generic` instance from lists where it does not need to be. * Filter out `generic` instance from lists where it does not need to be.
* Added `Instance Status` option which will report the status of each instance (as seen been systemctl status). * Added `Instance Status` option which will report the status of each instance (as seen been systemctl status).
* Added `Sync Users` option. It will copy users.yaml file from selected instances to all other instances (including template) * Added `Sync Users` option. It will copy users.yaml file from selected instances to all other instances (including template)
@@ -66,8 +68,6 @@ These files provide a bash script for quickly deploying multiple octoprint insta
* 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by the USB port but it does not have a serial number. * 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by the USB port but it does not have a serial number.
* Fail if sudouser is root. * Fail if sudouser is root.
* Add MIT license * Add MIT license
* Write /etc/octoprint_deploy if missing (older version system preparation)
* Add option for plugin installation during system preparation.
# TODO # TODO
* Multiple cameras for an instance (see multi-camera branch) * Multiple cameras for an instance (see multi-camera branch)

View File

@@ -469,7 +469,7 @@ detect_printer() {
echo "Plug your printer in via USB now (detection time-out in 1 min)" echo "Plug your printer in via USB now (detection time-out in 1 min)"
counter=0 counter=0
while [[ -z "$UDEV" ]] && [[ $counter -lt 60 ]]; do while [[ -z "$UDEV" ]] && [[ $counter -lt 60 ]]; do
TEMPUSB=$(dmesg | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') TEMPUSB=$(dmesg | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\|ch34x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\|ch34x\).*/\2/p')
UDEV=$(dmesg | sed -n -e 's/^.*SerialNumber: //p') UDEV=$(dmesg | sed -n -e 's/^.*SerialNumber: //p')
counter=$(( $counter + 1 )) counter=$(( $counter + 1 ))
if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then
@@ -587,7 +587,7 @@ prepare () {
MOVE=0 MOVE=0
echo 'Beginning system preparation' | log echo 'Beginning system preparation' | log
PS3='Installation type: ' PS3='Installation type: '
options=("OctoPi" "Ubuntu 18-22, Mint, Debian, Raspberry Pi OS" "Fedora/CentOS" "ArchLinux" "Quit") options=("OctoPi" "Ubuntu 20+, Mint, Debian, Raspberry Pi OS" "Fedora/CentOS" "ArchLinux" "Quit")
select opt in "${options[@]}" select opt in "${options[@]}"
do do
case $opt in case $opt in
@@ -595,7 +595,7 @@ prepare () {
INSTALL=1 INSTALL=1
break break
;; ;;
"Ubuntu 18-22, Mint, Debian, Raspberry Pi OS") "Ubuntu 20+, Mint, Debian, Raspberry Pi OS")
INSTALL=2 INSTALL=2
break break
;; ;;
@@ -984,6 +984,60 @@ remove_everything() {
fi fi
fi fi
} }
utility_menu() {
PS3='Select an option: '
options+=("Instance Status" "USB Port Testing" "Sync Users" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Instance Status")
instance_status
break
;;
"USB Port Testing")
usb_testing
break
break
;;
"Sync Users")
sync_users
break
;;
"Share Uploads")
share_uploads
break
;;
"Quit")
main_menu
break
;;*) echo "invalid option $REPLY";;
esac
done
}
backup_menu() {
PS3='Select an option: '
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() { create_menu() {
PS3='Select instance number to backup: ' PS3='Select instance number to backup: '
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
@@ -1042,7 +1096,7 @@ sync_users() {
sudo -u $user cp $userfile /home/$user/.$instance/ sudo -u $user cp $userfile /home/$user/.$instance/
fi fi
done done
if prompt_confirm "Restart all instances now for changes to take effect?"; then if prompt_confirm "Restart all instances now for changes to take effect?"; then
restart_all restart_all
fi fi
@@ -1052,6 +1106,55 @@ sync_users() {
done done
} }
share_uploads() {
get_settings
echo "This option will make all your uploads go to a single instance."
echo "This will mean all gcode files be available for all your instances."
echo "Use this option only if you understand the implications."
echo "This can be adjusted later in the Folders settings of OctoPrint."
PS3='Select instance where uploads will be stored: '
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) port:.*/\1/p')
options+=("Custom" "Quit")
unset 'options[0]'
select opt in "${options[@]}"
do
if [ "$opt" == Quit ]; then
main_menu
break
fi
if [ "$opt" == "Custom" ]; then
echo "Enter full path (should start /home/$user/):"
read ULPATH
if [ -d "$ULPATH" ]; then
#echo "This folder already exists. Are you sure you want to use it?"
if prompt_confirm "This folder already exists. Are you sure you want to use it?"; then
opt = $ULPATH
else
echo "Restart the option if you change your mind"
main_menu
break
fi
else
sudo -u $user mkdir $ULPATH
opt = $ULPATH
fi
else
opt = /home/$user/.$opt/uploads
fi
echo $opt
echo
#Remove Quit and Custom from array, is there a cleaner way?
unset 'options[-1]'
unset 'options[-1]'
for instance in "${options[@]}"; do
$OCTOEXEC --basedir /home/$user/.$instance config set folder.upload "$opt"
done
done
echo "Instances must be restarted for changes to take effect."
}
back_up() { back_up() {
INSTANCE=$1 INSTANCE=$1
echo "Creating backup of $INSTANCE...." echo "Creating backup of $INSTANCE...."
@@ -1149,7 +1252,7 @@ instance_status() {
} }
main_menu() { main_menu() {
VERSION=0.1.7 VERSION=0.1.9
#reset #reset
UDEV='' UDEV=''
TEMPUSB='' TEMPUSB=''
@@ -1165,7 +1268,7 @@ main_menu() {
echo echo
PS3='Select operation: ' PS3='Select operation: '
if [ -f "/etc/octoprint_instances" ]; then if [ -f "/etc/octoprint_instances" ]; then
options=("New instance" "Delete instance" "Add Camera" "Instance Status" "USB port testing" "Sync Users" "Create Backup" "Restore Backup" "Update" "Quit") options=("New instance" "Delete instance" "Add Camera" "Utilities" "Backup Menu" "Update" "Quit")
else else
options=("Prepare system" "USB port testing" "Update" "Quit") options=("Prepare system" "USB port testing" "Update" "Quit")
fi fi
@@ -1179,7 +1282,8 @@ main_menu() {
;; ;;
"New instance") "New instance")
new_instance new_instance
break ;; break
;;
"Delete instance") "Delete instance")
remove_instance remove_instance
break break
@@ -1188,24 +1292,12 @@ main_menu() {
add_camera add_camera
break break
;; ;;
"Instance Status") "Utilities")
instance_status utility_menu
break break
;; ;;
"USB port testing") "Backup Menu")
usb_testing backup_menu
break
;;
"Sync Users")
sync_users
break
;;
"Create Backup")
create_menu
break
;;
"Restore Backup")
restore_menu
break break
;; ;;
"Update") "Update")