Cleanup commit
This commit is contained in:
10
3dprinter-octoprint/rootfs/etc/caddy/Caddyfile
Normal file
10
3dprinter-octoprint/rootfs/etc/caddy/Caddyfile
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
# debug
|
||||
log {
|
||||
format console
|
||||
output file /var/log/caddy/caddy.log
|
||||
}
|
||||
auto_https disable_redirects
|
||||
}
|
||||
|
||||
import sites-enabled/*.caddy
|
||||
2
3dprinter-octoprint/rootfs/etc/caddy/env
Normal file
2
3dprinter-octoprint/rootfs/etc/caddy/env
Normal file
@@ -0,0 +1,2 @@
|
||||
XDG_CONFIG_HOME="/data/config"
|
||||
XDG_DATA_HOME="/data/config"
|
||||
0
3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitignore
vendored
Normal file
0
3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitignore
vendored
Normal file
54
3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh
Normal file
54
3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Prepare OctoPrint
|
||||
# s6-overlay docs: https://github.com/just-containers/s6-overlay
|
||||
# ==============================================================================
|
||||
export BASEDIR="--basedir /data/config/octoprint"
|
||||
|
||||
{ # Check if OctoPrint is installed.
|
||||
octoprint $BASEDIR --version
|
||||
} || { # Otherwise install it.
|
||||
{ # Check if Python is available (at `/data/python/octoprint`, set by PATH in Dockerfile)
|
||||
python --version
|
||||
} || { # Otherwise create Python virtual environment.
|
||||
python3 -m venv /data/python/octoprint
|
||||
# Install wheel to speed up future installs.
|
||||
pip install wheel
|
||||
}
|
||||
pip install octoprint==$OCTOPRINT_VERSION
|
||||
}
|
||||
|
||||
# Create initial OctoPrint config, if missing.
|
||||
if [ ! -f /data/config/octoprint/config.yaml ]; then
|
||||
mkdir -p /data/config/octoprint
|
||||
fi
|
||||
|
||||
# Update OctoPrint config with settings for the addon to behave properly.
|
||||
updateConfig()
|
||||
{
|
||||
# octoprint $BASEDIR config set --bool api.allowCrossOrigin true
|
||||
octoprint $BASEDIR config set folder.generated "/tmp/octoprint/generated"
|
||||
octoprint $BASEDIR config set folder.timelapse_tmp "/tmp/octoprint/timelapse/tmp"
|
||||
# octoprint $BASEDIR config set --bool server.allowFraming true
|
||||
octoprint $BASEDIR config set server.commands.serverRestartCommand "/scripts/octoprint_restart.sh"
|
||||
octoprint $BASEDIR config set server.commands.systemRestartCommand "/scripts/system_restart.sh"
|
||||
octoprint $BASEDIR config set server.commands.systemShutdownCommand "/scripts/system_shutdown.sh"
|
||||
octoprint $BASEDIR config set webcam.ffmpeg "/usr/bin/ffmpeg"
|
||||
}
|
||||
updateConfig
|
||||
|
||||
# Other setting changes, if needed. E.g. creating a user.
|
||||
# Update OctoPrint config with customized settings, not strictly required for addon to work but helps with features.
|
||||
# updateConfigCustom() {
|
||||
# Add user, if needed.
|
||||
# { # Make sure Ingress user for OctoPrint exists.
|
||||
# bashio::log.notice "Ensure Ingress user (homeassistant) exist."
|
||||
# if ! octoprint --basedir /data/config/octoprint user list | grep -q 'homeassistant'; then
|
||||
# new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
|
||||
# octoprint --basedir /data/config/octoprint user add --password "$new_password" --admin homeassistant # 2> /dev/null
|
||||
# fi
|
||||
# } || { # catch
|
||||
# bashio::log.warning "Failed to ensure Ingress user exists, may not be able to launch."
|
||||
# }
|
||||
# Trusted networks, access control etc.
|
||||
# }
|
||||
33
3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh
Normal file
33
3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Configures proxy
|
||||
# ==============================================================================
|
||||
|
||||
# Generate proxy configuration for internal and external access
|
||||
bashio::var.json \
|
||||
addon_hostname "$(bashio::addon.hostname)" \
|
||||
addon_ip "$(bashio::addon.ip_address)" \
|
||||
trusted_proxies "$(bashio::config 'trusted_proxies')" \
|
||||
| tempio \
|
||||
-template /usr/share/tempio/caddy/Caddyfile.internal_external.gtpl \
|
||||
-out /etc/caddy/sites-enabled/internal_external.caddy
|
||||
|
||||
# Generate proxy configuration for access by Ingress
|
||||
# bashio::var.json \
|
||||
# addon_hostname "$(bashio::addon.hostname)" \
|
||||
# addon_ip "$(bashio::addon.ip_address)" \
|
||||
# camera_host "$(bashio::config 'camera_url')" \
|
||||
# ingress_entry "$(bashio::addon.ingress_entry)" \
|
||||
# ingress_port "^$(bashio::addon.ingress_port)" \
|
||||
# interface "$(bashio::addon.ip_address)" \
|
||||
# mode "$(bashio::config 'mode')" \
|
||||
# supervisor_ip "$(bashio::supervisor.ip_address)" \
|
||||
# trusted_proxies "$(bashio::config 'trusted_proxies')" \
|
||||
# | tempio \
|
||||
# -template /usr/share/tempio/caddy/Caddyfile.ingress.gtpl \
|
||||
# -out /etc/caddy/sites-enabled/ingress.caddy
|
||||
|
||||
|
||||
# Make sure config is correctly formatted.
|
||||
caddy fmt --overwrite /etc/caddy/Caddyfile
|
||||
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish
Normal file
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Take down the S6 supervision tree when OctoPrint fails
|
||||
# ==============================================================================
|
||||
|
||||
# if -n { s6-test $# -ne 0 }
|
||||
# if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
# s6-svscanctl -t /var/run/s6/services
|
||||
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/run
Normal file
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/run
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Runs OctoPrint
|
||||
# ==============================================================================
|
||||
|
||||
bashio::log.info "Starting OctoPrint..."
|
||||
|
||||
## Run your program
|
||||
exec octoprint --basedir /data/config/octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 80
|
||||
5
3dprinter-octoprint/rootfs/etc/services.d/proxy/finish
Normal file
5
3dprinter-octoprint/rootfs/etc/services.d/proxy/finish
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Stop reverse proxy
|
||||
# ==============================================================================
|
||||
12
3dprinter-octoprint/rootfs/etc/services.d/proxy/run
Normal file
12
3dprinter-octoprint/rootfs/etc/services.d/proxy/run
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Runs the reverse proxy.
|
||||
# ==============================================================================
|
||||
|
||||
# Wait for OctoPrint WebUI to be available
|
||||
bashio::net.wait_for 80
|
||||
|
||||
bashio::log.info "Starting proxy..."
|
||||
|
||||
exec caddy run --config /etc/caddy/Caddyfile --envfile /etc/caddy/env
|
||||
5
3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Restart OctoPrint."
|
||||
|
||||
s6-svc -r /var/run/s6/legacy-services/octoprint
|
||||
5
3dprinter-octoprint/rootfs/scripts/proxy_restart.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/proxy_restart.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Restart proxy."
|
||||
|
||||
s6-svc -r /var/run/s6/legacy-services/proxy
|
||||
48
3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh
Normal file
48
3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
# #!/usr/bin/bash
|
||||
# # Set/update parts of OctoPrint config to work with addon.
|
||||
|
||||
# export OCTOPRINT_HOME=/data/config/octoprint
|
||||
|
||||
# # Access control
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json accessControl '
|
||||
# {
|
||||
# "localNetworks": [
|
||||
# "127.0.0.0/8",
|
||||
# "::1/128",
|
||||
# "172.30.32.2"
|
||||
# ]
|
||||
# }
|
||||
# '
|
||||
|
||||
# # API config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json api '
|
||||
# {
|
||||
# "allowCrossOrigin": true
|
||||
# }
|
||||
# '
|
||||
|
||||
# # Folder config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json folder '
|
||||
# {
|
||||
# "generated": "/tmp/octoprint/generated",
|
||||
# "timelapse_tmp": "/tmp/octoprint/timelapse/tmp"
|
||||
# }
|
||||
# '
|
||||
|
||||
# # Server config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json server '
|
||||
# {
|
||||
# "allowFraming": true,
|
||||
# "commands": {
|
||||
# "serverRestartCommand": "/scripts/octoprint_restart.sh",
|
||||
# "systemRestartCommand": "/scripts/system_restart.sh",
|
||||
# "systemShutdownCommand": "/scripts/system_shutdown.sh"
|
||||
# }
|
||||
# }
|
||||
# '
|
||||
# # Webcam config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json webcam '
|
||||
# {
|
||||
# "ffmpeg": "/usr/bin/ffmpeg"
|
||||
# }
|
||||
# '
|
||||
5
3dprinter-octoprint/rootfs/scripts/system_restart.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/system_restart.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Restart addon."
|
||||
|
||||
bashio::addon.restart
|
||||
5
3dprinter-octoprint/rootfs/scripts/system_shutdown.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/system_shutdown.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Shutdown addon."
|
||||
|
||||
bashio::addon.stop
|
||||
@@ -0,0 +1,46 @@
|
||||
:{{ .ingress_port }} {
|
||||
bind {{ .addon_ip }}
|
||||
@ingress {
|
||||
remote_ip {{ .supervisor_ip }}
|
||||
}
|
||||
uri strip_prefix {{ .ingress_entry }}
|
||||
handle {
|
||||
reverse_proxy @ingress 127.0.0.1:80/ {
|
||||
# header_up X-Script-Name {{ .ingress_entry }}
|
||||
# trusted_proxies {{ .supervisor_ip }}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# :8099 {
|
||||
# @ingress {
|
||||
# remote_ip {{ .supervisor_ip }}
|
||||
# }
|
||||
# uri strip_prefix {{ .ingress_entry }}
|
||||
#
|
||||
# handle_path /camera/* {
|
||||
# reverse_proxy @ingress {{ .camera_host }} {
|
||||
# }
|
||||
# }
|
||||
# handle {
|
||||
# {{ if eq .mode "camera" }}
|
||||
# reverse_proxy @ingress {{ .camera_host }} {
|
||||
# trusted_proxies 172.30.32.2
|
||||
# }
|
||||
# {{ else if eq .mode "recovery" }}
|
||||
# rewrite / /recovery
|
||||
# {{ else if eq .mode "reverse_proxy_test" }}
|
||||
# rewrite / /reverse_proxy_test
|
||||
# {{ end }}
|
||||
# reverse_proxy @ingress 127.0.0.1:80 {
|
||||
# header_up X-Script-Name {{ .ingress_entry }}
|
||||
# trusted_proxies 172.30.32.2
|
||||
# # header_up -Origin
|
||||
# # header_up Origin 172.30.32.2
|
||||
# # header_up X-Forwarded-For 172.30.32.2
|
||||
# # header_up X-Scheme {scheme}
|
||||
# # flush_interval -1
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
@@ -0,0 +1,8 @@
|
||||
# Internal and external access. Used for:
|
||||
# * Home-Assistant OctoPrint integration.
|
||||
# * Accessing OctoPrint WebUI through external port.
|
||||
:5000 {
|
||||
reverse_proxy http://127.0.0.1:80 {
|
||||
trusted_proxies {{ .trusted_proxies }}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user