diff --git a/filebrowser/Dockerfile b/filebrowser/Dockerfile index 846945fcc..3703b4ac9 100644 --- a/filebrowser/Dockerfile +++ b/filebrowser/Dockerfile @@ -31,16 +31,16 @@ RUN \ ######################################## # Correct upstream image folders links # ######################################## - && mkdir -p -m 777 /config/filebrowser + && mkdir -p -m 777 /config/filebrowser || true # Copy root filesystem COPY rootfs / VOLUME [ "/data" ] WORKDIR / -RUN chmod 777 /run.sh +RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/run.sh" ] +CMD [ "/entrypoint.sh" ] ### LABELS diff --git a/filebrowser/rootfs/entrypoint.sh b/filebrowser/rootfs/entrypoint.sh new file mode 100644 index 000000000..af3f22031 --- /dev/null +++ b/filebrowser/rootfs/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +cd /scripts +for SCRIPTS in *; do + [ -e "$SCRIPTS" ] || continue + echo $SCRIPTS + chown $(id -u):$(id -g) $SCRIPTS + chmod a+x $SCRIPTS + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true + ./$SCRIPTS && + true || true # Prevents script crash on failure +done diff --git a/filebrowser/rootfs/scripts/00-aaa.sh b/filebrowser/rootfs/scripts/00-aaa.sh new file mode 100644 index 000000000..33c59cddc --- /dev/null +++ b/filebrowser/rootfs/scripts/00-aaa.sh @@ -0,0 +1,36 @@ +#!/bin/bash +if [ ! -f "/usr/bin/bashio" ]; then + echo "Bashio does not exist, executing script" + + ################ + # Install apps # + ################ + apk add --no-cache \ + curl \ + jq \ + bash \ + cifs-utils \ + keyutils \ + samba \ + samba-client \ + bind-tools \ + nginx + + ################### + # Install bashio # + ################## + BASHIO_VERSION=0.13.1 + mkdir -p /tmp/bashio + curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | + tar -xzf - --strip 1 -C /tmp/bashio + mv /tmp/bashio/lib /usr/lib/bashio + ln -s /usr/lib/bashio/bashio /usr/bin/bashio + rm -rf /tmp/bashio + + ######################################## + # Correct upstream image folders links # + ######################################## + mkdir -p -m 777 /config/filebrowser || true + + echo "Bashio installed" +fi diff --git a/filebrowser/rootfs/00-banner.sh b/filebrowser/rootfs/scripts/00-banner.sh similarity index 100% rename from filebrowser/rootfs/00-banner.sh rename to filebrowser/rootfs/scripts/00-banner.sh diff --git a/filebrowser/rootfs/92-local_mounts.sh b/filebrowser/rootfs/scripts/92-local_mounts.sh similarity index 100% rename from filebrowser/rootfs/92-local_mounts.sh rename to filebrowser/rootfs/scripts/92-local_mounts.sh diff --git a/filebrowser/rootfs/92-smb_mounts.sh b/filebrowser/rootfs/scripts/92-smb_mounts.sh similarity index 100% rename from filebrowser/rootfs/92-smb_mounts.sh rename to filebrowser/rootfs/scripts/92-smb_mounts.sh diff --git a/filebrowser/rootfs/92_mount _partitions.sh b/filebrowser/rootfs/scripts/92_mount _partitions.sh similarity index 100% rename from filebrowser/rootfs/92_mount _partitions.sh rename to filebrowser/rootfs/scripts/92_mount _partitions.sh diff --git a/filebrowser/rootfs/run.sh b/filebrowser/rootfs/scripts/99-run.sh similarity index 88% rename from filebrowser/rootfs/run.sh rename to filebrowser/rootfs/scripts/99-run.sh index 4e4e5d8d5..f7b71bcc2 100644 --- a/filebrowser/rootfs/run.sh +++ b/filebrowser/rootfs/scripts/99-run.sh @@ -1,18 +1,5 @@ #!/usr/bin/env bashio -########### -# SCRIPTS # -########### - -for SCRIPTS in "/00-banner.sh" "/92-local_mounts.sh" "/92-smb_mounts.sh"; do - echo $SCRIPTS - chown $(id -u):$(id -g) $SCRIPTS - chmod a+x $SCRIPTS - sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS - /.$SCRIPTS && - true # Prevents script crash on failure -done - ################### # SSL CONFIG v1.0 # ################### diff --git a/freqtrade/Dockerfile b/freqtrade/Dockerfile index 302dac18e..ebf5c87d5 100644 --- a/freqtrade/Dockerfile +++ b/freqtrade/Dockerfile @@ -27,9 +27,9 @@ RUN \ VOLUME [ "/data" ] WORKDIR / -RUN chmod 777 /run.sh +RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/bin/bash" ] -CMD [ "/run.sh" ] +CMD [ "/entrypoint.sh" ] # use /data instead of /config for hass.io environment # && sed -i "s|/config|/share/freqtrade|g" /etc/services.d/freqtrade/run \ diff --git a/freqtrade/rootfs/entrypoint.sh b/freqtrade/rootfs/entrypoint.sh new file mode 100644 index 000000000..f10b0abd6 --- /dev/null +++ b/freqtrade/rootfs/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "Starting" + +if [ ! -f /data/config.json ]; then + echo "building userdir" + freqtrade create-userdir --userdir /data + echo "building initial config" + freqtrade new-config --config /data/config.json +fi + +echo "Starting app" +freqtrade trade --logfile /data/logs/freqtrade.log --db-url sqlite://///data/tradesv3.sqlite --config /data/config.json --strategy SampleStrategy diff --git a/joal/rootfs/run.sh b/joal/rootfs/run.sh index c398f0246..1c0510fb7 100644 --- a/joal/rootfs/run.sh +++ b/joal/rootfs/run.sh @@ -6,37 +6,37 @@ if bashio::supervisor.ping; then bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' bashio::log.blue " Add-on: $(bashio::addon.name)" bashio::log.blue " $(bashio::addon.description)" bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' bashio::log.blue " Add-on version: $(bashio::addon.version)" if bashio::var.true "$(bashio::addon.update_available)"; then bashio::log.magenta ' There is an update available for this add-on!' bashio::log.magenta \ - " Latest add-on version: $(bashio::addon.version_latest)" + " Latest add-on version: $(bashio::addon.version_latest)" bashio::log.magenta ' Please consider upgrading as soon as possible.' else bashio::log.green ' You are running the latest version of this add-on.' fi bashio::log.blue " System: $(bashio::info.operating_system)" \ - " ($(bashio::info.arch) / $(bashio::info.machine))" + " ($(bashio::info.arch) / $(bashio::info.machine))" bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' bashio::log.blue \ - ' Please, share the above information when looking for help' + ' Please, share the above information when looking for help' bashio::log.blue \ - ' or support in, e.g., GitHub, forums or the Discord chat.' + ' or support in, e.g., GitHub, forums or the Discord chat.' bashio::log.green \ - ' https://github.com/alexbelgium/hassio-addons' + ' https://github.com/alexbelgium/hassio-addons' bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' fi ################ @@ -129,8 +129,7 @@ if [ $VERBOSE = true ]; then nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix=${UIPATH} --joal.ui.secret-token=$TOKEN else nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix=${UIPATH} --joal.ui.secret-token=$TOKEN >/dev/null -fi \ - & +fi & bashio::log.info "Please wait, loading..." # Wait for transmission to become available diff --git a/webtrees/Dockerfile b/webtrees/Dockerfile index 5c9e15943..92952a09f 100644 --- a/webtrees/Dockerfile +++ b/webtrees/Dockerfile @@ -8,7 +8,6 @@ COPY rootfs / ARG BASHIO_VERSION=0.13.1 ENV WEBTREES_HOME="/data/webtrees" WORKDIR $WEBTREES_HOME -ENTRYPOINT ["/run.sh"] VOLUME ["/data"] RUN \ @@ -36,14 +35,16 @@ RUN \ # Modify image # ################ # Change data location - && grep -rl "/var/www/webtrees" /etc/ | xargs sed -i 's|/var/www/webtrees|/data/webtrees|g' \ - \ - # Add entry script - && chown root:root /run.sh \ - && chmod a+x /run.sh \ + && grep -rl "/var/www/webtrees" /etc/ | xargs sed -i 's|/var/www/webtrees|/data/webtrees|g' || true + +# Add entry script +RUN chown root:root /entrypoint.sh \ + && chmod 777 /entrypoint.sh \ # Add end script && sed -i '$ d' /docker-entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + ### LABELS ARG BUILD_ARCH ARG BUILD_DATE diff --git a/freqtrade/rootfs/run.sh b/webtrees/rootfs/entrypoint.sh similarity index 97% rename from freqtrade/rootfs/run.sh rename to webtrees/rootfs/entrypoint.sh index ed812c5da..be0e15917 100644 --- a/freqtrade/rootfs/run.sh +++ b/webtrees/rootfs/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bah +#!/bin/bash echo "Starting" diff --git a/webtrees/rootfs/script/00-aaa.sh b/webtrees/rootfs/script/00-aaa.sh new file mode 100644 index 000000000..08af64c9d --- /dev/null +++ b/webtrees/rootfs/script/00-aaa.sh @@ -0,0 +1,33 @@ +#!/bin/bash +if [ ! -f "/usr/bin/bashio" ]; then + echo "Bashio does not exist, executing script" + + ################ + # Install apps # + ################ + apt-get clean && + apt-get update && + apt-get install -y \ + jq \ + curl && + apt-get clean + + ################ + # Modify image # + ################ + # Change data location + grep -rl "/var/www/webtrees" /etc/ | xargs sed -i 's|/var/www/webtrees|/data/webtrees|g' + + ################### + # Install bashio # + ################## + BASHIO_VERSION=0.13.1 + mkdir -p /tmp/bashio + curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | + tar -xzf - --strip 1 -C /tmp/bashio + mv /tmp/bashio/lib /usr/lib/bashio + ln -s /usr/lib/bashio/bashio /usr/bin/bashio + rm -rf /tmp/bashio + + echo "Bashio installed" +fi diff --git a/webtrees/rootfs/00-banner.sh b/webtrees/rootfs/script/00-banner.sh similarity index 100% rename from webtrees/rootfs/00-banner.sh rename to webtrees/rootfs/script/00-banner.sh diff --git a/webtrees/rootfs/run.sh b/webtrees/rootfs/script/99-run.sh similarity index 51% rename from webtrees/rootfs/run.sh rename to webtrees/rootfs/script/99-run.sh index e1ec8cdf7..055959b79 100644 --- a/webtrees/rootfs/run.sh +++ b/webtrees/rootfs/script/99-run.sh @@ -1,18 +1,5 @@ #!/usr/bin/env bashio -########### -# SCRIPTS # -########### - -for SCRIPTS in "/00-banner.sh"; do - echo $SCRIPTS - chown $(id -u):$(id -g) $SCRIPTS - chmod a+x $SCRIPTS - sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS - /.$SCRIPTS && - true # Prevents script crash on failure -done - #################### # GLOBAL VARIABLES # #################### @@ -28,25 +15,25 @@ export DB_TYPE=$(bashio::config 'DB_TYPE') bashio::config.require.ssl if bashio::config.true 'ssl'; then - - #set variables - CERTFILE=$(bashio::config 'certfile') - KEYFILE=$(bashio::config 'keyfile') - - #Replace variables - sed -i "s|/certs/webtrees.crt|/ssl/$CERTFILE|g" /etc/apache2/sites-available/default-ssl.conf - sed -i "s|/certs/webtrees.key|/ssl/$KEYFILE|g" /etc/apache2/sites-available/default-ssl.conf - sed -i "s|/certs/webtrees.crt|/ssl/$CERTFILE|g" /etc/apache2/sites-available/webtrees-ssl.conf - sed -i "s|/certs/webtrees.key|/ssl/$KEYFILE|g" /etc/apache2/sites-available/webtrees-ssl.conf - - #Send env variables - export HTTPS=true - export SSL=true - BASE_URL=$BASE_URL:$(bashio::addon.port 443) - export BASE_URL="${BASE_URL/http:/https:}" - - #Communication - bashio::log.info "Ssl enabled. If webui don't work, disable ssl or check your certificate paths" + + #set variables + CERTFILE=$(bashio::config 'certfile') + KEYFILE=$(bashio::config 'keyfile') + + #Replace variables + sed -i "s|/certs/webtrees.crt|/ssl/$CERTFILE|g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s|/certs/webtrees.key|/ssl/$KEYFILE|g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s|/certs/webtrees.crt|/ssl/$CERTFILE|g" /etc/apache2/sites-available/webtrees-ssl.conf + sed -i "s|/certs/webtrees.key|/ssl/$KEYFILE|g" /etc/apache2/sites-available/webtrees-ssl.conf + + #Send env variables + export HTTPS=true + export SSL=true + BASE_URL=$BASE_URL:$(bashio::addon.port 443) + export BASE_URL="${BASE_URL/http:/https:}" + + #Communication + bashio::log.info "Ssl enabled. If webui don't work, disable ssl or check your certificate paths" fi ############## @@ -69,20 +56,20 @@ chown -R www-data:www-data $WEBTREES_HOME # Make links with share echo "... make links with data in /share" for VOL in "data" "media" "modules_v4"; do -mkdir -p $OLD_WEBTREES_HOME/$VOL -cp -rn $OLD_WEBTREES_HOME/$VOL $WEBTREES_HOME || true -rm -r $OLD_WEBTREES_HOME/$VOL || true -ln -s $WEBTREES_HOME/$VOL $OLD_WEBTREES_HOME || true + mkdir -p $OLD_WEBTREES_HOME/$VOL + cp -rn $OLD_WEBTREES_HOME/$VOL $WEBTREES_HOME || true + rm -r $OLD_WEBTREES_HOME/$VOL || true + ln -s $WEBTREES_HOME/$VOL $OLD_WEBTREES_HOME || true done chown -R www-data:www-data $WEBTREES_HOME # Correct base url if needed echo "... align base url with latest addon value" if [ -f $WEBTREES_HOME/data/config.ini.php ]; then - echo "Aligning base_url addon config" - LINE=$(sed -n '/base_url/=' $WEBTREES_HOME/data/config.ini.php) - sed -i "$LINE a base_url=\"$BASE_URL\"" $WEBTREES_HOME/data/config.ini.php - sed -i "$LINE d" $WEBTREES_HOME/data/config.ini.php + echo "Aligning base_url addon config" + LINE=$(sed -n '/base_url/=' $WEBTREES_HOME/data/config.ini.php) + sed -i "$LINE a base_url=\"$BASE_URL\"" $WEBTREES_HOME/data/config.ini.php + sed -i "$LINE d" $WEBTREES_HOME/data/config.ini.php fi || true # Execute main script