This commit is contained in:
Alexandre
2022-02-18 09:14:08 +01:00
parent 0e58af718b
commit b23670350e
8 changed files with 24 additions and 25 deletions

View File

@@ -4,7 +4,6 @@
# ============================================================================== # ==============================================================================
# Displays a simple add-on banner on startup # Displays a simple add-on banner on startup
# ============================================================================== # ==============================================================================
echo "hello"
if bashio::supervisor.ping; then if bashio::supervisor.ping; then
bashio::log.blue \ bashio::log.blue \
'-----------------------------------------------------------' '-----------------------------------------------------------'

View File

@@ -19,14 +19,14 @@ if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then
fi fi
# Check if config file is there, or create one from template # Check if config file is there, or create one from template
if [ -f $CONFIGSOURCE ]; then if [ -f "$CONFIGSOURCE" ]; then
# Create symlink if not existing yet # Create symlink if not existing yet
[ ! -L /data/config.yaml ] && ln -sf $CONFIGSOURCE /data [ ! -L /data/config.yaml ] && ln -sf "$CONFIGSOURCE" /data
bashio::log.info "Using config file found in $CONFIGSOURCE" bashio::log.info "Using config file found in $CONFIGSOURCE"
# Check if yaml is valid # Check if yaml is valid
EXIT_CODE=0 EXIT_CODE=0
yamllint -d relaxed $CONFIGSOURCE &>ERROR || EXIT_CODE=$? yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$?
if [ $EXIT_CODE = 0 ]; then if [ $EXIT_CODE = 0 ]; then
echo "Config file is a valid yaml" echo "Config file is a valid yaml"
else else
@@ -37,10 +37,10 @@ if [ -f $CONFIGSOURCE ]; then
else else
# Create symlink for addon to create config # Create symlink for addon to create config
touch ${CONFIGSOURCE} touch ${CONFIGSOURCE}
ln -sf $CONFIGSOURCE /data ln -sf "$CONFIGSOURCE" /data
rm $CONFIGSOURCE rm $CONFIGSOURCE
# Need to restart # Need to restart
bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting." bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in "$CONFIGSOURCE" before restarting."
fi fi
# Remove previous link or file # Remove previous link or file

View File

@@ -9,4 +9,4 @@ mkdir -p "$CONFIGSOURCE/import_files" || true
mkdir -p "$CONFIGSOURCE/configurations" || true mkdir -p "$CONFIGSOURCE/configurations" || true
# Make sure permissions are right # Make sure permissions are right
chown -R $(id -u):$(id -g) "$CONFIGSOURCE" chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE"

View File

@@ -10,7 +10,7 @@ CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
chmod 755 $CONFIGSOURCE chmod 755 $CONFIGSOURCE
# Check if config file is there, or create one from template # Check if config file is there, or create one from template
if [ -f $CONFIGSOURCE ]; then if [ -f "$CONFIGSOURCE" ]; then
echo "Using config file found in $CONFIGSOURCE" echo "Using config file found in $CONFIGSOURCE"
else else
echo "No config file, creating one from template" echo "No config file, creating one from template"
@@ -26,13 +26,13 @@ else
curl -L -f -s $TEMPLATESOURCE --output $CONFIGSOURCE curl -L -f -s $TEMPLATESOURCE --output $CONFIGSOURCE
fi fi
# Need to restart # Need to restart
bashio::log.fatal "Config file not found, creating a new one. Please customize the file in $CONFIGSOURCE before restarting." bashio::log.fatal "Config file not found, creating a new one. Please customize the file in "$CONFIGSOURCE" before restarting."
# bashio::exit.nok # bashio::exit.nok
fi fi
# Check if yaml is valid # Check if yaml is valid
EXIT_CODE=0 EXIT_CODE=0
yamllint -d relaxed $CONFIGSOURCE &>ERROR || EXIT_CODE=$? yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$?
if [ $EXIT_CODE = 0 ]; then if [ $EXIT_CODE = 0 ]; then
echo "Config file is a valid yaml" echo "Config file is a valid yaml"
else else

View File

@@ -31,7 +31,7 @@ RUN \
&& curl -s -S -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") >/dev/null \ && curl -s -S -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") >/dev/null \
&& mkdir -p /data/joal \ && mkdir -p /data/joal \
&& tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null \ && tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null \
&& chown -R $(id -u):$(id -g) /data/joal \ && chown -R "$(id -u):$(id -g)" /data/joal \
&& rm /data/joal/jack-of* || true && rm /data/joal/jack-of* || true
################## ##################

