From 624da80514050e325bcf183f922af17a8fced49e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 13 Feb 2022 22:54:33 +0100 Subject: [PATCH] Update 99-run.sh --- joplin/rootfs/etc/cont-init.d/99-run.sh | 47 ++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/joplin/rootfs/etc/cont-init.d/99-run.sh b/joplin/rootfs/etc/cont-init.d/99-run.sh index f032880d6..1f2f37153 100644 --- a/joplin/rootfs/etc/cont-init.d/99-run.sh +++ b/joplin/rootfs/etc/cont-init.d/99-run.sh @@ -2,17 +2,56 @@ bashio::log.warning "Warning - minimum configuration recommended : 2 cpu cores and 4 GB of memory. Otherwise the system will become unresponsive and crash." -############## -# LAUNCH APP # -############## -# Configure app + # Create folder + echo "Creating $LOCATION" + mkdir -p "$LOCATION" + mkdir -p "$LOCATION"/resources + + rm -r /home/joplin/resources + ln -s $LOCATION/resources /home/joplin + + +# Check data location +LOCATION=$(bashio::config 'data_location') +if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then +# Default location +LOCATION="/config/addons_config/joplin" +else +bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually" +fi + +if bashio::config.has_value 'POSTGRES_DATABASE'; then +bashio::log.info "Using postgres" + bashio::config.has_value 'DB_CLIENT' && export DB_CLIENT=$(bashio::config 'DB_CLIENT') && bashio::log.info 'Database client set' bashio::config.has_value 'POSTGRES_PASSWORD' && export POSTGRES_PASSWORD=$(bashio::config 'POSTGRES_PASSWORD') && bashio::log.info 'Postgrep Password set' bashio::config.has_value 'POSTGRES_DATABASE' && export POSTGRES_DATABASE=$(bashio::config 'POSTGRES_DATABASE') && bashio::log.info 'Postgrep Database set' bashio::config.has_value 'POSTGRES_USER' && export POSTGRES_USER=$(bashio::config 'POSTGRES_USER') && bashio::log.info 'Postgrep User set' bashio::config.has_value 'POSTGRES_PORT' && export POSTGRES_PORT=$(bashio::config 'POSTGRES_PORT') && bashio::log.info 'Postgrep Port set' bashio::config.has_value 'POSTGRES_HOST' && export POSTGRES_HOST=$(bashio::config 'POSTGRES_HOST') && bashio::log.info 'Postgrep Host set' +else + +bashio::log.info "Using sqlite" + + + # Creating database + if [ ! -f $LOCATION/database.sqlite ]; then + # Create database + touch $LOCATION/database.sqlite + fi + + # Creating symlink + rm -r /home/joplin/database.sqlite + ln -s $LOCATION/database.sqlite /home/joplin/database.sqlite + +fi + +############## +# LAUNCH APP # +############## + +# Configure app bashio::config.has_value 'MAILER_HOST' && export MAILER_HOST=$(bashio::config 'MAILER_HOST') && bashio::log.info 'Mailer Host set' bashio::config.has_value 'MAILER_PORT' && export MAILER_PORT=$(bashio::config 'MAILER_PORT') && bashio::log.info 'Mailer Port set' bashio::config.has_value 'MAILER_SECURE' && export MAILER_SECURE=$(bashio::config 'MAILER_SECURE') && bashio::log.info 'Mailer Secure set'