initial code changes
This commit is contained in:
73
util.sh
Normal file → Executable file
73
util.sh
Normal file → Executable file
@@ -26,12 +26,12 @@ has-space () {
|
||||
}
|
||||
|
||||
get_settings() {
|
||||
#Get octoprint_deploy settings, all of which are written on system prepare
|
||||
if [ -f /etc/octoprint_deploy ]; then
|
||||
OCTOEXEC=$(cat /etc/octoprint_deploy | sed -n -e 's/^octoexec: \(\.*\)/\1/p')
|
||||
OCTOPIP=$(cat /etc/octoprint_deploy | sed -n -e 's/^octopip: \(\.*\)/\1/p')
|
||||
STREAMER=$(cat /etc/octoprint_deploy | sed -n -e 's/^streamer: \(\.*\)/\1/p')
|
||||
HAPROXY=$(cat /etc/octoprint_deploy | sed -n -e 's/^haproxy: \(\.*\)/\1/p')
|
||||
#Get octodocker_deploy settings, all of which are written on system prepare
|
||||
if [ -f /etc/octodocker_deploy ]; then
|
||||
OCTOEXEC=/usr/local/bin/octoprint
|
||||
OCTOPIP=/usr/local/bin/pip
|
||||
STREAMER=$(cat /etc/octodocker_deploy | sed -n -e 's/^streamer: \(\.*\)/\1/p')
|
||||
HAPROXY=$(cat /etc/octodocker_deploy | sed -n -e 's/^haproxy: \(\.*\)/\1/p')
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -53,26 +53,26 @@ global_config() {
|
||||
}
|
||||
|
||||
octo_deploy_update() {
|
||||
sudo -u $user git -C $SCRIPTDIR pull
|
||||
git -C $SCRIPTDIR pull
|
||||
exit
|
||||
}
|
||||
|
||||
back_up() {
|
||||
INSTANCE=$1
|
||||
echo "Creating backup of $INSTANCE...."
|
||||
sudo -u $user $OCTOEXEC --basedir /home/$user/.$INSTANCE plugins backup:backup --exclude timelapse
|
||||
sudo -u $user mkdir /home/$user/instance_backup 2>/dev/null
|
||||
sudo -u $user mv /home/$user/.$INSTANCE/data/backup/*.zip /home/$user/instance_backup/
|
||||
echo "Zipped instance backup created in /home/$user/instance_backup"
|
||||
docker exec -it $INSTANCE $OCTOEXEC --basedir /opt/octoprint/$INSTANCE plugins backup:backup --exclude timelapse
|
||||
mkdir /opt/octoprint/instance_backup 2>/dev/null
|
||||
mv /opt/octoprint/$INSTANCE/data/backup/*.zip /opt/octoprint/instance_backup/
|
||||
echo "Zipped instance backup created in /opt/octoprint/instance_backup"
|
||||
}
|
||||
|
||||
restore() {
|
||||
INSTANCE=$1
|
||||
TAR=$2
|
||||
echo "Restoring backup of $INSTANCE...."
|
||||
systemctl stop $INSTANCE
|
||||
sudo -u $user $OCTOEXEC --basedir /home/$user/.$INSTANCE plugins backup:restore $TAR
|
||||
systemctl start $INSTANCE
|
||||
docker stop $INSTANCE
|
||||
docker exec -it $INSTANCE $OCTOEXEC --basedir /opt/octoprint/$INSTANCE plugins backup:restore $TAR
|
||||
docker start $INSTANCE
|
||||
|
||||
}
|
||||
|
||||
@@ -119,14 +119,14 @@ sync_users() {
|
||||
fi
|
||||
|
||||
if prompt_confirm "Copy users from instance $opt to all other instances?"; then
|
||||
userfile=/home/$user/.$opt/users.yaml
|
||||
userfile=/opt/octoprint/$opt/users.yaml
|
||||
#re-read to avoid the Quit
|
||||
get_instances false
|
||||
for instance in "${INSTANCE_ARR[@]}"; do
|
||||
if [ "$instance" == "$opt" ]; then
|
||||
continue
|
||||
fi
|
||||
sudo -u $user cp $userfile /home/$user/.$instance/
|
||||
cp $userfile /opt/octoprint/$instance/
|
||||
done
|
||||
|
||||
if prompt_confirm "Restart all instances now for changes to take effect?"; then
|
||||
@@ -157,7 +157,7 @@ share_uploads() {
|
||||
fi
|
||||
|
||||
if [ "$opt" == "Custom" ]; then
|
||||
echo "Enter full path (should start /home/$user/):"
|
||||
echo "Enter full path (should start /opt/octoprint/):"
|
||||
read ULPATH
|
||||
if [ -d "$ULPATH" ]; then
|
||||
if prompt_confirm "This folder already exists. Are you sure you want to use it?"; then
|
||||
@@ -168,19 +168,19 @@ share_uploads() {
|
||||
break
|
||||
fi
|
||||
else
|
||||
sudo -u $user mkdir $ULPATH
|
||||
mkdir $ULPATH
|
||||
opt=$ULPATH
|
||||
fi
|
||||
|
||||
else
|
||||
opt=/home/$user/.$opt/uploads
|
||||
opt=/opt/octoprint/$opt/uploads
|
||||
fi
|
||||
echo
|
||||
#Remove Quit and Custom from array, is there a cleaner way?
|
||||
unset 'INSTANCE_ARR[-1]'
|
||||
unset 'INSTANCE_ARR[-1]'
|
||||
for instance in "${INSTANCE_ARR[@]}"; do
|
||||
sudo -u $user $OCTOEXEC --basedir /home/$user/.$instance config set folder.uploads "$opt"
|
||||
docker exec -it $INSTANCE $OCTOEXEC --basedir /opt/octoprint/$INSTANCEinstance config set folder.uploads "$opt"
|
||||
done
|
||||
break
|
||||
done
|
||||
@@ -293,7 +293,7 @@ instance_status() {
|
||||
echo "$instance - $status"
|
||||
done
|
||||
echo "${cyan}*******************************************${white}"
|
||||
echo "Only instances and cameras made with octoprint_deploy are shown"
|
||||
echo "Only instances and cameras made with octodocker_deploy are shown"
|
||||
echo
|
||||
main_menu
|
||||
}
|
||||
@@ -322,21 +322,14 @@ remove_everything() {
|
||||
done
|
||||
|
||||
echo "Removing system stuff"
|
||||
rm /etc/systemd/system/octoprint.service 2>/dev/null
|
||||
rm /etc/octoprint_streamer 2>/dev/null
|
||||
rm /etc/octoprint_deploy 2>/dev/null
|
||||
rm /etc/octodocker_deploy 2>/dev/null
|
||||
rm /etc/octoprint_instances 2>/dev/null
|
||||
rm /etc/octoprint_cameras 2>/dev/null
|
||||
rm /etc/udev/rules.d/99-octoprint.rules 2>/dev/null
|
||||
rm /etc/sudoers.d/octoprint_reboot 2>/dev/null
|
||||
rm /etc/sudoers.d/octoprint_systemctl 2>/dev/null
|
||||
rm -rf /home/$user/.octoprint 2>/dev/null
|
||||
rm -rf /home/$user/OctoPrint 2>/dev/null
|
||||
rm -rf /home/$user/ustreamer 2>/dev/null
|
||||
rm -rf /home/$user/mjpg-streamer 2>/dev/null
|
||||
rm -rf /home/$user/camera-streamer 2>/dev/null
|
||||
systemctl restart haproxy.service
|
||||
systemctl daemon-reload
|
||||
rm -rf /opt/octoprint/ustreamer 2>/dev/null
|
||||
rm -rf /opt/octoprint/mjpg-streamer 2>/dev/null
|
||||
rm -rf /opt/octoprint/camera-streamer 2>/dev/null
|
||||
|
||||
fi
|
||||
}
|
||||
@@ -346,7 +339,7 @@ restart_all() {
|
||||
get_instances false
|
||||
for instance in "${INSTANCE_ARR[@]}"; do
|
||||
echo "Trying to restart instance $instance"
|
||||
systemctl restart $instance
|
||||
docker restart $instance
|
||||
done
|
||||
main_menu
|
||||
}
|
||||
@@ -381,9 +374,9 @@ diagnostic_output() {
|
||||
|
||||
diagnostics() {
|
||||
get_settings
|
||||
logfile='octoprint_deploy_diagnostic.log'
|
||||
echo "octoprint_deploy diagnostic information. Please provide ALL output for support help"
|
||||
diagnostic_output /etc/octoprint_deploy | log
|
||||
logfile='octodocker_deploy_diagnostic.log'
|
||||
echo "octodocker_deploy diagnostic information. Please provide ALL output for support help"
|
||||
diagnostic_output /etc/octodocker_deploy | log
|
||||
diagnostic_output /etc/octoprint_instances | log
|
||||
diagnostic_output /etc/octoprint_cameras | log
|
||||
diagnostic_output /etc/udev/rules.d/99-octoprint.rules | log
|
||||
@@ -395,9 +388,9 @@ diagnostics() {
|
||||
echo "**************************************" | log
|
||||
systemctl status $instance -l --no-pager | log
|
||||
#get needed config info
|
||||
sudo -u $user $OCTOEXEC --basedir=/home/$user/.$INSTANCE config get plugins.classicwebcam | log
|
||||
#sudo -u $user $OCTOEXEC --basedir=/home/$user/.$INSTANCE config get plugins.classicwebcam.snapshot | log
|
||||
sudo -u $user $OCTOEXEC --basedir=/home/$user/.$INSTANCE config get webcam | log
|
||||
docker exec -it $INSTANCE $OCTOEXEC --basedir=/opt/octoprint/$INSTANCE config get plugins.classicwebcam | log
|
||||
#docker exec -it $INSTANCE $OCTOEXEC --basedir=/opt/octoprint/$INSTANCE config get plugins.classicwebcam.snapshot | log
|
||||
docker exec -it $INSTANCE $OCTOEXEC --basedir=/opt/octoprint/$INSTANCE config get webcam | log
|
||||
done
|
||||
#get all cam status
|
||||
get_cameras false
|
||||
@@ -408,6 +401,6 @@ diagnostics() {
|
||||
#get haproxy status
|
||||
echo "**************************************" | log
|
||||
systemctl status haproxy -l --no-pager | log
|
||||
logfile='octoprint_deploy.log'
|
||||
logfile='octodocker_deploy.log'
|
||||
main_menu
|
||||
}
|
||||
Reference in New Issue
Block a user