sync user function
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
Updated October 21, 2022.
|
Updated October 23, 2022.
|
||||||
Want to support this work? Buy Me a Coffee. https://www.buymeacoffee.com/ppaukstelis.
|
Want to support this work? Buy Me a Coffee. https://www.buymeacoffee.com/ppaukstelis.
|
||||||
Need help with octoprint_deploy? Ask on Discord: https://discord.gg/6vgSjgvR6u
|
Need help with octoprint_deploy? Ask on Discord: https://discord.gg/6vgSjgvR6u
|
||||||
# octoprint_deploy
|
# octoprint_deploy
|
||||||
@@ -58,15 +58,14 @@ 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
|
||||||
|
* Added `Sync Users` option. It will copy users.yaml file from selected instances to all other instances (including template)
|
||||||
|
* Starting with 0.1.4, added `Update` in the menu which will update octoprint_deploy via git (then exit)
|
||||||
* Rename printers_udev.sh to udev_rules.sh. Allows writing udev rules for both printers and cameras without full deployment.
|
* Rename printers_udev.sh to udev_rules.sh. Allows writing udev rules for both printers and cameras without full deployment.
|
||||||
* 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)
|
* Write /etc/octoprint_deploy if missing (older version system preparation)
|
||||||
* Add option for plugin installation during system preparation.
|
* Add option for plugin installation during system preparation.
|
||||||
* Enable ssh.
|
|
||||||
* Added webcam restart to system commands during camera addition.
|
|
||||||
* Admin user and first run wizards during Prepare System.
|
|
||||||
# TODO
|
# TODO
|
||||||
* Multiple cameras for an instance (see multi-camera branch)
|
* Multiple cameras for an instance (see multi-camera branch)
|
||||||
|
|
||||||
|
|||||||
@@ -1014,6 +1014,41 @@ restart_all() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sync_users() {
|
||||||
|
PS3='Select instance that contains current user list: '
|
||||||
|
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
|
||||||
|
|
||||||
|
if prompt_confirm "Copy users from instance $opt to all other instances?"; then
|
||||||
|
if [ "$opt" == generic ]; then
|
||||||
|
userfile=/home/$user/.octoprint/users.yaml
|
||||||
|
else
|
||||||
|
userfile=/home/$user/.$opt/users.yaml
|
||||||
|
fi
|
||||||
|
#re-read to avoid the Quit
|
||||||
|
readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
|
||||||
|
for instance in "${instances[@]}"; do
|
||||||
|
if [ "$instance" == generic ]; then
|
||||||
|
sudo -u $user cp $userfile /home/$user/.octoprint/
|
||||||
|
else
|
||||||
|
sudo -u $user cp $userfile /home/$user/.$instance/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if prompt_confirm "Restart all instances now for changes to take effect?"; then
|
||||||
|
restart_all
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
main_menu
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
back_up() {
|
back_up() {
|
||||||
INSTANCE=$1
|
INSTANCE=$1
|
||||||
echo "Creating backup of $INSTANCE...."
|
echo "Creating backup of $INSTANCE...."
|
||||||
@@ -1091,8 +1126,13 @@ replace_id() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
octo_deploy_update() {
|
||||||
|
sudo -u $user git -C octoprint_deploy pull
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
main_menu() {
|
main_menu() {
|
||||||
VERSION=0.1.3
|
VERSION=0.1.5
|
||||||
#reset
|
#reset
|
||||||
UDEV=''
|
UDEV=''
|
||||||
TEMPUSB=''
|
TEMPUSB=''
|
||||||
@@ -1108,9 +1148,9 @@ 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" "USB port testing" "Create Backup" "Restore Backup" "Quit")
|
options=("New instance" "Delete instance" "Add Camera" "USB port testing" "Sync Users" "Create Backup" "Restore Backup" "Update" "Quit")
|
||||||
else
|
else
|
||||||
options=("Prepare system" "USB port testing" "Quit")
|
options=("Prepare system" "USB port testing" "Update" "Quit")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
select opt in "${options[@]}"
|
select opt in "${options[@]}"
|
||||||
@@ -1135,6 +1175,10 @@ main_menu() {
|
|||||||
usb_testing
|
usb_testing
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
"Sync Users")
|
||||||
|
sync_users
|
||||||
|
break
|
||||||
|
;;
|
||||||
"Create Backup")
|
"Create Backup")
|
||||||
create_menu
|
create_menu
|
||||||
break
|
break
|
||||||
@@ -1143,6 +1187,10 @@ main_menu() {
|
|||||||
restore_menu
|
restore_menu
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
"Update")
|
||||||
|
octo_deploy_update
|
||||||
|
break
|
||||||
|
;;
|
||||||
"Quit")
|
"Quit")
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user