add portainer

This commit is contained in:
Alexandre
2021-05-06 11:56:56 +02:00
parent e952501425
commit db0efa997b
11 changed files with 468 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
#!/usr/bin/env bashio
##################
# DEFINE OPTIONS #
##################
declare -a options
options+=(--data /data)
options+=(--bind 0.0.0.0:9000)
options+=(--templates /opt/portainer/templates.json)
options+=(--host unix:///var/run/docker.sock)
bashio::log.info "Starting Portainer..."
################
# SET PASSWORD #
################
PASSWORD=$(bashio::config 'password')
echo -n $PASSWORD > /tmp/portainer_password
options+=(--admin-password-file /tmp/portainer_password)
bashio::log.info "... password set to $PASSWORD"
##############
# SSL CONFIG #
##############
bashio::config.require.ssl
if bashio::config.true 'ssl'; then
bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths"
#set variables
CERTFILE="/ssl/$(bashio::config 'certfile')"
KEYFILE="/ssl/$(bashio::config 'keyfile')"
options+=(--ssl true)
options+=(--sslcert /ssl/$CERTFILE)
options+=(--sslkey /ssl/$KEYFILE)
bashio::log.info "... ssl activated"
fi
###################
# HIDE CONTAINERS #
###################
# Hide Hassio containers by default, but only eforce on first run
if ! bashio::fs.file_exists "/data/hidden"; then
options+=(--hide-label io.hass.type=supervisor)
options+=(--hide-label io.hass.type=homeassistant)
options+=(--hide-label io.hass.type=base)
options+=(--hide-label io.hass.type=core)
# options+=(--hide-label io.hass.type=addon)
options+=(--hide-label io.hass.type=audio)
options+=(--hide-label io.hass.type=cli)
options+=(--hide-label io.hass.type=dns)
options+=(--hide-label io.hass.type=multicast)
options+=(--hide-label io.hass.type=observer)
bashio::log.info "... non-addon containers hidden"
touch /data/hidden
fi
####################
# LAUNCH PORTAINER #
####################
bashio::log.info "... portainer launched"
exec /opt/portainer/portainer "${options[@]}"

View File

@@ -0,0 +1,6 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: Portainer
# Runs some initializations for Portainer
# ==============================================================================
bashio::require.unprotected

View File

@@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Home Assistant Community Add-on: Portainer
# Take down the S6 supervision tree when Portainer fails
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View File

@@ -0,0 +1,64 @@
#!/usr/bin/env bashio
##################
# DEFINE OPTIONS #
##################
declare -a options
options+=(--data /data)
options+=(--bind 0.0.0.0:9000)
options+=(--templates /opt/portainer/templates.json)
options+=(--host unix:///var/run/docker.sock)
bashio::log.info "Starting Portainer..."
################
# SET PASSWORD #
################
PASSWORD=$(bashio::config 'password')
echo -n $PASSWORD > /tmp/portainer_password
options+=(--admin-password-file /tmp/portainer_password)
bashio::log.info "... password set to $PASSWORD"
##############
# SSL CONFIG #
##############
bashio::config.require.ssl
if bashio::config.true 'ssl'; then
bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths"
#set variables
CERTFILE="/ssl/$(bashio::config 'certfile')"
KEYFILE="/ssl/$(bashio::config 'keyfile')"
options+=(--ssl true)
options+=(--sslcert /ssl/$CERTFILE)
options+=(--sslkey /ssl/$KEYFILE)
bashio::log.info "... ssl activated"
fi
###################
# HIDE CONTAINERS #
###################
# Hide Hassio containers by default, but only eforce on first run
if ! bashio::fs.file_exists "/data/hidden"; then
options+=(--hide-label io.hass.type=supervisor)
options+=(--hide-label io.hass.type=homeassistant)
options+=(--hide-label io.hass.type=base)
options+=(--hide-label io.hass.type=core)
# options+=(--hide-label io.hass.type=addon)
options+=(--hide-label io.hass.type=audio)
options+=(--hide-label io.hass.type=cli)
options+=(--hide-label io.hass.type=dns)
options+=(--hide-label io.hass.type=multicast)
options+=(--hide-label io.hass.type=observer)
bashio::log.info "... non-addon containers hidden"
touch /data/hidden
fi
####################
# LAUNCH PORTAINER #
####################
bashio::log.info "... portainer launched"
exec /opt/portainer/portainer "${options[@]}"