Compare commits
No commits in common. "1f9e8d526946792a43209b8c5e5173486cd46f55" and "b94fcfc1c99165990ded96392ce847d9c6cb3a80" have entirely different histories.
1f9e8d5269
...
b94fcfc1c9
16 changed files with 48 additions and 154 deletions
5
TODO.md
5
TODO.md
|
@ -1,13 +1,18 @@
|
||||||
# TODO:
|
# TODO:
|
||||||
|
|
||||||
## First time/Octo-Config
|
## First time/Octo-Config
|
||||||
|
- Change OctoPrint listening address and port
|
||||||
|
- Change frontend listening address and port
|
||||||
- Add network configuration (replace nmtui)
|
- Add network configuration (replace nmtui)
|
||||||
- Add hostname configuration (replace nmtui)
|
- Add hostname configuration (replace nmtui)
|
||||||
|
- Consolidate shared functions into a single file
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
- Autodetect OctoPrint port if hosted locally
|
- Autodetect OctoPrint port if hosted locally
|
||||||
- Add on screen keyboard to Openbox autostart
|
- Add on screen keyboard to Openbox autostart
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
- Add MJPEG streamer
|
||||||
- 64 bit builds
|
- 64 bit builds
|
||||||
- More security
|
- More security
|
||||||
|
- e
|
||||||
|
|
|
@ -6,7 +6,6 @@ install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab"
|
||||||
install -m 755 files/.xprofile "${ROOTFS_DIR}/etc/skel/.xprofile"
|
install -m 755 files/.xprofile "${ROOTFS_DIR}/etc/skel/.xprofile"
|
||||||
install -m 755 files/.browser.sh "${ROOTFS_DIR}/etc/skel/.browser.sh"
|
install -m 755 files/.browser.sh "${ROOTFS_DIR}/etc/skel/.browser.sh"
|
||||||
install -m 644 files/.dialogrc "${ROOTFS_DIR}/etc/skel/.dialogrc"
|
install -m 644 files/.dialogrc "${ROOTFS_DIR}/etc/skel/.dialogrc"
|
||||||
install -m 644 files/.dialogrc "${ROOTFS_DIR}/root/.dialogrc"
|
|
||||||
mkdir -p "${ROOTFS_DIR}/etc/skel/.config/openbox"
|
mkdir -p "${ROOTFS_DIR}/etc/skel/.config/openbox"
|
||||||
install -m 644 files/autostart "${ROOTFS_DIR}/etc/skel/.config/openbox/autostart"
|
install -m 644 files/autostart "${ROOTFS_DIR}/etc/skel/.config/openbox/autostart"
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
LISTEN=$(grep -i listen /etc/nginx/port.conf | awk '{gsub(";",""); print $2}')
|
source /srv/octoprint/host
|
||||||
|
|
||||||
if [[ -f ~/.overrideurl.sh ]]; then source ./.overrideurl.sh; fi
|
if [[ -f ~/.overrideurl.sh ]]; then source ./.overrideurl.sh; fi
|
||||||
|
|
||||||
# Wait until OctoPrint comes up
|
# Wait until OctoPrint comes up
|
||||||
while ! curl "$LISTEN" 2>&1 >/dev/null; do
|
while ! curl "$HOST:$PORT" 2>&1 >/dev/null; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
surf -d -F -g -K -n -p "$LISTEN"
|
surf -d -F -g -K -n -p "$HOST:$PORT"
|
||||||
|
|
|
@ -4,4 +4,3 @@ python-setuptools
|
||||||
python-virtualenv
|
python-virtualenv
|
||||||
git
|
git
|
||||||
libyaml-dev
|
libyaml-dev
|
||||||
nginx
|
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
|
|
||||||
install -m 644 files/octoprint.service ${ROOTFS_DIR}/etc/systemd/system/octoprint.service
|
install -m 644 files/octoprint.service ${ROOTFS_DIR}/etc/systemd/system/octoprint.service
|
||||||
|
|
||||||
install -m 644 files/nginx.conf ${ROOTFS_DIR}/etc/nginx/nginx.conf
|
|
||||||
echo -e "listen 80;" > ${ROOTFS_DIR}/etc/nginx/listen.conf
|
|
||||||
|
|
||||||
on_chroot << EOF
|
on_chroot << EOF
|
||||||
systemctl enable nginx
|
|
||||||
if ! pip list | grep -F octoprint; then
|
if ! pip list | grep -F octoprint; then
|
||||||
if [[ ! -d /srv/octoprint ]]; then mkdir -p /srv/octoprint; fi
|
if [[ ! -d /srv/octoprint ]]; then mkdir -p /srv/octoprint; fi
|
||||||
cd /srv/octoprint || exit 1
|
cd /srv/octoprint || exit 1
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
worker_processes auto;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
sendfile on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
|
||||||
default upgrade;
|
|
||||||
'' close;
|
|
||||||
}
|
|
||||||
|
|
||||||
upstream "octoprint" {
|
|
||||||
server 127.0.0.1:5000;
|
|
||||||
}
|
|
||||||
|
|
||||||
upstream "mjpg-streamer" {
|
|
||||||
server 127.0.0.1:8080;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
include /etc/nginx/listen.conf;
|
|
||||||
server_name localhost;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://octoprint/;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Scheme $scheme;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
|
|
||||||
client_max_body_size 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /webcam/ {
|
|
||||||
proxy_pass http://mjpg-streamer/;
|
|
||||||
}
|
|
||||||
|
|
||||||
# redirect server error pages to the static page /50x.html
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ Description=OctoPrint Daemon
|
||||||
Type=simple
|
Type=simple
|
||||||
User=octoprint
|
User=octoprint
|
||||||
Group=octoprint
|
Group=octoprint
|
||||||
ExecStart=/srv/octoprint/venv/bin/octoprint --host localhost --port 5000
|
ExecStart=/usr/local/bin/start-octoprint
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
cmake
|
|
||||||
libjpeg8-dev
|
|
||||||
v4l-utils
|
|
||||||
libv4l-dev
|
|
||||||
gcc
|
|
||||||
g++
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
install -m 644 files/mjpg-streamer.service ${ROOTFS_DIR}/etc/systemd/system/mjpg-streamer.service
|
|
||||||
install -m 755 files/start-mjpg ${ROOTFS_DIR}/usr/local/bin/start-mjpg
|
|
||||||
|
|
||||||
on_chroot << EOF
|
|
||||||
if ! which mjpg_streamer; then
|
|
||||||
cd /tmp
|
|
||||||
rm -rf /tmp/mjpg-streamer
|
|
||||||
git clone https://github.com/jacksonliam/mjpg-streamer/
|
|
||||||
cd mjpg-streamer/mjpg-streamer-experimental/
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
cd /
|
|
||||||
rm -rf /tmp/mjpg-streamer
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=MJPG-Streamer Daemon
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=octoprint
|
|
||||||
Group=octoprint
|
|
||||||
ExecStart=/usr/local/bin/start-mjpg
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
/usr/local/bin/mjpg_streamer -i input_uvc.so -o "output_http.so --port 8080"
|
|
|
@ -4,6 +4,7 @@ mkdir -p "${ROOTFS_DIR}/usr/local/bin/"
|
||||||
install -m 755 files/octo-config "${ROOTFS_DIR}/usr/local/bin/octo-config"
|
install -m 755 files/octo-config "${ROOTFS_DIR}/usr/local/bin/octo-config"
|
||||||
install -m 755 files/first-time.sh "${ROOTFS_DIR}/etc/profile.d/first-time.sh"
|
install -m 755 files/first-time.sh "${ROOTFS_DIR}/etc/profile.d/first-time.sh"
|
||||||
install -m 755 files/octo-lib.sh "${ROOTFS_DIR}/usr/local/lib/octo-lib.sh"
|
install -m 755 files/octo-lib.sh "${ROOTFS_DIR}/usr/local/lib/octo-lib.sh"
|
||||||
|
install -m 755 files/start-octoprint "${ROOTFS_DIR}/usr/local/bin/start-octoprint"
|
||||||
|
|
||||||
mkdir -p ${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d/
|
mkdir -p ${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d/
|
||||||
cat > ${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d/override.conf << 'EOF'
|
cat > ${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d/override.conf << 'EOF'
|
|
@ -73,15 +73,11 @@ service_select || return 1
|
||||||
|
|
||||||
screen_timeout || return 1
|
screen_timeout || return 1
|
||||||
|
|
||||||
if [[ -f /etc/systemd/system/multi-user.target.wants/octoprint.service ]] && dialog --title "OctoPrint Config" --yesno "Do you wish to change the default OctoPrint listening address and/or port?" 10 60; then
|
if dialog --title "OctoPrint Config" --yesno "Do you wish to change the default OctoPrint listening address and/or port?" 10 60; then
|
||||||
nginx_config
|
octo_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f /etc/systemd/system/multi-user.target.wants/mjpg-streamer.service ]]; then
|
if dialog --title "Plugin Manager" --yesno "Do you wish to preinstall some suggested plugins?" 10 60; then
|
||||||
video_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f /etc/systemd/system/multi-user.target.wants/octoprint.service ]] && dialog --title "Plugin Manager" --yesno "Do you wish to preinstall some suggested plugins?" 10 60; then
|
|
||||||
recommended_menu || return 1
|
recommended_menu || return 1
|
||||||
suggested_menu || return 1
|
suggested_menu || return 1
|
||||||
chown -R octoprint:octoprint /srv/octoprint
|
chown -R octoprint:octoprint /srv/octoprint
|
|
@ -9,22 +9,20 @@ source /usr/local/lib/octo-lib.sh
|
||||||
|
|
||||||
main_menu () {
|
main_menu () {
|
||||||
local MAINMENU=$(dialog --nocancel --title "Pi Setup" --menu "" 10 50 0 \
|
local MAINMENU=$(dialog --nocancel --title "Pi Setup" --menu "" 10 50 0 \
|
||||||
"1" "Configure networking" \
|
"1" "Configure Networking" \
|
||||||
"2" "Change password for pi" \
|
"2" "Change password for pi" \
|
||||||
"3" "Configure services" \
|
"3" "Configure services" \
|
||||||
"4" "Configure screen timeout" \
|
"4" "Configure screen timeout" \
|
||||||
"5" "Configure Nginx" \
|
"5" "Configure OctoPrint" \
|
||||||
"6" "Configure MJPG" \
|
"6" "Exit" 3>&1 1>&2 2>&3)
|
||||||
"7" "Exit" 3>&1 1>&2 2>&3)
|
|
||||||
|
|
||||||
case $MAINMENU in
|
case $MAINMENU in
|
||||||
"1") nmtui; main_menu; return 0;;
|
"1") nmtui; main_menu; return 0;;
|
||||||
"2") change_password; main_menu; return 0;;
|
"2") change_password; main_menu; return 0;;
|
||||||
"3") service_select; main_menu; return 0;;
|
"3") service_select; main_menu; return 0;;
|
||||||
"4") screen_timeout; main_menu; return 0;;
|
"4") screen_timeout; main_menu; return 0;;
|
||||||
"5") nginx_config; main_menu; return 0;;
|
"5") octo_config; main_menu; return 0;;
|
||||||
"6") video_config; main_menu; return 0;;
|
"6") return 0;;
|
||||||
"7") return 0;;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,23 +20,20 @@ change_password () {
|
||||||
service_select () {
|
service_select () {
|
||||||
local SERVICE_MENU=$(dialog --separate-output --nocancel --title "Select services" --checklist "Enable/disable services" 0 0 0 \
|
local SERVICE_MENU=$(dialog --separate-output --nocancel --title "Select services" --checklist "Enable/disable services" 0 0 0 \
|
||||||
"1" "OctoPrint" $(if [[ -f /etc/systemd/system/multi-user.target.wants/octoprint.service ]]; then echo "ON"; else echo "OFF"; fi) \
|
"1" "OctoPrint" $(if [[ -f /etc/systemd/system/multi-user.target.wants/octoprint.service ]]; then echo "ON"; else echo "OFF"; fi) \
|
||||||
"2" "MJPG-Streamer" $(if [[ -f /etc/systemd/system/multi-user.target.wants/mjpg-streamer.service ]]; then echo "ON"; else echo "OFF"; fi) \
|
"2" "GUI" $(if [[ $(systemctl get-default) == "graphical.target" ]]; then echo "ON"; else echo "OFF"; fi) \
|
||||||
"3" "GUI" $(if [[ $(systemctl get-default) == "graphical.target" ]]; then echo "ON"; else echo "OFF"; fi) \
|
"3" "SSH" $(if [[ -f /etc/systemd/system/multi-user.target.wants/ssh.service ]]; then echo "ON"; else echo "OFF"; fi) 3>&1 1>&2 2>&3)
|
||||||
"4" "SSH" $(if [[ -f /etc/systemd/system/multi-user.target.wants/ssh.service ]]; then echo "ON"; else echo "OFF"; fi) 3>&1 1>&2 2>&3)
|
|
||||||
|
|
||||||
SERVICE_MENU=($SERVICE_MENU)
|
SERVICE_MENU=($SERVICE_MENU)
|
||||||
|
|
||||||
local ENABLE_OCTO=false
|
local ENABLE_OCTO=false
|
||||||
local ENABLE_MJPG=false
|
|
||||||
local ENABLE_GUI=false
|
local ENABLE_GUI=false
|
||||||
local ENABLE_SSH=false
|
local ENABLE_SSH=false
|
||||||
|
|
||||||
for i in "${SERVICE_MENU[@]}"; do
|
for i in "${SERVICE_MENU[@]}"; do
|
||||||
case $i in
|
case $i in
|
||||||
"1") ENABLE_OCTO=true ;;
|
"1") ENABLE_OCTO=true ;;
|
||||||
"2") ENABLE_MJPG=true ;;
|
"2") ENABLE_GUI=true ;;
|
||||||
"3") ENABLE_GUI=true ;;
|
"3") ENABLE_SSH=true ;;
|
||||||
"4") ENABLE_SSH=true ;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -46,12 +43,6 @@ service_select () {
|
||||||
systemctl disable octoprint
|
systemctl disable octoprint
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $ENABLE_MJPG == true ]]; then
|
|
||||||
systemctl enable mjpg-streamer
|
|
||||||
else
|
|
||||||
systemctl disable mjpg-streamer
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $ENABLE_GUI == true ]]; then
|
if [[ $ENABLE_GUI == true ]]; then
|
||||||
systemctl set-default graphical.target
|
systemctl set-default graphical.target
|
||||||
else
|
else
|
||||||
|
@ -87,39 +78,30 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_timeout() {
|
screen_timeout() {
|
||||||
local TIMEOUT=$(dialog --nocancel --title "Screen Timeout" --inputbox "Input your desired screen timeout in seconds.\nEnter \"off\" to disable the screen timeout.\n\nAdding a screen timeout can reduce screen burn in.\n\nDefault: off" 12 60 "off" 3>&1 1>&2 2>&3)
|
local TIMEOUT=$(dialog --nocancel --title "Screen Timeout" --inputbox "Input your desired screen timeout in seconds.\nEnter \"off\" to disable the screen timeout.\n\nAdding a screen timeout can reduce screen burn in." 11 60 "0" 3>&1 1>&2 2>&3)
|
||||||
cat > /home/pi/.xtimeout << EOF
|
cat > /home/pi/.xtimeout << EOF
|
||||||
xset s ${TIMEOUT}
|
xset s ${TIMEOUT}
|
||||||
xset -dpms
|
xset -dpms
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
nginx_config () {
|
octo_config () {
|
||||||
local LISTEN=""
|
if [[ -f /srv/octoprint/host ]]; then
|
||||||
|
source /srv/octoprint/host
|
||||||
if [[ -f /etc/nginx/listen.conf ]]; then
|
|
||||||
LISTEN=$(grep -i listen /etc/nginx/listen.conf | awk '{gsub(";",""); print $2}')
|
|
||||||
else
|
else
|
||||||
LISTEN="80"
|
HOST="0.0.0.0"
|
||||||
|
PORT="5000"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LISTEN=$(dialog --title "Nginx Config" --nocancel --inputbox "Configure what port and IP Nginx should listen on.\nTo listen on all IPs, just enter the port.\nDefault: 80" 11 50 "$LISTEN" 3>&1 1>&2 2>&3)
|
local OCTOFORM=$(dialog --title "OctoPrint Config" --nocancel --form "Configure what port and IP OctoPrint listen on." 10 50 0 \
|
||||||
|
"Listening IP:" 1 1 "$HOST" 1 17 20 0 \
|
||||||
|
"Listening Port:" 2 1 "$PORT" 2 17 6 0 3>&1 1>&2 2>&3)
|
||||||
|
OCTOFORM=($OCTOFORM)
|
||||||
|
|
||||||
echo "listen $LISTEN;" > /etc/nginx/listen.conf
|
HOST=${OCTOFORM[0]}
|
||||||
|
PORT=${OCTOFORM[1]}
|
||||||
|
|
||||||
|
echo -e "HOST=$HOST\nPORT=$PORT" > /srv/octoprint/host
|
||||||
}
|
}
|
||||||
|
|
||||||
video_config () {
|
|
||||||
local DEVICES=($(ls /dev/video*))
|
|
||||||
|
|
||||||
local DEVICELIST=""
|
|
||||||
|
|
||||||
for ((i = 0; i < ${#DEVICES[@]}; i++)); do
|
|
||||||
DEVICELIST+="${DEVICES[$i]} $i OFF "
|
|
||||||
done
|
|
||||||
|
|
||||||
local DEVICE_MENU=$(dialog --title "Video Config" --nocancel --radiolist "Choose which video device you wish to use for MJPG-Streamer" 10 50 0 $DEVICELIST 3>&1 1>&2 2>&3)
|
|
||||||
|
|
||||||
[[ "$DEVICE_MENU" == "" ]] && return 0
|
|
||||||
|
|
||||||
echo -e '#!/bin/bash'"\n/usr/local/bin/mjpg_streamer -i \"input_uvc.so -d $DEVICE_MENU\" -o \"output_http.so --port 8080\"" > /usr/local/bin/start-mjpg
|
|
||||||
}
|
|
10
stage2/05-utils/files/start-octoprint
Normal file
10
stage2/05-utils/files/start-octoprint
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /srv/octoprint/venv/bin/activate
|
||||||
|
|
||||||
|
source /srv/octoprint/host
|
||||||
|
|
||||||
|
[[ "$HOST" == "" ]] && HOST="0.0.0.0"
|
||||||
|
[[ "$PORT" == "" ]] && PORT="5000"
|
||||||
|
|
||||||
|
/srv/octoprint/venv/bin/octoprint serve --host $HOST --port $PORT
|
Loading…
Reference in a new issue