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)
|
||||||
|
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ detect_printer() {
|
|||||||
dmesg -C
|
dmesg -C
|
||||||
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\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p')
|
||||||
UDEV=$(dmesg | sed -n -e 's/^.*SerialNumber: //p')
|
UDEV=$(dmesg | sed -n -e 's/^.*SerialNumber: //p')
|
||||||
counter=$(( $counter + 1 ))
|
counter=$(( $counter + 1 ))
|
||||||
@@ -675,7 +675,7 @@ prepare () {
|
|||||||
echo 'Disabling unneeded services....'
|
echo 'Disabling unneeded services....'
|
||||||
systemctl disable octoprint.service
|
systemctl disable octoprint.service
|
||||||
systemctl disable webcamd.service
|
systemctl disable webcamd.service
|
||||||
systemctl stop webcamd.service
|
systemctl stop webcamd.service
|
||||||
systemctl disable streamer_select.service
|
systemctl disable streamer_select.service
|
||||||
systemctl stop streamer_select.service
|
systemctl stop streamer_select.service
|
||||||
echo 'Installing needed packages'
|
echo 'Installing needed packages'
|
||||||
@@ -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
|
||||||
;;
|
;;
|
||||||
@@ -1157,7 +1205,7 @@ source $SCRIPTDIR/plugins.sh
|
|||||||
# gather info and write /etc/octoprint_deploy if missing
|
# gather info and write /etc/octoprint_deploy if missing
|
||||||
if [ ! -f /etc/octoprint_deploy ] && [ -f /etc/octoprint_instances ]; then
|
if [ ! -f /etc/octoprint_deploy ] && [ -f /etc/octoprint_instances ]; then
|
||||||
echo "/etc/octoprint_deploy is missing. You may have prepared the system with an older vesion."
|
echo "/etc/octoprint_deploy is missing. You may have prepared the system with an older vesion."
|
||||||
echo "The file will be created now."
|
echo "The file will be created now."
|
||||||
streamer_type=("mjpg-streamer" "ustreamer")
|
streamer_type=("mjpg-streamer" "ustreamer")
|
||||||
haproxy_bool=("true" "false")
|
haproxy_bool=("true" "false")
|
||||||
if [ -f /etc/octopi_version ]; then
|
if [ -f /etc/octopi_version ]; then
|
||||||
@@ -1176,8 +1224,8 @@ if [ ! -f /etc/octoprint_deploy ] && [ -f /etc/octoprint_instances ]; then
|
|||||||
echo "haproxy: $prox" >> /etc/octoprint_deploy
|
echo "haproxy: $prox" >> /etc/octoprint_deploy
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#command line arguments
|
#command line arguments
|
||||||
if [ "$1" == remove ]; then
|
if [ "$1" == remove ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user