alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.57k stars 224 forks source link

🐛 jellyseerr 1.9.2-2 contains bash script error #1540

Closed swesharkie closed 3 months ago

swesharkie commented 3 months ago

Description

After upgrading Jellyseerr from 1.9.2 to 1.9.2-2 the startup-script /etc/cont-init.d/90-run.sh throws an syntax error. /./etc/cont-init.d/90-run.sh: line 25: syntax error near unexpected token `else' Error : /etc/cont-init.d/90-run.sh exiting 2

The result is that the addon doesn't start.

However, I fixed this error on my own installation by editing /homeassistant/addons_config/jellyseerr/jellyseerr.sh with custom code to re-write /etc/cont-init.d/90-run.sh with the correct syntax.

cp /etc/cont-init.d/90-run.sh /etc/cont-init.d/90-run.bak
cat << 'EOF' > /etc/cont-init.d/90-run.sh
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e

# Create files
OLD_CONFIG_LOCATION="/config/addons_config/jellyseer"
CONFIG_LOCATION="/config/addons_config/jellyseerr"
bashio::log.info "Config stored in $CONFIG_LOCATION"
mkdir -p "$CONFIG_LOCATION"
cp -rnT /app/config "$CONFIG_LOCATION"/
rm -r /app/config
ln -s "$CONFIG_LOCATION" /app/config
chmod -R 755 "$CONFIG_LOCATION"

#Move files that may be in misspelled directory
if [ -d "$OLD_CONFIG_LOCATION" ];
  then
    #Directory Exists
  if ! [ -z "$( ls -A "$OLD_CONFIG_LOCATION" )" ];
    then
      bashio::log.info "Moving old configuration settings from $OLD_CONFIG_LOCATION to $CONFIG_LOCATION"
      cp -rnT "$OLD_CONFIG_LOCATION" "$CONFIG_LOCATION"/
      rm -r "$OLD_CONFIG_LOCATION"
  fi
fi

# Create files
JELLYFIN_TYPE=$(bashio::config 'TYPE')
export JELLYFIN_TYPE
TZ=$(bashio::config 'TZ')
export TZ

yarn start
EOF

Changes: Changed "if [ -z "$( ls -A '$OLD_CONFIG_LOCATION' )" ];" to a negative, so there's no need for an empty then. I moved the commands from else to then and removed else (there's no need for it since the if statement is reversed).

Please review the code to make sure it still performs as intended before implementation :).

Reproduction steps

Update to 1.9.2-2
Start the addon
View addon logs

Addon Logs

Don't have scrollback to failure logs, error is as above.

Architecture

amd64

OS

Virtual Machine

swesharkie commented 3 months ago

Can confirm now that 1.9.2-3 works without issues, thanks! :) I'll mark this as fixed and closed

alexbelgium commented 3 months ago

Thanks for reporting!