mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-18 14:51:50 +02: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
|
||||
15
filebrowser/rootfs/etc/cont-init.d/20-folders.sh
Normal file
15
filebrowser/rootfs/etc/cont-init.d/20-folders.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
if [ -d /config/filebrowser ]; then
|
||||
echo "Moving to new location /config/addons_config/filebrowser"
|
||||
mkdir -p /config/addons_config/filebrowser
|
||||
chmod 777 /config/addons_config/filebrowser
|
||||
mv /config/filebrowser/* /config/addons_config/filebrowser/
|
||||
rm -r /config/filebrowser
|
||||
fi
|
||||
|
||||
if [ ! -d /config/addons_config/filebrowser ]; then
|
||||
echo "Creating /config/addons_config/filebrowser"
|
||||
mkdir -p /config/addons_config/filebrowser
|
||||
chmod 777 /config/addons_config/filebrowser
|
||||
fi
|
||||
89
filebrowser/rootfs/etc/cont-init.d/99-run.sh
Normal file
89
filebrowser/rootfs/etc/cont-init.d/99-run.sh
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bashio
|
||||
|
||||
###################
|
||||
# SSL CONFIG v1.0 #
|
||||
###################
|
||||
|
||||
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="-t /ssl/$(bashio::config 'certfile')"
|
||||
KEYFILE="-k /ssl/$(bashio::config 'keyfile')"
|
||||
else
|
||||
CERTFILE=""
|
||||
KEYFILE=""
|
||||
fi
|
||||
|
||||
####################
|
||||
# SET UID GID v1.0 #
|
||||
####################
|
||||
bashio::log.info 'PUID GUID set to root'
|
||||
PUID=0
|
||||
PGID=0
|
||||
|
||||
#################
|
||||
# NGINX SETTING #
|
||||
#################
|
||||
|
||||
declare port
|
||||
declare certfile
|
||||
declare ingress_interface
|
||||
declare ingress_port
|
||||
declare keyfile
|
||||
|
||||
FB_BASEURL=$(bashio::addon.ingress_entry)
|
||||
export FB_BASEURL
|
||||
|
||||
declare ADDON_PROTOCOL=http
|
||||
# Generate Ingress configuration
|
||||
if bashio::config.true 'ssl'; then
|
||||
ADDON_PROTOCOL=https
|
||||
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%%|${FB_BASEURL}/|g" /etc/nginx/servers/ingress.conf
|
||||
mkdir -p /var/log/nginx && touch /var/log/nginx/error.log
|
||||
|
||||
######################
|
||||
# LAUNCH FILEBROWSER #
|
||||
######################
|
||||
|
||||
NOAUTH=""
|
||||
|
||||
if bashio::config.true 'NoAuth'; then
|
||||
if ! bashio::fs.file_exists "/data/noauth"; then
|
||||
rm /data/auth &>/dev/null || true
|
||||
rm /config/addons_config/filebrowser/filebrowser.dB &>/dev/null || true
|
||||
touch /data/noauth
|
||||
NOAUTH="--noauth"
|
||||
bashio::log.warning "Auth method change, database reset"
|
||||
fi
|
||||
bashio::log.info "NoAuth option selected"
|
||||
else
|
||||
if ! bashio::fs.file_exists "/data/auth"; then
|
||||
rm /data/noauth &>/dev/null || true
|
||||
rm /config/addons_config/filebrowser/filebrowser.dB &>/dev/null || true
|
||||
touch /data/auth
|
||||
bashio::log.warning "Auth method change, database reset"
|
||||
fi
|
||||
bashio::log.info "Default username/password : admin/admin"
|
||||
fi
|
||||
|
||||
if bashio::config.has_value 'base_folder'; then
|
||||
BASE_FOLDER=$(bashio::config 'base_folder')
|
||||
else
|
||||
BASE_FOLDER=/
|
||||
fi
|
||||
|
||||
bashio::log.info "Starting..."
|
||||
|
||||
/./filebrowser $CERTFILE $KEYFILE --root=$BASE_FOLDER --address=0.0.0.0 --database=/config/addons_config/filebrowser/filebrowser.dB $NOAUTH &
|
||||
bashio::net.wait_for 8080 localhost 900 || true
|
||||
bashio::log.info "Started !"
|
||||
exec nginx
|
||||
Reference in New Issue
Block a user