enforce python3, main menu
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
octoprint_deploy.log
|
|
||||||
@@ -259,6 +259,7 @@ new_instance () {
|
|||||||
sudo systemctl restart haproxy.service
|
sudo systemctl restart haproxy.service
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
main_menu
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +278,7 @@ write_camera() {
|
|||||||
echo " stream: http://$(hostname).local:$CAMPORT?action=stream" >> $OCTOCONFIG/.$INSTANCE/config.yaml
|
echo " stream: http://$(hostname).local:$CAMPORT?action=stream" >> $OCTOCONFIG/.$INSTANCE/config.yaml
|
||||||
echo
|
echo
|
||||||
|
|
||||||
#Octobuntu Cameras udev identifier - either Serial number or USB port
|
#Either Serial number or USB port
|
||||||
#Serial Number
|
#Serial Number
|
||||||
if [ -n "$CAM" ]; then
|
if [ -n "$CAM" ]; then
|
||||||
echo SUBSYSTEM==\"video4linux\", ATTRS{serial}==\"$CAM\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules
|
echo SUBSYSTEM==\"video4linux\", ATTRS{serial}==\"$CAM\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules
|
||||||
@@ -297,10 +298,10 @@ add_camera() {
|
|||||||
PS3='Select instance to add camera to: '
|
PS3='Select instance to add camera to: '
|
||||||
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
||||||
#Not yet check to see if instance already has a camera
|
#Not yet check to see if instance already has a camera
|
||||||
select opt in "${options[@]}"
|
select camopt in "${options[@]}"
|
||||||
do
|
do
|
||||||
echo "Selected instance for camera: $opt" | log
|
echo "Selected instance for camera: $camopt" | log
|
||||||
INSTANCE=$opt
|
INSTANCE=$camopt
|
||||||
OCTOCONFIG="/home/$user/"
|
OCTOCONFIG="/home/$user/"
|
||||||
OCTOUSER=$user
|
OCTOUSER=$user
|
||||||
break
|
break
|
||||||
@@ -355,16 +356,17 @@ add_camera() {
|
|||||||
|
|
||||||
|
|
||||||
#Need to check if this is a one-off install
|
#Need to check if this is a one-off install
|
||||||
if [ -n "$opt" ]; then
|
if [ -n "$camopt" ]; then
|
||||||
write_camera
|
write_camera
|
||||||
systemctl start cam_$INSTANCE.service
|
systemctl start cam_$INSTANCE.service
|
||||||
systemctl enable cam_$INSTANCE.service
|
systemctl enable cam_$INSTANCE.service
|
||||||
|
main_menu
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_instance() {
|
remove_instance() {
|
||||||
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
|
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
|
||||||
#Check to see that octoprint_instances exists before continuing
|
#TODO Check to see that octoprint_instances exists before continuing
|
||||||
echo 'Do not remove the generic instance!' | log
|
echo 'Do not remove the generic instance!' | log
|
||||||
PS3='Select instance to remove: '
|
PS3='Select instance to remove: '
|
||||||
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
||||||
@@ -396,6 +398,7 @@ remove_instance() {
|
|||||||
#remove from octoprint_instances
|
#remove from octoprint_instances
|
||||||
sed -i "/$opt/d" /etc/octoprint_instances
|
sed -i "/$opt/d" /etc/octoprint_instances
|
||||||
fi
|
fi
|
||||||
|
main_menu
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_testing() {
|
usb_testing() {
|
||||||
@@ -415,6 +418,7 @@ usb_testing() {
|
|||||||
echo "Serial Number detected: $UDEV" | log
|
echo "Serial Number detected: $UDEV" | log
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
main_menu
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare () {
|
prepare () {
|
||||||
@@ -422,7 +426,6 @@ prepare () {
|
|||||||
echo 'Beginning system preparation' | log
|
echo 'Beginning system preparation' | log
|
||||||
echo 'This only needs to be run once to prepare your system to use octoprint_deploy.'
|
echo 'This only needs to be run once to prepare your system to use octoprint_deploy.'
|
||||||
echo 'Run this setup and then connect to OctoPrint through your browser to setup your admin user.'
|
echo 'Run this setup and then connect to OctoPrint through your browser to setup your admin user.'
|
||||||
echo 'System type:'
|
|
||||||
PS3='Installation type: '
|
PS3='Installation type: '
|
||||||
options=("OctoPi" "Ubuntu" "Quit")
|
options=("OctoPi" "Ubuntu" "Quit")
|
||||||
select opt in "${options[@]}"
|
select opt in "${options[@]}"
|
||||||
@@ -457,12 +460,14 @@ prepare () {
|
|||||||
echo 'Connect to your octoprint instance and setup admin user'
|
echo 'Connect to your octoprint instance and setup admin user'
|
||||||
fi
|
fi
|
||||||
if [ $INSTALL -eq 2 ]; then
|
if [ $INSTALL -eq 2 ]; then
|
||||||
|
echo "Creating OctoBuntu installation equivalent."
|
||||||
|
echo "This will install necessary packages, download and install OctoPrint and setup a base instance on this machine."
|
||||||
#install packages
|
#install packages
|
||||||
apt update
|
apt update
|
||||||
apt -y install python3-pip python3-venv virtualenv
|
apt -y install python3-pip python3-venv virtualenv
|
||||||
echo "Installing OctoPrint in /home/$user/OctoPrint"
|
echo "Installing OctoPrint in /home/$user/OctoPrint"
|
||||||
#make venv
|
#make venv
|
||||||
sudo -u $user python -m venv /home/$user/OctoPrint
|
sudo -u $user python3 -m venv /home/$user/OctoPrint
|
||||||
#install oprint
|
#install oprint
|
||||||
sudo -u $user /home/$user/OctoPrint/bin/pip install OctoPrint
|
sudo -u $user /home/$user/OctoPrint/bin/pip install OctoPrint
|
||||||
#start server and run in background
|
#start server and run in background
|
||||||
@@ -479,21 +484,18 @@ prepare () {
|
|||||||
sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml
|
sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
main_menu
|
||||||
}
|
}
|
||||||
|
main_menu() {
|
||||||
# initiate logging
|
PS3='Select operation: '
|
||||||
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
|
if [ -f "/etc/octoprint_instances" ]; then
|
||||||
logfile='octoprint_deploy.log'
|
|
||||||
SCRIPTDIR=$(dirname $(readlink -f $0))
|
|
||||||
PS3='Select operation: '
|
|
||||||
if [ -f "/etc/octoprint_instances" ]; then
|
|
||||||
options=("New instance" "Delete instance" "Add Camera" "USB port testing" "Quit")
|
options=("New instance" "Delete instance" "Add Camera" "USB port testing" "Quit")
|
||||||
else
|
else
|
||||||
options=("Prepare system" "New instance" "Delete instance" "Add Camera" "USB port testing" "Quit")
|
options=("Prepare system" "New instance" "Delete instance" "Add Camera" "USB port testing" "Quit")
|
||||||
fi
|
fi
|
||||||
#options=("Prepare system (OctoPi)" "New instance" "Delete instance" "Add Camera" "USB port testing" "Quit")
|
|
||||||
select opt in "${options[@]}"
|
select opt in "${options[@]}"
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
"Prepare system")
|
"Prepare system")
|
||||||
prepare
|
prepare
|
||||||
@@ -519,4 +521,10 @@ do
|
|||||||
;;
|
;;
|
||||||
*) echo "invalid option $REPLY";;
|
*) echo "invalid option $REPLY";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
# initiate logging
|
||||||
|
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
|
||||||
|
logfile='octoprint_deploy.log'
|
||||||
|
SCRIPTDIR=$(dirname $(readlink -f $0))
|
||||||
|
main_menu
|
||||||
Reference in New Issue
Block a user