mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
Beautify bash
This commit is contained in:
@@ -6,10 +6,10 @@ echo "Starting..."
|
||||
############################
|
||||
|
||||
if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then
|
||||
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
/./etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
/./etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
fi
|
||||
|
||||
####################
|
||||
@@ -17,11 +17,11 @@ fi
|
||||
####################
|
||||
|
||||
for SCRIPTS in /etc/cont-init.d/*; do
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
# Change shebang if no s6 supervision
|
||||
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS"
|
||||
/."$SCRIPTS" || echo "$SCRIPTS: exiting $?"
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
# Change shebang if no s6 supervision
|
||||
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS"
|
||||
/."$SCRIPTS" || echo "$SCRIPTS: exiting $?"
|
||||
done
|
||||
|
||||
@@ -11,10 +11,10 @@ if [ -e "/MODULESFILE" ]; then
|
||||
echo "Executing modules script : $MODULES"
|
||||
|
||||
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) >/dev/null; 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) >/dev/null; fi \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
&& 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) >/dev/null; fi \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
fi
|
||||
|
||||
#######################
|
||||
@@ -25,9 +25,9 @@ if [ -e "/ENVFILE" ]; then
|
||||
echo "Executing dependency script with custom elements : $PACKAGES"
|
||||
|
||||
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) >/dev/null; 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) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
&& 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) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
fi
|
||||
|
||||
@@ -11,8 +11,8 @@ APP_KEY="$(bashio::config 'APP_KEY')"
|
||||
|
||||
# If not base64
|
||||
if [[ ! "$APP_KEY" == *"base64"* ]]; then
|
||||
# Check APP_KEY format
|
||||
if [ ! "${#APP_KEY}" = 32 ]; then bashio::exit.nok "Your APP_KEY has ${#APP_KEY} instead of 32 characters"; fi
|
||||
# Check APP_KEY format
|
||||
if [ ! "${#APP_KEY}" = 32 ]; then bashio::exit.nok "Your APP_KEY has ${#APP_KEY} instead of 32 characters"; fi
|
||||
fi
|
||||
|
||||
# Backup APP_KEY file
|
||||
@@ -42,82 +42,82 @@ chmod -R 775 /config/addons_config/fireflyiii
|
||||
bashio::log.info "Defining database"
|
||||
case $(bashio::config 'DB_CONNECTION') in
|
||||
|
||||
# Use sqlite
|
||||
sqlite_internal)
|
||||
bashio::log.info "Using built in sqlite"
|
||||
# Use sqlite
|
||||
sqlite_internal)
|
||||
bashio::log.info "Using built in sqlite"
|
||||
|
||||
# Set variable
|
||||
export DB_CONNECTION=sqlite
|
||||
# Set variable
|
||||
export DB_CONNECTION=sqlite
|
||||
|
||||
# Creating folders
|
||||
mkdir -p /config/addons_config/fireflyiii/database
|
||||
chown -R www-data:www-data /config/addons_config/fireflyiii/database
|
||||
# Creating folders
|
||||
mkdir -p /config/addons_config/fireflyiii/database
|
||||
chown -R www-data:www-data /config/addons_config/fireflyiii/database
|
||||
|
||||
# Creating database
|
||||
if [ ! -f /config/addons_config/fireflyiii/database/database.sqlite ]; then
|
||||
# Create database
|
||||
touch /config/addons_config/fireflyiii/database/database.sqlite
|
||||
# Install database
|
||||
echo "updating database"
|
||||
php artisan migrate:refresh --seed --quiet
|
||||
php artisan firefly-iii:upgrade-database --quiet
|
||||
php artisan passport:install --quiet
|
||||
fi
|
||||
|
||||
# Creating symlink
|
||||
rm -r /var/www/html/storage/database
|
||||
ln -s /config/addons_config/fireflyiii/database /var/www/html/storage/database
|
||||
|
||||
# Updating permissions
|
||||
chmod 775 /config/addons_config/fireflyiii/database/database.sqlite
|
||||
chown -R www-data:www-data /config/addons_config/fireflyiii
|
||||
chown -R www-data:www-data /var/www/html/storage
|
||||
;;
|
||||
|
||||
# Use MariaDB
|
||||
mariadb_addon)
|
||||
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Detecting 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
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=$(bashio::services "mysql" "host")
|
||||
DB_PORT=$(bashio::services "mysql" "port")
|
||||
DB_DATABASE=firefly
|
||||
DB_USERNAME=$(bashio::services "mysql" "username")
|
||||
DB_PASSWORD=$(bashio::services "mysql" "password")
|
||||
export DB_CONNECTION
|
||||
export DB_HOST && bashio::log.blue "DB_HOST=$DB_HOST"
|
||||
export DB_PORT && bashio::log.blue "DB_PORT=$DB_PORT"
|
||||
export DB_DATABASE && bashio::log.blue "DB_DATABASE=$DB_DATABASE"
|
||||
export DB_USERNAME && bashio::log.blue "DB_USERNAME=$DB_USERNAME"
|
||||
export DB_PASSWORD && bashio::log.blue "DB_PASSWORD=$DB_PASSWORD"
|
||||
|
||||
bashio::log.warning "Firefly-iii 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"
|
||||
|
||||
bashio::log.info "Creating database for Firefly-iii if required"
|
||||
mysql \
|
||||
-u "${DB_USERNAME}" -p"${DB_PASSWORD}" \
|
||||
-h "${DB_HOST}" -P "${DB_PORT}" \
|
||||
-e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;"
|
||||
;;
|
||||
|
||||
# Use remote
|
||||
*)
|
||||
bashio::log.info "Using remote database. Requirement : filling all addon options fields, and making sure the database already exists"
|
||||
for conditions in "DB_HOST" "DB_PORT" "DB_DATABASE" "DB_USERNAME" "DB_PASSWORD"; do
|
||||
if ! bashio::config.has_value "$conditions"; then
|
||||
bashio::exit.nok "Remote database has been specified but $conditions is not defined in addon options"
|
||||
# Creating database
|
||||
if [ ! -f /config/addons_config/fireflyiii/database/database.sqlite ]; then
|
||||
# Create database
|
||||
touch /config/addons_config/fireflyiii/database/database.sqlite
|
||||
# Install database
|
||||
echo "updating database"
|
||||
php artisan migrate:refresh --seed --quiet
|
||||
php artisan firefly-iii:upgrade-database --quiet
|
||||
php artisan passport:install --quiet
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
# Creating symlink
|
||||
rm -r /var/www/html/storage/database
|
||||
ln -s /config/addons_config/fireflyiii/database /var/www/html/storage/database
|
||||
|
||||
# Updating permissions
|
||||
chmod 775 /config/addons_config/fireflyiii/database/database.sqlite
|
||||
chown -R www-data:www-data /config/addons_config/fireflyiii
|
||||
chown -R www-data:www-data /var/www/html/storage
|
||||
;;
|
||||
|
||||
# Use MariaDB
|
||||
mariadb_addon)
|
||||
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Detecting 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
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=$(bashio::services "mysql" "host")
|
||||
DB_PORT=$(bashio::services "mysql" "port")
|
||||
DB_DATABASE=firefly
|
||||
DB_USERNAME=$(bashio::services "mysql" "username")
|
||||
DB_PASSWORD=$(bashio::services "mysql" "password")
|
||||
export DB_CONNECTION
|
||||
export DB_HOST && bashio::log.blue "DB_HOST=$DB_HOST"
|
||||
export DB_PORT && bashio::log.blue "DB_PORT=$DB_PORT"
|
||||
export DB_DATABASE && bashio::log.blue "DB_DATABASE=$DB_DATABASE"
|
||||
export DB_USERNAME && bashio::log.blue "DB_USERNAME=$DB_USERNAME"
|
||||
export DB_PASSWORD && bashio::log.blue "DB_PASSWORD=$DB_PASSWORD"
|
||||
|
||||
bashio::log.warning "Firefly-iii 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"
|
||||
|
||||
bashio::log.info "Creating database for Firefly-iii if required"
|
||||
mysql \
|
||||
-u "${DB_USERNAME}" -p"${DB_PASSWORD}" \
|
||||
-h "${DB_HOST}" -P "${DB_PORT}" \
|
||||
-e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;"
|
||||
;;
|
||||
|
||||
# Use remote
|
||||
*)
|
||||
bashio::log.info "Using remote database. Requirement : filling all addon options fields, and making sure the database already exists"
|
||||
for conditions in "DB_HOST" "DB_PORT" "DB_DATABASE" "DB_USERNAME" "DB_PASSWORD"; do
|
||||
if ! bashio::config.has_value "$conditions"; then
|
||||
bashio::exit.nok "Remote database has been specified but $conditions is not defined in addon options"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user