initial code changes

This commit is contained in:
2024-07-27 16:47:44 -05:00
parent 26b0a5fa19
commit d83353e61f
12 changed files with 196 additions and 194 deletions

View File

@@ -6,10 +6,10 @@ detect_installs() {
echo "OctoPi installation detected."
echo "Adding standard OctoPi instance to instance list."
echo "instance:octoprint port:5000 udev:false" >> /etc/octoprint_instances
echo "octoexec: /home/$user/oprint/bin/octoprint" >> /etc/octoprint_deploy
echo "octopip: /home/$user/oprint/bin/pip" >> /etc/octoprint_deploy
echo "haproxy: true" >> /etc/octoprint_deploy
echo "octopi: true" >> /etc/octoprint_deploy
echo "octoexec: /opt/octoprint/oprint/bin/octoprint" >> /etc/octodocker_deploy
echo "octopip: /opt/octoprint/oprint/bin/pip" >> /etc/octodocker_deploy
echo "haproxy: true" >> /etc/octodocker_deploy
echo "octopi: true" >> /etc/octodocker_deploy
echo "Adding systemctl and reboot to sudo"
echo "$user ALL=NOPASSWD: /usr/bin/systemctl" > /etc/sudoers.d/octoprint_systemctl
echo "$user ALL=NOPASSWD: /usr/sbin/reboot" > /etc/sudoers.d/octoprint_reboot
@@ -31,8 +31,8 @@ detect_installs() {
printer_udev true
udevadm control --reload-rules
udevadm trigger
sudo -u $user $OCTOEXEC config set serial.port /dev/octo_$INSTANCE
sudo -u $user $OCTOEXEC config append_value serial.additionalPorts "/dev/octo_$INSTANCE"
docker exec -it $INSTANCE $OCTOEXEC config set serial.port /dev/octo_$INSTANCE
docker exec -it $INSTANCE $OCTOEXEC config append_value serial.additionalPorts "/dev/octo_$INSTANCE"
#convert UDEV to true
sed -i "s/udev:false/udev:true/" /etc/octoprint_instances
systemctl restart $INSTANCE
@@ -40,12 +40,12 @@ detect_installs() {
fi
#streamer_install
echo "streamer: camera-streamer" >> /etc/octoprint_deploy
echo "streamer: camera-streamer" >> /etc/octodocker_deploy
main_menu
fi
echo "Searching home directory for existing OctoPrint venv/binary....."
octopresent=$(find /home/$user/ -type f -executable -print | grep "bin/octoprint")
octopresent=$(find /opt/octoprint/ -type f -executable -print | grep "bin/octoprint")
if [ -n "$octopresent" ]; then
echo "OctoPrint binary found at $octopresent"
echo "Did you try and setup OctoPrint in another way?"
@@ -255,7 +255,7 @@ prepare () {
}
old_install() {
echo "octoexec:$octopresent" >> /etc/octoprint_deploy
echo "octoexec:$octopresent" >> /etc/octodocker_deploy
user_groups
haproxy_install
streamer_install
@@ -264,7 +264,7 @@ old_install() {
new_install() {
user_groups
OCTOEXEC=/home/$user/OctoPrint/bin/octoprint
OCTOEXEC=/usr/local/bin/octoprint
echo "Adding systemctl and reboot to sudo"
echo "$user ALL=NOPASSWD: /usr/bin/systemctl" > /etc/sudoers.d/octoprint_systemctl
echo "$user ALL=NOPASSWD: /usr/sbin/reboot" > /etc/sudoers.d/octoprint_reboot
@@ -311,18 +311,18 @@ new_install() {
echo "Enabling ssh server..."
systemctl enable ssh.service
echo "Installing OctoPrint virtual environment in /home/$user/OctoPrint"
echo "Installing OctoPrint virtual environment in /opt/octoprint/OctoPrint"
#make venv
sudo -u $user $PYVERSION -m venv /home/$user/OctoPrint
$PYVERSION -m venv /opt/octoprint/OctoPrint
#update pip
sudo -u $user /home/$user/OctoPrint/bin/pip install --upgrade pip
/opt/octoprint/OctoPrint/bin/pip install --upgrade pip
#pre-install wheel
sudo -u $user /home/$user/OctoPrint/bin/pip install wheel
/opt/octoprint/OctoPrint/bin/pip install wheel
#install oprint
sudo -u $user /home/$user/OctoPrint/bin/pip install OctoPrint
/opt/octoprint/OctoPrint/bin/pip install OctoPrint
#Check to verify that OctoPrint binary is installed
if [ -f "/home/$user/OctoPrint/bin/octoprint" ]; then
if [ -f "/opt/octoprint/OctoPrint/bin/octoprint" ]; then
echo "${cyan}OctoPrint apppears to have been installed successfully${white}"
else
echo "${red}WARNING! WARNING! WARNING!${white}"
@@ -336,8 +336,8 @@ new_install() {
streamer_install
#These will retreived as settings
echo "octoexec: /home/$user/OctoPrint/bin/octoprint" >> /etc/octoprint_deploy
echo "octopip: /home/$user/OctoPrint/bin/pip" >> /etc/octoprint_deploy
echo "octoexec: /opt/octoprint/OctoPrint/bin/octoprint" >> /etc/octodocker_deploy
echo "octopip: /opt/octoprint/OctoPrint/bin/pip" >> /etc/octodocker_deploy
#Create first instance
echo
@@ -363,9 +363,9 @@ haproxy_install() {
echo
echo
if prompt_confirm "Use haproxy?"; then
echo 'haproxy: true' >> /etc/octoprint_deploy
echo 'haproxy: true' >> /etc/octodocker_deploy
#Check if using improved haproxy rules
#echo 'haproxynew: true' >> /etc/octoprint_deploy
#echo 'haproxynew: true' >> /etc/octodocker_deploy
systemctl stop haproxy
#get haproxy version
HAversion=$(haproxy -v | sed -n 's/^.*version \([0-9]\).*/\1/p')
@@ -415,19 +415,19 @@ streamer_install() {
#If we run this function directly, clean up streamer setting before installing
get_settings
sed -i "/streamer/d" /etc/octoprint_deploy
sed -i "/streamer/d" /etc/octodocker_deploy
if [ $VID -eq 1 ]; then
rm -rf /home/$user/mjpg_streamer 2>/dev/null
rm -rf /opt/octoprint/mjpg_streamer 2>/dev/null
#install mjpg-streamer, not doing any error checking or anything
echo 'Installing mjpeg-streamer'
sudo -u $user git -C /home/$user/ clone https://github.com/jacksonliam/mjpg-streamer.git mjpeg
git -C /opt/octoprint/ clone https://github.com/jacksonliam/mjpg-streamer.git mjpeg
#apt -y install
sudo -u $user make -C /home/$user/mjpeg/mjpg-streamer-experimental > /dev/null
make -C /opt/octoprint/mjpeg/mjpg-streamer-experimental > /dev/null
sudo -u $user mv /home/$user/mjpeg/mjpg-streamer-experimental /home/$user/mjpg-streamer
sudo -u $user rm -rf /home/$user/mjpeg
if [ -f "/home/$user/mjpg-streamer/mjpg_streamer" ]; then
mv /opt/octoprint/mjpeg/mjpg-streamer-experimental /opt/octoprint/mjpg-streamer
rm -rf /opt/octoprint/mjpeg
if [ -f "/opt/octoprint/mjpg-streamer/mjpg_streamer" ]; then
echo "Streamer installed successfully"
else
echo "${red}WARNING! WARNING! WARNING!${white}"
@@ -436,15 +436,15 @@ streamer_install() {
streamer_install
fi
fi
echo 'streamer: mjpg-streamer' >> /etc/octoprint_deploy
echo 'streamer: mjpg-streamer' >> /etc/octodocker_deploy
fi
if [ $VID -eq 2 ]; then
rm -rf /home/$user/ustreamer 2>/dev/null
rm -rf /opt/octoprint/ustreamer 2>/dev/null
#install ustreamer
sudo -u $user git -C /home/$user clone --depth=1 https://github.com/pikvm/ustreamer
sudo -u $user make -C /home/$user/ustreamer > /dev/null
if [ -f "/home/$user/ustreamer/ustreamer" ] || [ -f "/home/$user/ustreamer/ustreamer.bin" ]; then
git -C /opt/octoprint clone --depth=1 https://github.com/pikvm/ustreamer
make -C /opt/octoprint/ustreamer > /dev/null
if [ -f "/opt/octoprint/ustreamer/ustreamer" ] || [ -f "/opt/octoprint/ustreamer/ustreamer.bin" ]; then
echo "Streamer installed successfully"
else
echo "${red}WARNING! WARNING! WARNING!${white}"
@@ -453,18 +453,18 @@ streamer_install() {
streamer_install
fi
fi
if [ -f "/home/$user/ustreamer/ustreamer.bin" ]; then
sudo -u $user ln -s /home/$user/ustreamer/ustreamer.bin /home/$user/ustreamer/ustreamer
if [ -f "/opt/octoprint/ustreamer/ustreamer.bin" ]; then
ln -s /opt/octoprint/ustreamer/ustreamer.bin /opt/octoprint/ustreamer/ustreamer
fi
echo 'streamer: ustreamer' >> /etc/octoprint_deploy
echo 'streamer: ustreamer' >> /etc/octodocker_deploy
fi
if [ $VID -eq 4 ]; then
rm -rf /home/$user/camera-streamer 2>/dev/null
rm -rf /opt/octoprint/camera-streamer 2>/dev/null
#install camera-streamer
sudo -u $user git -C /home/$user clone https://github.com/ayufan-research/camera-streamer.git --recursive
sudo -u $user make -C /home/$user/camera-streamer > /dev/null
if [ -f "/home/$user/camera-streamer/camera-streamer" ]; then
git -C /opt/octoprint clone https://github.com/ayufan-research/camera-streamer.git --recursive
make -C /opt/octoprint/camera-streamer > /dev/null
if [ -f "/opt/octoprint/camera-streamer/camera-streamer" ]; then
echo "Streamer installed successfully"
else
echo "${red}WARNING! WARNING! WARNING!${white}"
@@ -473,11 +473,11 @@ streamer_install() {
streamer_install
fi
fi
echo 'streamer: camera-streamer' >> /etc/octoprint_deploy
echo 'streamer: camera-streamer' >> /etc/octodocker_deploy
fi
if [ $VID -eq 3 ]; then
echo 'streamer: none' >> /etc/octoprint_deploy
echo 'streamer: none' >> /etc/octodocker_deploy
echo "Good for you! Cameras are just annoying anyway."
fi
@@ -522,7 +522,7 @@ firstrun_install() {
done
echo "Admin password: ${cyan}$OCTOPASS${white}"
sudo -u $user $OCTOEXEC --basedir $BASE user add $OCTOADMIN --password $OCTOPASS --admin
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE user add $OCTOADMIN --password $OCTOPASS --admin
fi
if [ -n "$OCTOADMIN" ]; then
@@ -534,13 +534,13 @@ firstrun_install() {
echo
echo
if prompt_confirm "Complete first run wizards now?"; then
sudo -u $user $OCTOEXEC --basedir $BASE config set server.firstRun false --bool
sudo -u $user $OCTOEXEC --basedir $BASE config set server.seenWizards.backup null
sudo -u $user $OCTOEXEC --basedir $BASE config set server.seenWizards.corewizard 4 --int
sudo -u $user $OCTOEXEC --basedir $BASE config set server.onlineCheck.enabled true --bool
sudo -u $user $OCTOEXEC --basedir $BASE config set server.pluginBlacklist.enabled true --bool
sudo -u $user $OCTOEXEC --basedir $BASE config set plugins.tracking.enabled true --bool
sudo -u $user $OCTOEXEC --basedir $BASE config set printerProfiles.default _default
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set server.firstRun false --bool
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set server.seenWizards.backup null
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set server.seenWizards.corewizard 4 --int
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set server.onlineCheck.enabled true --bool
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set server.pluginBlacklist.enabled true --bool
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set plugins.tracking.enabled true --bool
docker exec -it $INSTANCE $OCTOEXEC --basedir $BASE config set printerProfiles.default _default
fi
fi