mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
align to cont-init.d
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# If dockerfile failed install manually
|
||||
if [ -e "/MODULESFILE" ]; then
|
||||
echo "Executing modules script"
|
||||
PACKAGES=$(</MODULESFILE)
|
||||
(
|
||||
##############################
|
||||
# Automatic modules download #
|
||||
##############################
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); fi &&
|
||||
if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl); fi &&
|
||||
mkdir -p /tmpscripts /etc/cont-init.d &&
|
||||
for scripts in $MODULES; do curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/$scripts" -o /tmpscripts/"$scripts"; done &&
|
||||
if [ -d /etc/cont-init.d ]; then /bin/cp -rf /tmpscripts/* /etc/cont-init.d/ && chmod -R 755 /etc/cont-init.d; fi &&
|
||||
rm -rf /tmpscripts || printf '%s\n' "${MODULES:-}" >/MODULESFILE
|
||||
) >/dev/null
|
||||
|
||||
fi
|
||||
|
||||
if [ -e "/ENVFILE" ]; then
|
||||
echo "Executing script"
|
||||
PACKAGES=$(</ENVFILE)
|
||||
(
|
||||
#######################
|
||||
# Automatic installer #
|
||||
#######################
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); fi &&
|
||||
if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl); fi &&
|
||||
curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh &&
|
||||
chmod 777 /automatic_packages.sh &&
|
||||
eval /./automatic_packages.sh "$PACKAGES" &&
|
||||
rm /automatic_packages.sh
|
||||
) >/dev/null
|
||||
|
||||
fi
|
||||
53
cloudcommander/rootfs/etc/cont-init.d/99-run.sh
Normal file
53
cloudcommander/rootfs/etc/cont-init.d/99-run.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bashio
|
||||
|
||||
#################
|
||||
# NGINX SETTING #
|
||||
#################
|
||||
|
||||
declare port
|
||||
declare certfile
|
||||
declare ingress_interface
|
||||
declare ingress_port
|
||||
declare keyfile
|
||||
|
||||
CLOUDCMD_PREFIX=$(bashio::addon.ingress_entry)
|
||||
export CLOUDCMD_PREFIX
|
||||
|
||||
declare ADDON_PROTOCOL=http
|
||||
if bashio::config.true 'ssl'; then
|
||||
ADDON_PROTOCOL=https
|
||||
bashio::config.require.ssl
|
||||
fi
|
||||
|
||||
port=$(bashio::addon.port 80)
|
||||
ingress_port=$(bashio::addon.ingress_port)
|
||||
ingress_interface=$(bashio::addon.ip_address)
|
||||
sed -i "s|%%protocol%%|${ADDON_PROTOCOL}|g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s|%%port%%|${ingress_port}|g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s|%%interface%%|${ingress_interface}|g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s|%%subpath%%|${CLOUDCMD_PREFIX}/|g" /etc/nginx/servers/ingress.conf
|
||||
mkdir -p /var/log/nginx && touch /var/log/nginx/error.log
|
||||
|
||||
###############
|
||||
# LAUNCH APPS #
|
||||
###############
|
||||
|
||||
if bashio::config.has_value 'CUSTOM_OPTIONS'; then
|
||||
CUSTOMOPTIONS=" $(bashio::config 'CUSTOM_OPTIONS')"
|
||||
else
|
||||
CUSTOMOPTIONS=""
|
||||
fi
|
||||
|
||||
if bashio::config.has_value 'DROPBOX_TOKEN'; then
|
||||
DROPBOX_TOKEN="--dropbox --dropbox-token $(bashio::config 'DROPBOX_TOKEN')"
|
||||
else
|
||||
DROPBOX_TOKEN=""
|
||||
fi
|
||||
|
||||
bashio::log.info "Starting..."
|
||||
|
||||
cd /
|
||||
./usr/src/app/bin/cloudcmd.mjs '"'$DROPBOX_TOKEN$CUSTOMOPTIONS'"' &
|
||||
bashio::net.wait_for 8000 localhost 900 || true
|
||||
bashio::log.info "Started !"
|
||||
exec nginx
|
||||
Reference in New Issue
Block a user