mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 09:51:02 +01:00
Export variable to bashrc
This commit is contained in:
@@ -51,6 +51,7 @@ for KEYS in "${arr[@]}"; do
|
||||
if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi
|
||||
# For s6
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "${KEYS}=\"${VALUE}\"" >> ~/.bashrc; fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ while IFS= read -r line; do
|
||||
sed -i "1a export $KEYS=\'$VALUE\'" /scripts/*run* 2>/dev/null || true
|
||||
# Export to s6
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "${KEYS}=\"${VALUE}\"" >> ~/.bashrc; fi
|
||||
# Show in log
|
||||
if ! bashio::config.false "verbose"; then bashio::log.blue "$KEYS=\'$VALUE\'"; fi
|
||||
else
|
||||
|
||||
@@ -48,6 +48,10 @@ if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME
|
||||
printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME
|
||||
fi
|
||||
if [ -f ~/.bashrc ]; then
|
||||
printf "%s" "HOME=\"$LOCATION\"" >> ~/.bashrc
|
||||
printf "%s" "FM_HOME=\"$LOCATION\"" >> ~/.bashrc
|
||||
fi
|
||||
|
||||
usermod --home "$LOCATION" abc
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ if bashio::config.has_value 'KEYBOARD'; then
|
||||
bashio::log.info "Setting keyboard to $KEYBOARD"
|
||||
sed -i "1a export KEYBOARD=$KEYBOARD" /etc/s6-overlay/s6-rc.d/svc-web/run
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$KEYBOARD" > /var/run/s6/container_environment/KEYBOARD; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "KEYBOARD=\"$KEYBOARD\"" >> ~/.bashrc; fi
|
||||
fi || true
|
||||
|
||||
# Set cli args
|
||||
@@ -24,6 +25,7 @@ if bashio::config.has_value 'CLI_ARGS'; then
|
||||
bashio::log.info "Setting arguments to $CLI_ARGS"
|
||||
sed -i "1a export CLI_ARGS=$CLI_ARGS" /etc/s6-overlay/s6-rc.d/svc-web/run
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$CLI_ARGS" > /var/run/s6/container_environment/CLI_ARGS; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "CLI_ARGS=\"$CLI_ARGS\"" >> ~/.bashrc; fi
|
||||
fi || true
|
||||
|
||||
# Set password
|
||||
@@ -33,4 +35,5 @@ if bashio::config.has_value 'PASSWORD'; then
|
||||
bashio::log.info "Setting password to $PASSWORD"
|
||||
sed -i "1a export PASSWORD=$PASSWORD" /etc/s6-overlay/s6-rc.d/svc-web/run
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$PASSWORD" > /var/run/s6/container_environment/PASSWORD; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "PASSWORD=\"$PASSWORD\"" >> ~/.bashrc; fi
|
||||
fi || true
|
||||
|
||||
@@ -38,6 +38,8 @@ sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /etc/cont-init.d/*
|
||||
sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /etc/services.d/*/run
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME; fi
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "HOME=\"$LOCATION\"" >> ~/.bashrc; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "FM_HOME=\"$LOCATION\"" >> ~/.bashrc; fi
|
||||
|
||||
usermod --home "$LOCATION" abc
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ export IMMICH_MEDIA_LOCATION="$DATA_LOCATION"
|
||||
if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "$DATA_LOCATION" > /var/run/s6/container_environment/IMMICH_MEDIA_LOCATION
|
||||
fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "IMMICH_MEDIA_LOCATION=\"$DATA_LOCATION\"" >> ~/.bashrc; fi
|
||||
|
||||
echo "... check $DATA_LOCATION folder exists"
|
||||
mkdir -p "$DATA_LOCATION"
|
||||
|
||||
@@ -82,3 +82,11 @@ if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "$DB_HOSTNAME" > /var/run/s6/container_environment/DB_HOSTNAME
|
||||
printf "%s" "$JWT_SECRET" > /var/run/s6/container_environment/JWT_SECRET
|
||||
fi
|
||||
if [ -f ~/.bashrc ]; then
|
||||
printf "%s" "DB_USERNAME=\"$DB_USERNAME\"" >> ~/.bashrc
|
||||
printf "%s" "DB_PASSWORD=\"$DB_PASSWORD\"" >> ~/.bashrc
|
||||
printf "%s" "DB_DATABASE_NAME=\"$DB_DATABASE_NAME\"" >> ~/.bashrc
|
||||
printf "%s" "DB_PORT=\"$DB_PORT\"" >> ~/.bashrc
|
||||
printf "%s" "DB_HOSTNAME=\"$DB_HOSTNAME\"" >> ~/.bashrc
|
||||
printf "%s" "JWT_SECRET=\"$JWT_SECRET\"" >> ~/.bashrc
|
||||
fi
|
||||
|
||||
@@ -35,21 +35,24 @@ case $(bashio::config 'DB_TYPE') in
|
||||
PHOTOPRISM_DATABASE_USER="$(bashio::services 'mysql' 'username')"
|
||||
PHOTOPRISM_DATABASE_PASSWORD="$(bashio::services 'mysql' 'password')"
|
||||
export PHOTOPRISM_DATABASE_DRIVER && \
|
||||
sed -i "1a PHOTOPRISM_DATABASE_DRIVER=$PHOTOPRISM_DATABASE_DRIVER" /scripts/entrypoint.sh && \
|
||||
bashio::log.blue "PHOTOPRISM_DATABASE_DRIVER=$PHOTOPRISM_DATABASE_DRIVER"
|
||||
export PHOTOPRISM_DATABASE_SERVER && \
|
||||
sed -i "1a PHOTOPRISM_DATABASE_SERVER=$PHOTOPRISM_DATABASE_SERVER" /scripts/entrypoint.sh && \
|
||||
bashio::log.blue "PHOTOPRISM_DATABASE_SERVER=$PHOTOPRISM_DATABASE_SERVER"
|
||||
export PHOTOPRISM_DATABASE_NAME && \
|
||||
sed -i "1a PHOTOPRISM_DATABASE_NAME=$PHOTOPRISM_DATABASE_NAME" /scripts/entrypoint.sh && \
|
||||
bashio::log.blue "PHOTOPRISM_DATABASE_NAME=$PHOTOPRISM_DATABASE_NAME"
|
||||
export PHOTOPRISM_DATABASE_USER && \
|
||||
sed -i "1a PHOTOPRISM_DATABASE_USER=$PHOTOPRISM_DATABASE_USER" /scripts/entrypoint.sh && \
|
||||
bashio::log.blue "PHOTOPRISM_DATABASE_USER=$PHOTOPRISM_DATABASE_USER"
|
||||
export PHOTOPRISM_DATABASE_PASSWORD && \
|
||||
sed -i "1a PHOTOPRISM_DATABASE_PASSWORD=$PHOTOPRISM_DATABASE_PASSWORD" /scripts/entrypoint.sh && \
|
||||
bashio::log.blue "PHOTOPRISM_DATABASE_PASSWORD=$PHOTOPRISM_DATABASE_PASSWORD"
|
||||
|
||||
if [ -f ~/.bashrc ]; then
|
||||
printf "%s" "PHOTOPRISM_DATABASE_DRIVER=\"${PHOTOPRISM_DATABASE_DRIVER}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_DATABASE_SERVER=\"${PHOTOPRISM_DATABASE_SERVER}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_DATABASE_NAME=\"${PHOTOPRISM_DATABASE_NAME}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_DATABASE_USER=\"${PHOTOPRISM_DATABASE_USER}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_DATABASE_PASSWORD=\"${PHOTOPRISM_DATABASE_PASSWORD}\"" >> ~/.bashrc
|
||||
fi
|
||||
|
||||
bashio::log.warning "Photoprism is using the Maria DB addon"
|
||||
bashio::log.warning "Please ensure this is included in your backups"
|
||||
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
|
||||
@@ -74,7 +77,7 @@ if bashio::config.true "ingress_disabled"; then
|
||||
else
|
||||
PHOTOPRISM_SITE_URL="$(bashio::addon.ingress_entry)/"
|
||||
export PHOTOPRISM_SITE_URL
|
||||
sed -i "1a PHOTOPRISM_SITE_URL=$PHOTOPRISM_SITE_URL" /scripts/entrypoint.sh
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "PHOTOPRISM_SITE_URL=\"${PHOTOPRISM_SITE_URL}\"" >> ~/.bashrc; fi
|
||||
bashio::log.warning "Ingress is enabled. To connect, you must add $PHOTOPRISM_SITE_URL to the end of your access point. Example : http://my-url:8123$PHOTOPRISM_SITE_URL"
|
||||
fi
|
||||
|
||||
@@ -93,11 +96,13 @@ export PHOTOPRISM_STORAGE_PATH
|
||||
export PHOTOPRISM_ORIGINALS_PATH
|
||||
export PHOTOPRISM_IMPORT_PATH
|
||||
export PHOTOPRISM_BACKUP_PATH
|
||||
sed -i "1a PHOTOPRISM_UPLOAD_NSFW=$PHOTOPRISM_UPLOAD_NSFW" /scripts/entrypoint.sh
|
||||
sed -i "1a PHOTOPRISM_STORAGE_PATH=$PHOTOPRISM_STORAGE_PATH" /scripts/entrypoint.sh
|
||||
sed -i "1a PHOTOPRISM_ORIGINALS_PATH=$PHOTOPRISM_ORIGINALS_PATH" /scripts/entrypoint.sh
|
||||
sed -i "1a PHOTOPRISM_IMPORT_PATH=$PHOTOPRISM_IMPORT_PATH" /scripts/entrypoint.sh
|
||||
sed -i "1a PHOTOPRISM_BACKUP_PATH=$PHOTOPRISM_BACKUP_PATH" /scripts/entrypoint.sh
|
||||
if [ -f ~/.bashrc ]; then
|
||||
printf "%s" "PHOTOPRISM_UPLOAD_NSFW=\"${PHOTOPRISM_UPLOAD_NSFW}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_STORAGE_PATH=\"${PHOTOPRISM_STORAGE_PATH}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_ORIGINALS_PATH=\"${PHOTOPRISM_ORIGINALS_PATH}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_IMPORT_PATH=\"${PHOTOPRISM_IMPORT_PATH}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_BACKUP_PATH=\"${PHOTOPRISM_BACKUP_PATH}\"" >> ~/.bashrc
|
||||
fi
|
||||
|
||||
# Test configs
|
||||
for variabletest in $PHOTOPRISM_STORAGE_PATH $PHOTOPRISM_ORIGINALS_PATH $PHOTOPRISM_IMPORT_PATH $PHOTOPRISM_BACKUP_PATH; do
|
||||
@@ -121,6 +126,10 @@ if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then
|
||||
export PHOTOPRISM_GID="$PGID"
|
||||
sed -i "1a PHOTOPRISM_UID=$PHOTOPRISM_UID" /scripts/entrypoint.sh
|
||||
sed -i "1a PHOTOPRISM_GID=$PHOTOPRISM_GID" /scripts/entrypoint.sh
|
||||
if [ -f ~/.bashrc ]; then
|
||||
printf "%s" "PHOTOPRISM_UID=\"${PHOTOPRISM_UID}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_GID=\"${PHOTOPRISM_GID}\"" >> ~/.bashrc
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start messages
|
||||
|
||||
@@ -26,6 +26,13 @@ export PHOTOPRISM_STORAGE_PATH=$(bashio::config 'STORAGE_PATH')
|
||||
export PHOTOPRISM_ORIGINALS_PATH=$(bashio::config 'ORIGINALS_PATH')
|
||||
export PHOTOPRISM_IMPORT_PATH=$(bashio::config 'IMPORT_PATH')
|
||||
export PHOTOPRISM_BACKUP_PATH=$(bashio::config 'BACKUP_PATH')
|
||||
if [ -f ~/.bashrc ]; then
|
||||
printf "%s" "PHOTOPRISM_UPLOAD_NSFW=\"${PHOTOPRISM_UPLOAD_NSFW}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_STORAGE_PATH=\"${PHOTOPRISM_STORAGE_PATH}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_ORIGINALS_PATH=\"${PHOTOPRISM_ORIGINALS_PATH}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_IMPORT_PATH=\"${PHOTOPRISM_IMPORT_PATH}\"" >> ~/.bashrc
|
||||
printf "%s" "PHOTOPRISM_BACKUP_PATH=\"${PHOTOPRISM_BACKUP_PATH}\"" >> ~/.bashrc
|
||||
fi
|
||||
|
||||
if bashio::config.has_value 'CUSTOM_OPTIONS'; then
|
||||
CUSTOMOPTIONS=$(bashio::config 'CUSTOM_OPTIONS')
|
||||
|
||||
@@ -26,6 +26,7 @@ if [ -n "${RC_SVCNAME}" ]; then
|
||||
if /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
|
||||
export IN_BACKGROUND=true
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "true" > /var/run/s6/container_environment/IN_BACKGROUND; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "IN_BACKGROUND=\"true\"" >> ~/.bashrc; fi
|
||||
/etc/init.d/"${RC_SVCNAME}" --quiet stop
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -79,6 +79,7 @@ if [ -n "${RC_SVCNAME}" ]; then
|
||||
if ! /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
|
||||
export IN_BACKGROUND=true
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "true" > /var/run/s6/container_environment/IN_BACKGROUND; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "IN_BACKGROUND=\"true\"" >> ~/.bashrc; fi
|
||||
/etc/init.d/${RC_SVCNAME} --quiet start
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -41,6 +41,7 @@ if [[ "$(bashio::config "Mode")" == Collector ]]; then
|
||||
echo "export COLLECTOR_API_ENDPOINT=$(bashio::config "COLLECTOR_API_ENDPOINT")" >> /env.sh
|
||||
sed -i "1a export COLLECTOR_API_ENDPOINT=$(bashio::config "COLLECTOR_API_ENDPOINT")" /etc/services.d/collector-once/run
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$COLLECTOR_API_ENDPOINT" > /var/run/s6/container_environment/COLLECTOR_API_ENDPOINT; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "IN_BACKGROUND=\"$COLLECTOR_API_ENDPOINT\"" >> ~/.bashrc; fi
|
||||
bashio::log.info "Using 'COLLECTOR_API_ENDPOINT' $(bashio::config "COLLECTOR_API_ENDPOINT")"
|
||||
else
|
||||
bashio::exit.nok "Mode is set to 'Collector', but 'COLLECTOR_API_ENDPOINT' is not defined"
|
||||
|
||||
@@ -63,5 +63,6 @@ if bashio::config.has_value 'customUI' && [ ! "$CUSTOMUI" = default ] && [ ! "$C
|
||||
# Define variable
|
||||
if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export TRANSMISSION_WEB_HOME=$CUSTOMUI" /etc/services.d/*/*run* 2>/dev/null; fi
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$CUSTOMUI" > /var/run/s6/container_environment/TRANSMISSION_WEB_HOME; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "TRANSMISSION_WEB_HOME=\"$CUSTOMUI\"" >> ~/.bashrc; fi
|
||||
|
||||
fi
|
||||
|
||||
@@ -41,6 +41,8 @@ sed -i "s|/share/webtop_kde|$LOCATION|g" $(find /etc/services.d -type f) || true
|
||||
sed -i "s|/share/webtop_kde|$LOCATION|g" $(find /etc/s6-overlay/s6-rc.d -type f) || true
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME; fi
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "HOME=\"$LOCATION\"" >> ~/.bashrc; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "FM_HOME=\"$LOCATION\"" >> ~/.bashrc; fi
|
||||
|
||||
usermod --home "$LOCATION" abc
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ if bashio::config.has_value 'KEYBOARD'; then
|
||||
bashio::log.info "Setting keyboard to $KEYBOARD"
|
||||
sed -i "1a export KEYBOARD=$KEYBOARD" /etc/s6-overlay/s6-rc.d/svc-web/run
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$KEYBOARD" > /var/run/s6/container_environment/KEYBOARD; fi
|
||||
if [ -f ~/.bashrc ]; then printf "%s" "KEYBOARD=\"$KEYBOARD\"" >> ~/.bashrc; fi
|
||||
fi
|
||||
|
||||
# Set password
|
||||
|
||||
Reference in New Issue
Block a user