Cleanup octoprint for testing
This commit is contained in:
parent
774bd3b18d
commit
08aa3cd32a
@ -1,36 +1,24 @@
|
||||
{
|
||||
"name": "Example devcontainer for add-on repositories",
|
||||
"image": "ghcr.io/home-assistant/devcontainer:addons",
|
||||
"appPort": [
|
||||
"7123:8123",
|
||||
"7357:4357"
|
||||
],
|
||||
"postStartCommand": "sudo -E bash devcontainer_bootstrap",
|
||||
"runArgs": [
|
||||
"-e",
|
||||
"GIT_EDITOR=code --wait",
|
||||
"--privileged"
|
||||
],
|
||||
"containerEnv": {
|
||||
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
|
||||
},
|
||||
"extensions": [
|
||||
"timonwong.shellcheck",
|
||||
"esbenp.prettier-vscode"
|
||||
],
|
||||
"mounts": [
|
||||
"type=volume,target=/var/lib/docker"
|
||||
],
|
||||
"settings": {
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"zsh": {
|
||||
"path": "/usr/bin/zsh"
|
||||
}
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "zsh",
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
||||
{
|
||||
"name": "Example devcontainer for add-on repositories",
|
||||
"image": "ghcr.io/home-assistant/devcontainer:addons",
|
||||
"appPort": ["7123:8123", "7357:4357"],
|
||||
"postStartCommand": "bash devcontainer_bootstrap",
|
||||
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
|
||||
"containerEnv": {
|
||||
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
|
||||
},
|
||||
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
|
||||
"mounts": [ "type=volume,target=/var/lib/docker" ],
|
||||
"settings": {
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"zsh": {
|
||||
"path": "/usr/bin/zsh"
|
||||
}
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "zsh",
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,15 @@
|
||||
# Addon configuration
|
||||
|
||||
## Camera URL
|
||||
|
||||
**Note: Currently not working.**
|
||||
|
||||
Through setting a camera URL you should be able to access the camera stream even when using Ingress.
|
||||
|
||||
## Mode
|
||||
|
||||
By specifying a different mode you can instead access recovery and reverse proy test page. Normally this should not be needed.
|
||||
|
||||
# Notes etc.
|
||||
|
||||
> image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch}
|
||||
> image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-octoprint-{arch}
|
||||
|
||||
## Camera URL
|
||||
|
||||
**Note: Currently not used.**
|
||||
|
||||
Through setting a camera URL you should be able to access the camera stream even when using Ingress.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# 3DPrinter-OctoPrint
|
||||
|
||||
**Note: Currently not in a ready-to-use state.**
|
||||
|
||||
Provides OctoPrint as an addon to Home Assistant.
|
||||
|
||||
Note: Ingress is **NOT** supported.
|
||||
|
||||
@ -9,4 +9,4 @@ labels:
|
||||
org.opencontainers.image.description: "3DPrinter-OctoPrint addon for Home-Assistant."
|
||||
org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons"
|
||||
args:
|
||||
OCTOPRINT_VERSION: "1.7.3"
|
||||
OCTOPRINT_VERSION: "1.8.6"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: "3DPrinter-OctoPrint"
|
||||
version: "2022.12.05"
|
||||
version: "2023.01.0"
|
||||
slug: "3dprinter-octoprint"
|
||||
description: "OctoPrint as an addon, no additional bells and whistles."
|
||||
url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint"
|
||||
@ -22,7 +22,7 @@ usb: true
|
||||
ports:
|
||||
5000/tcp: null
|
||||
ports_description:
|
||||
5000/tcp: Web-based interface (Not required for Ingress)
|
||||
5000/tcp: Web-based interface
|
||||
options:
|
||||
camera_url: "http://b7aa59c4-camera-mjpg-streamer"
|
||||
mode: normal
|
||||
@ -32,4 +32,4 @@ schema:
|
||||
mode: "list(normal|recovery|reverse_proxy_test|camera)?"
|
||||
trusted_proxies: "str?"
|
||||
tmpfs: true
|
||||
image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch}
|
||||
# image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-octoprint-{arch}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
# Temporary file, will be overwritten on launch.
|
||||
{
|
||||
debug
|
||||
log {
|
||||
@ -6,3 +5,5 @@
|
||||
output file /var/log/caddy/caddy.log
|
||||
}
|
||||
}
|
||||
|
||||
import sites-enabled/*.caddy
|
||||
|
||||
0
3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitignore
vendored
Normal file
0
3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitignore
vendored
Normal file
@ -3,11 +3,12 @@
|
||||
# Prepare OctoPrint
|
||||
# s6-overlay docs: https://github.com/just-containers/s6-overlay
|
||||
# ==============================================================================
|
||||
export BASEDIR="--basedir /data/config/octoprint"
|
||||
|
||||
{ # Check if OctoPrint is installed.
|
||||
octoprint -b /data/config/octoprint --version
|
||||
octoprint $BASEDIR --version
|
||||
} || { # Otherwise install it.
|
||||
{ # Check if Python is available (at `/data/python/octoprint` according to PATH)
|
||||
{ # Check if Python is available (at `/data/python/octoprint`, according to PATH)
|
||||
python --version
|
||||
} || { # Otherwise create Python virtual environment.
|
||||
python3 -m venv /data/python/octoprint
|
||||
@ -17,23 +18,39 @@
|
||||
pip install octoprint==$OCTOPRINT_VERSION
|
||||
}
|
||||
|
||||
# Copy OctoPrint config to persistent storage, if missing.
|
||||
if [ ! -f /data/config/octoprint/config.yaml ]; then
|
||||
if [ -f /root/config/octoprint/config.yaml ]; then
|
||||
mkdir -p /data/config/octoprint
|
||||
cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml
|
||||
bashio::log.notice "Default OctoPrint config copied"
|
||||
else
|
||||
bashio::log.warning "Default OctoPrint config not found"
|
||||
fi
|
||||
fi
|
||||
|
||||
# { # 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."
|
||||
# }
|
||||
# Update OctoPrint config with settings used for the addon overall (could always be changed)
|
||||
function updateConfigRequired() {
|
||||
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 server.host "127.0.0.1"
|
||||
octoprint $BASEDIR config set --int server.port 80
|
||||
octoprint $BASEDIR config set webcam.ffmpeg "/usr/bin/ffmpeg"
|
||||
}
|
||||
|
||||
# Update OctoPrint config with customized settings, not strictly required for addon to work but helps with features.
|
||||
function 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.
|
||||
}
|
||||
|
||||
|
||||
# Create initial OctoPrint config, if missing.
|
||||
if [ ! -f /data/config/octoprint/config.yaml ]; then
|
||||
mkdir -p /data/config/octoprint
|
||||
updateConfigRequired
|
||||
fi
|
||||
|
||||
@ -1,10 +1,23 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Configures proxy
|
||||
# ==============================================================================
|
||||
# #!/usr/bin/with-contenv bashio
|
||||
# # ==============================================================================
|
||||
# # Add-on: 3dprinter-octoprint
|
||||
# # Configures proxy
|
||||
# # ==============================================================================
|
||||
|
||||
# Generate proxy configuration for Ingress
|
||||
# Generate proxy configuration for any access
|
||||
bashio::var.json \
|
||||
| tempio \
|
||||
-template /usr/share/tempio/caddy/Caddyfile.any.gtpl \
|
||||
-out /etc/caddy/sites-enabled/any.caddy
|
||||
|
||||
# Generate proxy configuration for internal access
|
||||
bashio::var.json \
|
||||
internal_hostname "$(bashio::info.hostname)" \
|
||||
| tempio \
|
||||
-template /usr/share/tempio/caddy/Caddyfile.internal.gtpl \
|
||||
-out /etc/caddy/sites-enabled/internal.caddy
|
||||
|
||||
# Generate proxy configuration for Ingress access
|
||||
bashio::var.json \
|
||||
interface "$(bashio::addon.ip_address)" \
|
||||
port "^$(bashio::addon.ingress_port)" \
|
||||
@ -13,8 +26,8 @@ bashio::var.json \
|
||||
mode "$(bashio::config 'mode')" \
|
||||
trusted_proxies "$(bashio::config 'trusted_proxies')" \
|
||||
| tempio \
|
||||
-template /usr/share/tempio/caddy/Caddyfile.gtpl \
|
||||
-out /etc/caddy/Caddyfile
|
||||
-template /usr/share/tempio/caddy/Caddyfile.ingress.gtpl \
|
||||
-out /etc/caddy/sites-enabled/ingress.caddy
|
||||
|
||||
# Make sure file is correctly formatted.
|
||||
caddy fmt --overwrite /etc/caddy/Caddyfile
|
||||
# # Make sure file is correctly formatted.
|
||||
# caddy fmt --overwrite /etc/caddy/Caddyfile
|
||||
|
||||
@ -7,4 +7,4 @@
|
||||
bashio::log.info "Starting OctoPrint..."
|
||||
|
||||
## Run your program
|
||||
exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 80 --basedir /data/config/octoprint
|
||||
exec octoprint --basedir /data/config/octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 80
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
# Runs the reverse proxy.
|
||||
# ==============================================================================
|
||||
|
||||
# Wait for web server to be available
|
||||
# Wait for OctoPrint WebUI to be available
|
||||
bashio::net.wait_for 80
|
||||
|
||||
bashio::log.info "Starting proxy..."
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
# OctoPrint WebUI through external access
|
||||
:5000 {
|
||||
reverse_proxy http://127.0.0.1:80 {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
# WebUI through internal hostname
|
||||
{{ .internal_hostname }}:5000 {
|
||||
reverse_proxy http://127.0.0.1:80 {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user