Compare commits
5 commits
a55df5400f
...
0b4318d557
Author | SHA1 | Date | |
---|---|---|---|
0b4318d557 | |||
749d4af374 | |||
61e706f397 | |||
9f57eba401 | |||
19fb6cddf1 |
6 changed files with 121 additions and 67 deletions
2
TODO.md
2
TODO.md
|
@ -3,8 +3,6 @@
|
|||
## First time/TP-Config
|
||||
- Add network configuration (replace nmtui)
|
||||
- Add hostname configuration (replace nmtui)
|
||||
- Add Enclosure plugin to suggested
|
||||
- Bring back cancel buttons
|
||||
|
||||
## Misc
|
||||
- Cleanup
|
||||
|
|
|
@ -18,5 +18,4 @@ if ! id -u kiosk >/dev/null 2>&1; then
|
|||
adduser --disabled-password --shell /usr/sbin/nologin --gecos "" kiosk
|
||||
fi
|
||||
echo "${FIRST_USER_NAME}:${FIRST_USER_PASS}" | chpasswd
|
||||
echo "root:$(cat /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c40)" | chpasswd
|
||||
EOF
|
||||
|
|
|
@ -7,6 +7,12 @@ if [ "$EUID" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Prevent Ctrl+C since you shouldn't be able to exit this
|
||||
trap '' SIGINT
|
||||
|
||||
# Set the FIRST_TIME variable to disable cancel boxes
|
||||
FIRST_TIME="--nocancel"
|
||||
|
||||
# Import common functions
|
||||
source /usr/local/lib/tp-lib.sh
|
||||
|
||||
|
@ -21,58 +27,58 @@ error_install () {
|
|||
}
|
||||
|
||||
recommended_menu () {
|
||||
local RECOMMEND_MENU=$(dialog --nocancel --title "Plugin Manager | Recommended Plugins" --checklist "Check plugins that you wish to install." 0 0 0 \
|
||||
local RECOMMEND_MENU=$(dialog --title "Plugin Manager | Recommended Plugins" --checklist "Check plugins that you wish to install." 0 0 0 \
|
||||
"OctoPrint-Dashboard" "Adds a nice dashboard to OctoPrint." ON \
|
||||
"ExcludeRegion" "Select regions of the bed where you don't want to print." ON \
|
||||
"NavbarTemp" "Shows the temperature of the Pi, extruder(s) and bed in the navigation bar." ON \
|
||||
"PrintTimeGenius" "Provides more accurate print time estimates." ON \
|
||||
"HeaterTimeout" "Turns off the hotend and bed after a set amount of time." ON \
|
||||
"TouchUI" "Makes the UI easier to use on touchscreens. Also adds a virtual keyboard." ON 3>&1 1>&2 2>&3)
|
||||
"TouchUI" "Makes the UI easier to use on touchscreens. Also adds a virtual keyboard." ON 3>&1 1>&2 2>&3 || return 0)
|
||||
|
||||
RECOMMEND_MENU=($RECOMMEND_MENU)
|
||||
|
||||
for ((i = 0; i < ${#RECOMMEND_MENU[@]}; i++)); do
|
||||
echo $(( $i * 100 / ${#RECOMMEND_MENU[@]} )) | dialog --title "Plugin Manager" --gauge "Installing ${RECOMMEND_MENU[$i]}" 10 50
|
||||
case ${RECOMMEND_MENU[$i]} in
|
||||
"OctoPrint-Dashboard") install_package "https://github.com/StefanCohen/OctoPrint-Dashboard/archive/master.zip" || error_install "OctoPrint-Dashboard"; install_package "https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/releases/latest/download/master.zip" || error_install "OctoPrint-Dashboard";;
|
||||
"ExcludeRegion") install_package "https://github.com/bradcfisher/OctoPrint-ExcludeRegionPlugin/archive/master.zip" || error_install "ExcludeRegion";;
|
||||
"NavbarTemp") install_package "https://github.com/imrahil/OctoPrint-NavbarTemp/archive/master.zip" || error_install "NavbarTemp";;
|
||||
"PrintTimeGenius") install_package "https://github.com/eyal0/OctoPrint-PrintTimeGenius/archive/master.zip" || error_install "PrintTimeGenius";;
|
||||
"HeaterTimeout") install_package "https://github.com/google/OctoPrint-HeaterTimeout/archive/master.zip" || error_install "HeaterTimeout";;
|
||||
"TouchUI") install_package "https://github.com/BillyBlaze/OctoPrint-TouchUI/archive/master.zip" || error_install "TouchUI";;
|
||||
"OctoPrint-Dashboard") install_package "https://github.com/StefanCohen/OctoPrint-Dashboard/archive/master.zip" || error_install ${RECOMMEND_MENU[$i]}; install_package "https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/releases/latest/download/master.zip" || error_install ${RECOMMEND_MENU[$i]};;
|
||||
"ExcludeRegion") install_package "https://github.com/bradcfisher/OctoPrint-ExcludeRegionPlugin/archive/master.zip" || error_install ${RECOMMEND_MENU[$i]};;
|
||||
"NavbarTemp") install_package "https://github.com/imrahil/OctoPrint-NavbarTemp/archive/master.zip" || error_install ${RECOMMEND_MENU[$i]};;
|
||||
"PrintTimeGenius") install_package "https://github.com/eyal0/OctoPrint-PrintTimeGenius/archive/master.zip" || error_install ${RECOMMEND_MENU[$i]};;
|
||||
"HeaterTimeout") install_package "https://github.com/google/OctoPrint-HeaterTimeout/archive/master.zip" || error_install ${RECOMMEND_MENU[$i]};;
|
||||
"TouchUI") install_package "https://github.com/BillyBlaze/OctoPrint-TouchUI/archive/master.zip" || error_install ${RECOMMEND_MENU[$i]};;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
suggested_menu () {
|
||||
local SUGGEST_MENU=$(dialog --nocancel --title "Plugin Manager | Suggested Plugins" --checklist "Check plugins that you wish to install.\n\nSome of these may conflict with the recommended plugins." 0 0 0 \
|
||||
local SUGGEST_MENU=$(dialog --title "Plugin Manager | Suggested Plugins" --checklist "Check plugins that you wish to install.\n\nSome of these may conflict with the recommended plugins." 0 0 0 \
|
||||
"Themeify" "Adds theming supports and a few themes to OctoPrint." OFF \
|
||||
"Preheat" "Adds a preheat button to preheat the bed and extruder to the temperature set in the selected gcode file." OFF \
|
||||
"ConsolidatedTabs" "Allows you to combine several tabs into one larger tab with draggable and resizable panels." OFF \
|
||||
"DetailedProgress" "Sends commands to your printer to display current printing progress." OFF 3>&1 1>&2 2>&3)
|
||||
"DetailedProgress" "Sends commands to your printer to display current printing progress." OFF \
|
||||
"Enclosure" "Adds a lot of features for enclosures such as support for external temperature sensors." OFF 3>&1 1>&2 2>&3 || return 0)
|
||||
|
||||
SUGGEST_MENU=($SUGGEST_MENU)
|
||||
|
||||
for ((i = 0; i < ${#SUGGEST_MENU[@]}; i++)); do
|
||||
echo $(( $i * 100 / ${#SUGGEST_MENU[@]} )) | dialog --title "Plugin Manager" --gauge "Installing ${SUGGEST_MENU[$i]}" 10 50
|
||||
case ${SUGGEST_MENU[$i]} in
|
||||
"Themeify") install_package "https://github.com/birkbjo/OctoPrint-Themeify/archive/master.zip" || error_install "Themeify";;
|
||||
"Preheat") install_package "https://github.com/marian42/octoprint-preheat/archive/master.zip" || error_install "Preheat";;
|
||||
"ConsolidatedTabs") install_package "https://github.com/jneilliii/OctoPrint-ConsolidatedTabs/archive/master.zip" || error_install "ConsolidatedTabs";;
|
||||
"DetailedProgress") install_package "https://github.com/tpmullan/OctoPrint-DetailedProgress/archive/master.zip" || error_install "DetailedProgress";;
|
||||
"Themeify") install_package "https://github.com/birkbjo/OctoPrint-Themeify/archive/master.zip" || error_install ${SUGGEST_MENU[$i]};;
|
||||
"Preheat") install_package "https://github.com/marian42/octoprint-preheat/archive/master.zip" || error_install ${SUGGEST_MENU[$i]};;
|
||||
"ConsolidatedTabs") install_package "https://github.com/jneilliii/OctoPrint-ConsolidatedTabs/archive/master.zip" || error_install ${SUGGEST_MENU[$i]};;
|
||||
"DetailedProgress") install_package "https://github.com/tpmullan/OctoPrint-DetailedProgress/archive/master.zip" || error_install ${SUGGEST_MENU[$i]};;
|
||||
"Enclosure") install_package "https://github.com/vitormhenrique/OctoPrint-Enclosure/archive/master.zip" || error_install ${SUGGEST_MENU[$i]};;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
dialog --title "NOTICE" --nocancel --colors --msgbox "This collection of software is currently in beta, it may contain several bugs. This software is \Zb\Z1NOT\Zn recommended for a production environment." 10 50
|
||||
dialog --title "NOTICE" --colors --msgbox "This collection of software is currently in beta, it may contain several bugs. This software is \Zb\Z1NOT\Zn recommended for a production environment." 10 50
|
||||
|
||||
# Makes a certificate and key for Nginx HTTPS
|
||||
openssl req -x509 -nodes -days 36500 -newkey rsa:4096 -subj "/C=/ST=/L=/O=/OU=/CN=*/emailAddress=" -out /etc/ssl/certs/nginx-octoprint.crt -keyout /etc/ssl/private/nginx-octoprint.key
|
||||
|
||||
# Force the user to change the pi user's password before the RPi gets botnetted
|
||||
change_password
|
||||
# Randomize the root password
|
||||
echo "root:$(cat /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c40)" | chpasswd
|
||||
|
||||
dialog --title "Network Configuration" --nocancel --msgbox "Setup will now open nmtui, a program to help configure your ethernet/wireless interfaces. Hit Quit when you are done." 10 50
|
||||
nmtui
|
||||
|
@ -109,9 +115,9 @@ fi
|
|||
|
||||
# If OctoPrint is running locally, ask if user wants to preinstall recommended plugins
|
||||
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
|
||||
suggested_menu || return 1
|
||||
recommended_menu && suggested_menu
|
||||
chown -R octoprint:octoprint /srv/octoprint
|
||||
chown -R octoprint:octoprint /home/octoprint
|
||||
fi
|
||||
|
||||
# Delete the autologin override and first-time setup utility
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
change_password () {
|
||||
local PASSWORD="$(dialog --title "Change Password" --nocancel --insecure --passwordbox "Enter new password for user \"pi\"" 10 50 3>&1 1>&2 2>&3)"
|
||||
# If the password field was left blank, exit
|
||||
if [[ $? -ne 0 ]] || [[ $PASSWORD == "" ]]; then return 1; fi
|
||||
local PASSWORD="$(dialog --title "Change Password" $FIRST_TIME --insecure --passwordbox "Enter new password for user \"pi\"" 10 50 3>&1 1>&2 2>&3 || return 0)"
|
||||
|
||||
# If the password field was left blank and we aren't in the first time setup, exit
|
||||
[[ $PASSWORD == "" ]] && [[ $FIRST_TIME == "" ]] && return 0
|
||||
|
||||
# If we are in the first time setup and the password field is blank, make the user restart
|
||||
[[ $PASSWORD == "" ]] && ! [[ $FIRST_TIME == "" ]] && change_password
|
||||
|
||||
# If the password is raspberry, tell the user he is an idiot
|
||||
if [[ "$PASSWORD" == "raspberry" ]]; then
|
||||
dialog --title "Change Password" --nocancel --msgbox "That password sucks. Please use a different one :)" 10 50
|
||||
dialog --title "Change Password" --msgbox "That password sucks. Please use a different one :)" 10 50
|
||||
change_password
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ "$(dialog --nocancel --insecure --passwordbox "Confirm new password for user \"pi\"" 10 50 3>&1 1>&2 2>&3)" == "$PASSWORD" ]]; then
|
||||
if [[ $? != 0 ]]; then return 1; fi
|
||||
if [[ "$(dialog $FIRST_TIME --title "Change Password" --insecure --passwordbox "Confirm new password for user \"pi\"" 10 50 3>&1 1>&2 2>&3 || return 0)" == "$PASSWORD" ]]; then
|
||||
echo -e "pi:$PASSWORD" | chpasswd
|
||||
else
|
||||
dialog --title "Change Password" --nocancel --colors --msgbox "\Z1\ZbPasswords did not match!" 5 30
|
||||
dialog --title "Change Password" --colors --msgbox "\Z1\ZbPasswords did not match!" 5 30
|
||||
change_password
|
||||
return 0
|
||||
fi
|
||||
|
@ -24,11 +27,11 @@ change_password () {
|
|||
|
||||
service_toggle () {
|
||||
# Toggle the checkboxes if the service is active or not
|
||||
local SERVICE_MENU=$(dialog --separate-output --nocancel --title "Select services" --checklist "Enable/disable services" 0 0 0 \
|
||||
local SERVICE_MENU=$(dialog $FIRST_TIME --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) \
|
||||
"2" "MJPG-Streamer" $(if [[ -f /etc/systemd/system/multi-user.target.wants/mjpg-streamer.service ]]; then echo "ON"; else echo "OFF"; fi) \
|
||||
"3" "GUI" $(if [[ $(systemctl get-default) == "graphical.target" ]]; then echo "ON"; else echo "OFF"; fi) \
|
||||
"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)
|
||||
"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 || return 0)
|
||||
|
||||
SERVICE_MENU=($SERVICE_MENU)
|
||||
|
||||
|
@ -46,6 +49,8 @@ service_toggle () {
|
|||
esac
|
||||
done
|
||||
|
||||
# If FIRST_TIME is not empty, this is the first time boot so don't actually start stuff, otherwise use normal behaviour
|
||||
if ! [[ "$FIRST_TIME" == "" ]]; then
|
||||
if [[ $ENABLE_OCTO == true ]]; then
|
||||
systemctl enable octoprint
|
||||
else
|
||||
|
@ -77,8 +82,43 @@ service_toggle () {
|
|||
else
|
||||
systemctl disable ssh
|
||||
fi
|
||||
else
|
||||
if [[ $ENABLE_OCTO == true ]]; then
|
||||
systemctl enable --now octoprint
|
||||
else
|
||||
systemctl disable --now octoprint
|
||||
fi
|
||||
|
||||
if [[ $ENABLE_MJPG == true ]]; then
|
||||
systemctl enable --now mjpg-streamer
|
||||
raspi-config nonint do_camera 0 # Counter intuitively enables the camera
|
||||
ASK_REBOOT=true
|
||||
else
|
||||
systemctl disable --now mjpg-streamer
|
||||
raspi-config nonint do_camera 1 # Disables the camera
|
||||
ASK_REBOOT=true
|
||||
fi
|
||||
|
||||
if [[ $ENABLE_OCTO == true ]] && [[ $ENABLE_MJPG == true ]]; then
|
||||
systemctl enable --now nginx
|
||||
elif [[ $ENABLE_OCTO == false ]] && [[ $ENABLE_MJPG == false ]]; then
|
||||
systemctl disable --now nginx
|
||||
fi
|
||||
|
||||
if [[ $ENABLE_GUI == true ]]; then
|
||||
systemctl set-default graphical.target
|
||||
ASK_REBOOT=true
|
||||
else
|
||||
systemctl set-default multi-user.target
|
||||
ASK_REBOOT=true
|
||||
fi
|
||||
|
||||
if [[ $ENABLE_SSH == true ]]; then
|
||||
systemctl enable --now ssh
|
||||
else
|
||||
systemctl disable --now ssh
|
||||
fi
|
||||
fi
|
||||
|
||||
<< 'EOF'
|
||||
for ((i = 0; i <= 3; i++)); do
|
||||
|
@ -102,8 +142,9 @@ EOF
|
|||
}
|
||||
|
||||
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 $FIRST_TIME --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 || return 0)
|
||||
|
||||
# If timeout is blank, exit before we break everything
|
||||
[[ "$TIMEOUT" == "" ]] && return 0
|
||||
|
||||
cat > /home/kiosk/.xtimeout << EOF
|
||||
|
@ -118,11 +159,16 @@ EOF
|
|||
}
|
||||
|
||||
octo_autologin () {
|
||||
local AUTOLOGIN_MENU="$(dialog --title "OctoPrint AutoLogin" --nocancel --inputbox "Enter the username of the user that you want the GUI to autologin as on startup." 10 50 $(octo-settings read accessControl autologinAs) 3>&1 1>&2 2>&3)"
|
||||
local AUTOLOGIN_MENU="$(dialog --title "OctoPrint AutoLogin" --inputbox "Enter the username of the user that you want the GUI to autologin as on startup." 10 50 $(octo-settings read accessControl autologinAs) 3>&1 1>&2 2>&3 || return 0)"
|
||||
|
||||
# If the text field is blank, exit before everything (probably doesn't) break
|
||||
[[ "$AUTOLOGIN_MENU" == "" ]] && return 0
|
||||
|
||||
octo-settings write accessControl autologinAs $AUTOLOGIN_MENU
|
||||
|
||||
if [[ -f /etc/systemd/system/multi-user.target.wants/octoprint.service ]]; then
|
||||
systemctl restart octoprint
|
||||
ASK_REBOOT=true
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -136,7 +182,7 @@ nginx_listen () {
|
|||
LISTEN="443"
|
||||
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: 443" 11 50 "$LISTEN" 3>&1 1>&2 2>&3)
|
||||
LISTEN=$(dialog --title "Nginx Config" --inputbox "Configure what port and IP Nginx should listen on.\nTo listen on all IPs, just enter the port.\nDefault: 443" 11 50 "$LISTEN" 3>&1 1>&2 2>&3 || return 0)
|
||||
|
||||
[[ "$LISTEN" == "" ]] && return 0
|
||||
|
||||
|
@ -150,7 +196,7 @@ nginx_listen () {
|
|||
}
|
||||
|
||||
nginx_auth () {
|
||||
local NGINXAUTH_MENU=$(dialog --colors --nocancel --insecure --title "Nginx Config" --mixedform "Input desired username and password for the MJPG stream.\n\nLeave both fields blank if you do not want authentication \Zb\Z1(NOT RECOMMENDED)\Zn." 12 60 0\
|
||||
local NGINXAUTH_MENU=$(dialog --colors $FIRST_TIME --insecure --title "Nginx Config" --mixedform "Input desired username and password for the MJPG stream.\n\nLeave both fields blank if you do not want authentication \Zb\Z1(NOT RECOMMENDED)\Zn." 12 60 0\
|
||||
"Username: " 1 1 "" 1 11 10 0 0 \
|
||||
"Password: " 2 1 "" 2 11 30 0 1 3>&1 1>&2 2>&3 || return 0)
|
||||
NGINXAUTH_MENU=($NGINXAUTH_MENU)
|
||||
|
@ -208,7 +254,7 @@ video_select () {
|
|||
fi
|
||||
done
|
||||
|
||||
local DEVICE_MENU=$(dialog --title "MJPG Config" --nocancel --radiolist "Choose which video device you wish to use for MJPG-Streamer" 10 50 0 $DEVICELIST 3>&1 1>&2 2>&3)
|
||||
local DEVICE_MENU=$(dialog --title "MJPG Config" $FIRST_TIME --radiolist "Choose which video device you wish to use for MJPG-Streamer" 10 50 0 $DEVICELIST 3>&1 1>&2 2>&3 || return 0)
|
||||
|
||||
[[ "$DEVICE_MENU" == "" ]] && return 0
|
||||
|
||||
|
@ -229,11 +275,12 @@ video_config () {
|
|||
VIDEO_DEVICE="/dev/video0"
|
||||
fi
|
||||
|
||||
local VIDEOCONFIG_MENU=$(dialog --nocancel --title "MJPG Config" --form "Choose desired camera resolution and framerate." 10 50 0\
|
||||
local VIDEOCONFIG_MENU=$(dialog $FIRST_TIME --title "MJPG Config" --form "Choose desired camera resolution and framerate." 10 50 0\
|
||||
"Resolution: " 1 1 "$VIDEO_SIZE" 1 13 10 0 \
|
||||
"Framerate: " 2 1 "$FRAMERATE" 2 12 3 0 3>&1 1>&2 2>&3)
|
||||
"Framerate: " 2 1 "$FRAMERATE" 2 12 3 0 3>&1 1>&2 2>&3 || return 0)
|
||||
VIDEOCONFIG_MENU=($VIDEOCONFIG_MENU)
|
||||
|
||||
# If one of the fields is empty, tell the user to start over
|
||||
if [[ "${VIDEOCONFIG_MENU[0]}" == "" ]] || [[ "${VIDEOCONFIG_MENU[1]}" == "" ]]; then
|
||||
dialog --title "Error" --msgbox "Invalid input!" 10 50
|
||||
video_config
|
||||
|
|
|
@ -4,6 +4,7 @@ set -e
|
|||
mkdir -p "${ROOTFS_DIR}/home/kiosk"
|
||||
install -m 755 files/.xprofile "${ROOTFS_DIR}/home/kiosk/.xprofile"
|
||||
install -m 755 files/.browser.sh "${ROOTFS_DIR}/home/kiosk/.browser.sh"
|
||||
install -m 755 files/.xtimeout "${ROOTFS_DIR}/home/kiosk/.xtimeout"
|
||||
|
||||
mkdir -p "${ROOTFS_DIR}/home/kiosk/.config/openbox"
|
||||
install -m 644 files/autostart "${ROOTFS_DIR}/home/kiosk/.config/openbox/autostart"
|
||||
|
|
3
stage3/02-kiosk/files/.xtimeout
Executable file
3
stage3/02-kiosk/files/.xtimeout
Executable file
|
@ -0,0 +1,3 @@
|
|||
xset s 60
|
||||
xset -dpms
|
||||
xset s noblank
|
Loading…
Reference in a new issue