mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-18 14:51:50 +02:00
add auto options
This commit is contained in:
@@ -4,6 +4,8 @@ CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
||||
|
||||
# Create directory
|
||||
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
||||
mkdir -p "$(dirname "${CONFIGSOURCE}/import_files")"
|
||||
mkdir -p "$(dirname "${CONFIGSOURCE}/configurations")"
|
||||
|
||||
# Make sure permissions are right
|
||||
chown -R $(id -u):$(id -g) "$(dirname "${CONFIGSOURCE}")"
|
||||
|
||||
@@ -1,5 +1,109 @@
|
||||
#!/usr/bin/env bashio
|
||||
|
||||
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
||||
|
||||
#################
|
||||
# CONFIG IMPORT #
|
||||
#################
|
||||
|
||||
if [ "$(ls -A $CONFIGSOURCE/configurations)" ]; then
|
||||
bashio::log.info "Configurations were found in $CONFIGSOURCE/configurations, they will be loaded."
|
||||
JSON_CONFIGURATION_DIR="$CONFIGSOURCE/configurations"
|
||||
export JSON_CONFIGURATION_DIR
|
||||
fi
|
||||
|
||||
################
|
||||
# CRON OPTIONS #
|
||||
################
|
||||
|
||||
if bashio::config.has_value 'Updates'; then
|
||||
|
||||
CONFIGSOURCE="$(dirname "${CONFIGSOURCE}/import_files")"
|
||||
|
||||
if [ "$(ls -A $CONFIGSOURCE)" ]; then
|
||||
# Align update with options
|
||||
echo ""
|
||||
FREQUENCY=$(bashio::config 'Updates')
|
||||
bashio::log.info "$FREQUENCY updates"
|
||||
echo ""
|
||||
|
||||
# Sets cron // do not delete this message
|
||||
cp /templates/cronupdate /etc/cron."${FREQUENCY}"/
|
||||
chmod 777 /etc/cron."${FREQUENCY}"/cronupdate
|
||||
|
||||
# Sets cron to run with www-data user
|
||||
sed -i 's|root|www-data|g' /etc/crontab
|
||||
|
||||
# Starts cron
|
||||
service cron start
|
||||
|
||||
# Export variables
|
||||
IMPORT_DIR_WHITELIST="$CONFIGSOURCE"
|
||||
export IMPORT_DIR_WHITELIST
|
||||
|
||||
bashio::log.info "Automatic updates were requested. The files in $CONFIGSOURCE will be imported $FREQUENCY."
|
||||
|
||||
else
|
||||
bashio::log.fatal "Automatic updates were requested, but there are no configuration files in $CONFIGSOURCE. There will therefore be be no automatic updates."
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
bashio::log.info "Automatic updates not set in addon config. If you add configuration files in $CONFIGSOURCE, they won't be automatically updated."
|
||||
|
||||
fi
|
||||
|
||||
##############
|
||||
# LAUNCH APP #
|
||||
##############
|
||||
|
||||
bashio::log.info "Please wait while the app is loading !"
|
||||
|
||||
/./usr/local/bin/entrypoint.sh
|
||||
export JSON_CONFIGURATION_DIR
|
||||
fi
|
||||
|
||||
################
|
||||
# CRON OPTIONS #
|
||||
################
|
||||
|
||||
if bashio::config.has_value 'Updates'; then
|
||||
|
||||
CONFIGSOURCE="$(dirname "${CONFIGSOURCE}/import_files")"
|
||||
|
||||
if [ "$(ls -A $CONFIGSOURCE)" ]; then
|
||||
# Align update with options
|
||||
echo ""
|
||||
FREQUENCY=$(bashio::config 'Updates')
|
||||
bashio::log.info "$FREQUENCY updates"
|
||||
echo ""
|
||||
|
||||
# Sets cron // do not delete this message
|
||||
cp /templates/cronupdate /etc/cron."${FREQUENCY}"/
|
||||
chmod 777 /etc/cron."${FREQUENCY}"/cronupdate
|
||||
|
||||
# Sets cron to run with www-data user
|
||||
sed -i 's|root|www-data|g' /etc/crontab
|
||||
|
||||
# Starts cron
|
||||
service cron start
|
||||
|
||||
# Export variables
|
||||
IMPORT_DIR_WHITELIST="$CONFIGSOURCE"
|
||||
export IMPORT_DIR_WHITELIST
|
||||
|
||||
bashio::log.info "Automatic updates were requested. The files in $CONFIGSOURCE will be imported $FREQUENCY."
|
||||
|
||||
else
|
||||
bashio::log.fatal "Automatic updates were requested, but there are no configuration files in $CONFIGSOURCE. There will therefore be be no automatic updates."
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
bashio::log.info "Automatic updates not set in addon config. If you add configuration files in $CONFIGSOURCE, they won't be automatically updated."
|
||||
|
||||
fi
|
||||
|
||||
##############
|
||||
# LAUNCH APP #
|
||||
##############
|
||||
|
||||
13
fireflyiii_data_importer/rootfs/templates/cronupdate
Normal file
13
fireflyiii_data_importer/rootfs/templates/cronupdate
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bashio
|
||||
|
||||
PATHTOFILES="$(bashio::config "CONFIG_LOCATION")"
|
||||
PATHTOFILES="$(dirname "${PATHTOFILES}")"
|
||||
|
||||
bashio::log.info "Running update according to defined schedule. Files located in $PATHTOFILES will be imported"
|
||||
if bashio::config.true 'silent'; then
|
||||
bashio::log.warning "Silent mode activated. Only errors will be shown. Please disable in addon options if you need to debug"
|
||||
/usr/local/bin/php /var/www/html/artisan importer:auto-import >/dev/null
|
||||
else
|
||||
/usr/local/bin/php /var/www/html/artisan importer:auto-import "$PATHTOFILES"/import_files
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user