View File

@@ -16,14 +16,14 @@ fi
# download latest version # download latest version
if [ $VERBOSE = true ]; then if [ "$VERBOSE" = true ]; then
curl -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") curl -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz")
else else
curl -s -S -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") >/dev/null curl -s -S -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") >/dev/null
fi fi
mkdir -p /data/joal mkdir -p /data/joal
tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null
chown -R $(id -u):$(id -g) /data/joal chown -R "$(id -u):$(id -g)" /data/joal
rm /data/joal/jack-of* rm /data/joal/jack-of*
bashio::log.info "Joal updated" bashio::log.info "Joal updated"
@@ -84,7 +84,7 @@ mkdir -p /var/log/nginx && touch /var/log/nginx/error.log
# LAUNCH APPS # # LAUNCH APPS #
############### ###############
if [ $VERBOSE = true ]; then 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 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 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 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

View File

@@ -17,4 +17,4 @@ if [ -d /data/config ]; then
fi fi
# Make sure permissions are right # Make sure permissions are right
chown -R $(id -u):$(id -g) $CONFIGLOCATION chown -R "$(id -u):$(id -g)" $CONFIGLOCATION

View File

@@ -5,39 +5,39 @@ JSONTOCHECK='/config/transmission/settings.json'
JSONSOURCE='/defaults/settings.json' JSONSOURCE='/defaults/settings.json'
# If json already exists # If json already exists
if [ -f ${JSONTOCHECK} ]; then if [ -f "${JSONTOCHECK}" ]; then
# Variables # Variables
echo "Checking settings.json format" echo "Checking settings.json format"
# Check if json file valid or not # Check if json file valid or not
jq . -S ${JSONTOCHECK} &>/dev/null && ERROR=false || ERROR=true jq . -S "${JSONTOCHECK}" &>/dev/null && ERROR=false || ERROR=true
if [ $ERROR = true ]; then if [ $ERROR = true ]; then
bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch. Your old file is renamed as settings.json_old" bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch. Your old file is renamed as settings.json_old"
mv ${JSONSOURCE} ${JSONSOURCE}_old mv "${JSONSOURCE}" "${JSONSOURCE}"_old
cp ${JSONSOURCE} ${JSONTOCHECK} cp "${JSONSOURCE}" "${JSONTOCHECK}"
exit 0 exit 0
fi fi
# Get the default keys from the original file # Get the default keys from the original file
mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}")
# Check if all keys are still there, or add them # Check if all keys are still there, or add them
# spellcheck disable=SC2068 # shellcheck disable=SC2086
for KEYS in "${arr[@]}"; do for KEYS in "${arr[@]}"; do
# Check if key exists # Check if key exists
KEYSTHERE=$(jq "has(\"${KEYS}\")" ${JSONTOCHECK}) KEYSTHERE=$(jq "has(\"${KEYS}\")" "${JSONTOCHECK}")
if [ "$KEYSTHERE" != "true" ]; then if [ "$KEYSTHERE" != "true" ]; then
#Fetch initial value #Fetch initial value
JSONSOURCEVALUE=$(jq -r ".\"$KEYS\"" ${JSONSOURCE}) JSONSOURCEVALUE=$(jq -r ".\"$KEYS\"" "${JSONSOURCE}")
#Add key #Add key
sed -i "3 i\"${KEYS}\": \"${JSONSOURCEVALUE}\"," ${JSONTOCHECK} sed -i "3 i\"${KEYS}\": \"${JSONSOURCEVALUE}\"," "${JSONTOCHECK}"
# Message # Message
bashio::log.warning "${KEYS} was missing from your settings.json, it was added with the default value ${JSONSOURCEVALUE}" bashio::log.warning "${KEYS} was missing from your settings.json, it was added with the default value ${JSONSOURCEVALUE}"
fi fi
done done
# Show structure in a nice way # Show structure in a nice way
jq . -S ${JSONTOCHECK} | cat >temp.json && mv temp.json ${JSONTOCHECK} jq . -S "${JSONTOCHECK}" | cat >temp.json && mv temp.json "${JSONTOCHECK}"
# Message # Message
bashio::log.info "Your settings.json was checked and seems perfectly normal!" bashio::log.info "Your settings.json was checked and seems perfectly normal!"