mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 09:51:02 +01:00
fix: auto-fix linting issues
This commit is contained in:
committed by
github-actions[bot]
parent
3539f328fb
commit
f5428e0950
@@ -4,10 +4,10 @@
|
||||
slug=paperless_ng
|
||||
|
||||
if [ -d "/homeassistant/addons_config/$slug" ]; then
|
||||
echo "Migrating /homeassistant/addons_config/$slug"
|
||||
mv /homeassistant/addons_config/"$slug"/media /config/ || true
|
||||
mv /homeassistant/addons_config/"$slug"/consume /config/ || true
|
||||
mkdir -p /config/data
|
||||
mv /homeassistant/addons_config/"$slug"/* /config/data/ || true
|
||||
rm -r /homeassistant/addons_config/"$slug"
|
||||
echo "Migrating /homeassistant/addons_config/$slug"
|
||||
mv /homeassistant/addons_config/"$slug"/media /config/ || true
|
||||
mv /homeassistant/addons_config/"$slug"/consume /config/ || true
|
||||
mkdir -p /config/data
|
||||
mv /homeassistant/addons_config/"$slug"/* /config/data/ || true
|
||||
rm -r /homeassistant/addons_config/"$slug"
|
||||
fi
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
# Validate ssl
|
||||
bashio::config.require.ssl
|
||||
# Validate ssl
|
||||
bashio::config.require.ssl
|
||||
|
||||
# Adapt nginx template
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
|
||||
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
|
||||
# Adapt nginx template
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
|
||||
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
|
||||
|
||||
# Configure URL
|
||||
if bashio::config.has_value "PAPERLESS_URL"; then
|
||||
bashio::log.warning "Ssl enabled, your site will be available at $(bashio::config "PAPERLESS_URL"). Don't forget to enable the https alternative port in the addon options."
|
||||
else
|
||||
bashio::log.fatal "PAPERLESS_URL not set, you won't be able to access your site (CSRF error)"
|
||||
fi
|
||||
# Configure URL
|
||||
if bashio::config.has_value "PAPERLESS_URL"; then
|
||||
bashio::log.warning "Ssl enabled, your site will be available at $(bashio::config "PAPERLESS_URL"). Don't forget to enable the https alternative port in the addon options."
|
||||
else
|
||||
bashio::log.fatal "PAPERLESS_URL not set, you won't be able to access your site (CSRF error)"
|
||||
fi
|
||||
|
||||
else
|
||||
sed -i "s|default_server ssl|default_server|g" /etc/nginx/servers/direct.conf
|
||||
sed -i "/ssl/d" /etc/nginx/servers/direct.conf
|
||||
sed -i "s|default_server ssl|default_server|g" /etc/nginx/servers/direct.conf
|
||||
sed -i "/ssl/d" /etc/nginx/servers/direct.conf
|
||||
fi
|
||||
|
||||
@@ -16,8 +16,8 @@ if bashio::config.has_value "PGID"; then export USERMAP_GID="$(bashio::config "P
|
||||
if bashio::config.has_value "TZ"; then export PAPERLESS_TIME_ZONE="$(bashio::config "TZ")"; fi
|
||||
if bashio::config.has_value "PAPERLESS_URL"; then export PAPERLESS_URL="$(bashio::config "PAPERLESS_URL")"; fi
|
||||
if bashio::config.has_value "OCRLANG"; then
|
||||
PAPERLESS_OCR_LANGUAGES="$(bashio::config "OCRLANG")"
|
||||
export PAPERLESS_OCR_LANGUAGES="${PAPERLESS_OCR_LANGUAGES,,}"
|
||||
PAPERLESS_OCR_LANGUAGES="$(bashio::config "OCRLANG")"
|
||||
export PAPERLESS_OCR_LANGUAGES="${PAPERLESS_OCR_LANGUAGES,,}"
|
||||
fi
|
||||
if bashio::config.has_value "PAPERLESS_OCR_MODE"; then export PAPERLESS_OCR_MODE="$(bashio::config "PAPERLESS_OCR_MODE")"; fi
|
||||
if bashio::config.has_value "PAPERLESS_DATA_DIR"; then export PAPERLESS_DATA_DIR="$(bashio::config "PAPERLESS_DATA_DIR")"; fi
|
||||
@@ -28,10 +28,10 @@ if bashio::config.has_value "PAPERLESS_EXPORT_DIR"; then export PAPERLESS_EXPORT
|
||||
# Create folder and permissions if needed
|
||||
chown -R paperless:paperless /config
|
||||
for variable in "$PAPERLESS_DATA_DIR" "$PAPERLESS_MEDIA_ROOT" "$PAPERLESS_CONSUMPTION_DIR" "$PAPERLESS_EXPORT_DIR"; do
|
||||
echo "Creating directory \"$variable\""
|
||||
mkdir -p "$variable"
|
||||
chmod -R 755 "$variable"
|
||||
chown -R paperless:paperless "$variable"
|
||||
echo "Creating directory \"$variable\""
|
||||
mkdir -p "$variable"
|
||||
chmod -R 755 "$variable"
|
||||
chown -R paperless:paperless "$variable"
|
||||
done
|
||||
|
||||
###################
|
||||
@@ -42,37 +42,37 @@ bashio::log.info "Defining database"
|
||||
|
||||
case "$(bashio::config 'database')" in
|
||||
|
||||
# Use mariadb
|
||||
mariadb_addon)
|
||||
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..."
|
||||
if ! bashio::services.available 'mysql'; then
|
||||
bashio::log.fatal \
|
||||
"Local database access should be provided by the MariaDB addon"
|
||||
bashio::exit.nok \
|
||||
"Please ensure it is installed and started"
|
||||
fi
|
||||
# Use mariadb
|
||||
mariadb_addon)
|
||||
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..."
|
||||
if ! bashio::services.available 'mysql'; then
|
||||
bashio::log.fatal \
|
||||
"Local database access should be provided by the MariaDB addon"
|
||||
bashio::exit.nok \
|
||||
"Please ensure it is installed and started"
|
||||
fi
|
||||
|
||||
# Use values
|
||||
export PAPERLESS_DBENGINE=mariadb
|
||||
export PAPERLESS_DBHOST="$(bashio::services 'mysql' 'host')"
|
||||
export PAPERLESS_DBPORT="$(bashio::services 'mysql' 'port')"
|
||||
export PAPERLESS_DBNAME=paperless
|
||||
export PAPERLESS_DBUSER="$(bashio::services "mysql" "username")"
|
||||
export PAPERLESS_DBPASS="$(bashio::services "mysql" "password")"
|
||||
# Use values
|
||||
export PAPERLESS_DBENGINE=mariadb
|
||||
export PAPERLESS_DBHOST="$(bashio::services 'mysql' 'host')"
|
||||
export PAPERLESS_DBPORT="$(bashio::services 'mysql' 'port')"
|
||||
export PAPERLESS_DBNAME=paperless
|
||||
export PAPERLESS_DBUSER="$(bashio::services "mysql" "username")"
|
||||
export PAPERLESS_DBPASS="$(bashio::services "mysql" "password")"
|
||||
|
||||
# Create database
|
||||
mysql --host="$PAPERLESS_DBHOST" --port="$PAPERLESS_DBPORT" --user="$PAPERLESS_DBUSER" --password="$PAPERLESS_DBPASS" -e"CREATE DATABASE IF NOT EXISTS $PAPERLESS_DBNAME;"
|
||||
# Create database
|
||||
mysql --host="$PAPERLESS_DBHOST" --port="$PAPERLESS_DBPORT" --user="$PAPERLESS_DBUSER" --password="$PAPERLESS_DBPASS" -e"CREATE DATABASE IF NOT EXISTS $PAPERLESS_DBNAME;"
|
||||
|
||||
# Informations
|
||||
bashio::log.warning "This addon 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"
|
||||
;;
|
||||
# Informations
|
||||
bashio::log.warning "This addon 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"
|
||||
;;
|
||||
|
||||
# Use sqlite
|
||||
*)
|
||||
bashio::log.info "Using sqlite as database driver"
|
||||
;;
|
||||
# Use sqlite
|
||||
*)
|
||||
bashio::log.info "Using sqlite as database driver"
|
||||
;;
|
||||
esac
|
||||
|
||||
set +u
|
||||
@@ -80,30 +80,30 @@ set +u
|
||||
# For all relevant variables
|
||||
for variable in PAPERLESS_DATA_DIR PAPERLESS_MEDIA_ROOT PAPERLESS_CONSUMPTION_DIR PAPERLESS_EXPORT_DIR USERMAP_UID USERMAP_GID PAPERLESS_TIME_ZONE PAPERLESS_URL PAPERLESS_OCR_LANGUAGES PAPERLESS_OCR_MODE PAPERLESS_ADMIN_PASSWORD PAPERLESS_ADMIN_USER PAPERLESS_DBENGINE PAPERLESS_DBHOST PAPERLESS_DBPORT PAPERLESS_DBNAME PAPERLESS_DBUSER PAPERLESS_DBPASS; do
|
||||
|
||||
# Skip if not defined
|
||||
if [[ -z "$(eval echo "\$$variable")" ]]; then continue; fi
|
||||
# Skip if not defined
|
||||
if [[ -z "$(eval echo "\$$variable")" ]]; then continue; fi
|
||||
|
||||
# Variable content
|
||||
variablecontent="$(eval echo "\$$variable")"
|
||||
# Sanitize " ' ` in current variable
|
||||
variablecontent="${variablecontent//[\"\'\`]/}"
|
||||
#if [[ "$variablecontent" = *" "* ]] && [[ "$variable" != "PAPERLESS_OCR_LANGUAGES" ]]; then
|
||||
# variablecontent="\"$variablecontent\""
|
||||
#fi
|
||||
bashio::log.blue "$variable=\"$variablecontent\""
|
||||
# Add to entrypoint
|
||||
sed -i "1a export $variable=\"$variablecontent\"" /sbin/docker-entrypoint.sh
|
||||
# Export
|
||||
export "$variable"="$variablecontent"
|
||||
# Add to bashrc
|
||||
eval echo "$variable=\"$variablecontent\"" >>~/.bashrc
|
||||
# set .env
|
||||
echo "$variable=\"$variablecontent\"" >>/.env || true
|
||||
# set /etc/environment
|
||||
mkdir -p /etc
|
||||
echo "$variable=\"$variablecontent\"" >>/etc/environment
|
||||
# For s6
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${variablecontent}" >/var/run/s6/container_environment/"${variable}"; fi
|
||||
# Variable content
|
||||
variablecontent="$(eval echo "\$$variable")"
|
||||
# Sanitize " ' ` in current variable
|
||||
variablecontent="${variablecontent//[\"\'\`]/}"
|
||||
#if [[ "$variablecontent" = *" "* ]] && [[ "$variable" != "PAPERLESS_OCR_LANGUAGES" ]]; then
|
||||
# variablecontent="\"$variablecontent\""
|
||||
#fi
|
||||
bashio::log.blue "$variable=\"$variablecontent\""
|
||||
# Add to entrypoint
|
||||
sed -i "1a export $variable=\"$variablecontent\"" /sbin/docker-entrypoint.sh
|
||||
# Export
|
||||
export "$variable"="$variablecontent"
|
||||
# Add to bashrc
|
||||
eval echo "$variable=\"$variablecontent\"" >> ~/.bashrc
|
||||
# set .env
|
||||
echo "$variable=\"$variablecontent\"" >> /.env || true
|
||||
# set /etc/environment
|
||||
mkdir -p /etc
|
||||
echo "$variable=\"$variablecontent\"" >> /etc/environment
|
||||
# For s6
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${variablecontent}" > /var/run/s6/container_environment/"${variable}"; fi
|
||||
done
|
||||
|
||||
#################
|
||||
|
||||
@@ -7,44 +7,44 @@ echo "Starting..."
|
||||
####################
|
||||
|
||||
for SCRIPTS in /etc/cont-init.d/*; do
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
|
||||
# Check if run as root
|
||||
if test "$(id -u)" == 0 && test "$(id -u)" == 0; then
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
else
|
||||
bashio::log.warning "Script executed with user $(id -u):$(id -g), things can break and chown won't work"
|
||||
# Disable chown and chmod in scripts
|
||||
sed -i "s/^chown /true # chown /g" "$SCRIPTS"
|
||||
sed -i "s/ chown / true # chown /g" "$SCRIPTS"
|
||||
sed -i "s/^chmod /true # chmod /g" "$SCRIPTS"
|
||||
sed -i "s/ chmod / true # chmod /g" "$SCRIPTS"
|
||||
fi
|
||||
# Check if run as root
|
||||
if test "$(id -u)" == 0 && test "$(id -u)" == 0; then
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
else
|
||||
bashio::log.warning "Script executed with user $(id -u):$(id -g), things can break and chown won't work"
|
||||
# Disable chown and chmod in scripts
|
||||
sed -i "s/^chown /true # chown /g" "$SCRIPTS"
|
||||
sed -i "s/ chown / true # chown /g" "$SCRIPTS"
|
||||
sed -i "s/^chmod /true # chmod /g" "$SCRIPTS"
|
||||
sed -i "s/ chmod / true # chmod /g" "$SCRIPTS"
|
||||
fi
|
||||
|
||||
# Get current shebang, if not available use another
|
||||
currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")"
|
||||
if [ ! -f "${currentshebang%% *}" ]; then
|
||||
for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do if [ -f "${shebang%% *}" ]; then break; fi; done
|
||||
sed -i "s|$currentshebang|$shebang|g" "$SCRIPTS"
|
||||
fi
|
||||
# Get current shebang, if not available use another
|
||||
currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")"
|
||||
if [ ! -f "${currentshebang%% *}" ]; then
|
||||
for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do if [ -f "${shebang%% *}" ]; then break; fi; done
|
||||
sed -i "s|$currentshebang|$shebang|g" "$SCRIPTS"
|
||||
fi
|
||||
|
||||
# Use source to share env variables when requested
|
||||
if [ "${ha_entry_source:-null}" = true ] && command -v "source" &>/dev/null; then
|
||||
# Exit cannot be used with source
|
||||
sed -i "s/(.*\s|^)exit ([0-9]+)/\1 return \2 || exit \2/g" "$SCRIPTS"
|
||||
sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS"
|
||||
sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS"
|
||||
# shellcheck source=/dev/null
|
||||
source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
else
|
||||
# Support for posix only shell
|
||||
/."$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
fi
|
||||
# Use source to share env variables when requested
|
||||
if [ "${ha_entry_source:-null}" = true ] && command -v "source" &> /dev/null; then
|
||||
# Exit cannot be used with source
|
||||
sed -i "s/(.*\s|^)exit ([0-9]+)/\1 return \2 || exit \2/g" "$SCRIPTS"
|
||||
sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS"
|
||||
sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS"
|
||||
# shellcheck source=/dev/null
|
||||
source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
else
|
||||
# Support for posix only shell
|
||||
/."$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
rm "$SCRIPTS"
|
||||
# Cleanup
|
||||
rm "$SCRIPTS"
|
||||
done
|
||||
|
||||
######################
|
||||
|
||||
Reference in New Issue
Block a user