mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-07 16:15:55 +02:00
new version nobuild
This commit is contained in:
21
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/init-nginx/run
Normal file
21
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/init-nginx/run
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Vaultwarden
|
||||
# This file configures NGINX
|
||||
# ==============================================================================
|
||||
declare certfile
|
||||
declare keyfile
|
||||
|
||||
bashio::config.require.ssl
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
|
||||
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
||||
sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
|
||||
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
|
||||
else
|
||||
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
||||
fi
|
||||
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/init-nginx/type
Normal file
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/init-nginx/type
Normal file
@@ -0,0 +1 @@
|
||||
oneshot
|
||||
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/init-nginx/up
Normal file
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/init-nginx/up
Normal file
@@ -0,0 +1 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-nginx/run
|
||||
26
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish
Normal file
26
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Vaultwarden
|
||||
# Take down the S6 supervision tree when Nginx fails
|
||||
# ==============================================================================
|
||||
declare exit_code
|
||||
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
|
||||
readonly exit_code_service="${1}"
|
||||
readonly exit_code_signal="${2}"
|
||||
readonly service="NGINX"
|
||||
|
||||
bashio::log.info \
|
||||
"Service ${service} exited with code ${exit_code_service}" \
|
||||
"(by signal ${exit_code_signal})"
|
||||
|
||||
if [[ "${exit_code_service}" -eq 256 ]]; then
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
|
||||
elif [[ "${exit_code_service}" -ne 0 ]]; then
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
exec /run/s6/basedir/bin/halt
|
||||
fi
|
||||
9
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Normal file
9
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Vaultwarden
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
bashio::net.wait_for 80
|
||||
bashio::log.info "Starting NGinx..."
|
||||
|
||||
exec nginx
|
||||
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/nginx/type
Normal file
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/nginx/type
Normal file
@@ -0,0 +1 @@
|
||||
longrun
|
||||
27
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/vaultwarden/finish
Normal file
27
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/vaultwarden/finish
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Vaultwarden
|
||||
# Take down the S6 supervision tree when the server fails
|
||||
# ==============================================================================
|
||||
declare exit_code
|
||||
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
|
||||
readonly exit_code_service="${1}"
|
||||
readonly exit_code_signal="${2}"
|
||||
readonly service="Vaultwarden"
|
||||
|
||||
bashio::log.info \
|
||||
"Service ${service} exited with code ${exit_code_service}" \
|
||||
"(by signal ${exit_code_signal})"
|
||||
|
||||
if [[ "${exit_code_service}" -eq 256 ]]; then
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
|
||||
elif [[ "${exit_code_service}" -ne 0 ]]; then
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
exec /run/s6/basedir/bin/halt
|
||||
fi
|
||||
78
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/vaultwarden/run
Normal file
78
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/vaultwarden/run
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Vaultwarden
|
||||
# Runs the Vaultwarden server
|
||||
# ==============================================================================
|
||||
declare admin_token
|
||||
declare log_level
|
||||
declare request_size_limit
|
||||
declare secret_key
|
||||
|
||||
# Set defaults
|
||||
export DATA_FOLDER=/data
|
||||
export ROCKET_PORT=80
|
||||
export ROCKET_WORKERS=2
|
||||
|
||||
# Set a random secret, to remove confusing warning from logs.
|
||||
secret_key=$(openssl rand -base64 32)
|
||||
export ROCKET_SECRET_KEY="${secret_key}"
|
||||
|
||||
# Find the matching log level
|
||||
if bashio::config.has_value 'log_level'; then
|
||||
case "$(bashio::string.lower "$(bashio::config 'log_level')")" in
|
||||
all|trace)
|
||||
log_level="trace"
|
||||
;;
|
||||
debug)
|
||||
log_level="debug"
|
||||
;;
|
||||
info|notice)
|
||||
log_level="info"
|
||||
;;
|
||||
warning)
|
||||
log_level="warn"
|
||||
;;
|
||||
error|fatal)
|
||||
log_level="error"
|
||||
;;
|
||||
off)
|
||||
log_level="off"
|
||||
;;
|
||||
esac
|
||||
|
||||
export LOG_LEVEL="${log_level}"
|
||||
fi
|
||||
|
||||
# Show admin token in the log, if config does not exist.
|
||||
if ! bashio::fs.file_exists '/data/config.json'; then
|
||||
admin_token=$(openssl rand -base64 48)
|
||||
export ADMIN_TOKEN="${admin_token}"
|
||||
|
||||
bashio::log.info
|
||||
bashio::log.info
|
||||
bashio::log.info "READ THIS CAREFULLY! READ THIS CAREFULLY!"
|
||||
bashio::log.info
|
||||
bashio::log.info
|
||||
bashio::log.info "This is your temporary random admin token/password!"
|
||||
bashio::log.info
|
||||
bashio::log.info "${admin_token}"
|
||||
bashio::log.info
|
||||
bashio::log.info "Be sure to change it in the admin panel, as soon as possible."
|
||||
bashio::log.info
|
||||
bashio::log.info "After you have changed ANY setting in the admin panel,"
|
||||
bashio::log.info "the add-on will NOT generate a new token on each start"
|
||||
bashio::log.info "and stops showing this message."
|
||||
bashio::log.info
|
||||
fi
|
||||
|
||||
# API request size limit
|
||||
if bashio::config.has_value 'request_size_limit'; then
|
||||
request_size_limit=$(bashio::config 'request_size_limit')
|
||||
export ROCKET_LIMITS="{json=${request_size_limit}}"
|
||||
fi
|
||||
|
||||
# Run the Bitwarden server
|
||||
bashio::log.info 'Starting the Vaultwarden server...'
|
||||
cd /opt || bashio::exit.nok
|
||||
exec ./vaultwarden
|
||||
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/vaultwarden/type
Normal file
1
bitwarden/rootfs/etc/s6-overlay/s6-rc.d/vaultwarden/type
Normal file
@@ -0,0 +1 @@
|
||||
longrun
|
||||
Reference in New Issue
Block a user