diff --git a/CHANGELOG.md b/CHANGELOG.md index cf8b8b1..fcb1384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ [./run-seedbox.sh] line 320: ./env/traefik.env: No such file or directory ``` This bug was introduced in ``v2.2.1`` release and I'm sorry for it. It should work as expected now. +* [**Flood**] Fix #61 + The feature of Deluge Daemon auth autoconfig was broken since v2.2.0. It should work now and also handle filesystem with different permissions between config directory and media directory. # v2.2.1 (The little Flame 🔥) diff --git a/run-seedbox.sh b/run-seedbox.sh index a972dfa..0865369 100755 --- a/run-seedbox.sh +++ b/run-seedbox.sh @@ -204,17 +204,6 @@ if is_service_enabled flood; then else export DELUGE_HOST="deluge" fi - - # Specific instructions for Flood - # User for Deluge daemon RPC has to be created in deluge auth config file - if [[ ! -z ${FLOOD_PASSWORD} && ${FLOOD_AUTOCREATE_USER_IN_DELUGE_DAEMON} == true ]]; then - if ! grep -q "flood" $HOST_CONFIG_PATH/deluge/auth; then - echo "flood:${FLOOD_PASSWORD}:10" >> $HOST_CONFIG_PATH/deluge/auth - else - echo "[$0] No need to add user/password for flood as it has already been created." - echo "[$0] Consider setting FLOOD_AUTOCREATE_USER_IN_DELUGE_DAEMON variable to false in .env file." - fi - fi fi # Check that if calibre-web is enabled, calibre should also be enabled @@ -253,13 +242,26 @@ echo "[$0] ***** Generating configuration... *****" # Cleanup files before start, in case there was a change we start from scratch at every script execution rm -f services/generated/*-vpn.yaml +rm -f services/generated/*-envfile.yaml ALL_SERVICES="-f docker-compose.yaml" GLOBAL_ENV_FILE=".env" # Parse the config.yaml master configuration file -for json in $(yq eval -o json config.yaml | jq -c ".services[]"); do +CONFIG_JSON=($(yq eval -o json config.yaml | jq -c ".services[]")) # Parenthesis to cast as Bash array +CONFIG_JSON_INDEX=0 + +for json in "${CONFIG_JSON[@]}"; do + if [[ ${DEBUG} != "1" ]]; then + # Progress indicator with constant width + printf "[%s] ***** Processing [%02d / %02d] *****\r" "$0" "$((++CONFIG_JSON_INDEX))" "${#CONFIG_JSON[@]}" + # Break progress line if loop is ending + if [[ "$CONFIG_JSON_INDEX" -eq "${#CONFIG_JSON[@]}" ]]; then + echo "" + fi + fi + name=$(echo $json | jq -r .name) enabled=$(echo $json | jq -r .enabled) vpn=$(echo $json | jq -r .vpn) @@ -307,6 +309,47 @@ for json in $(yq eval -o json config.yaml | jq -c ".services[]"); do fi fi + # If we are on flood service AND autoconfig for flood password is set to true: + # Check that .env.custom exists and variable defined + # Do the deluge autoconfig - we already checked that deluge is enabled at this point + if [[ ${name} == "flood" && ${FLOOD_AUTOCREATE_USER_IN_DELUGE_DAEMON} == true ]]; then + # Specific instructions for Flood + if [[ ! -f env/${name}.env ]]; then + echo "ERROR. You set variable \"FLOOD_AUTOCREATE_USER_IN_DELUGE_DAEMON\" to true but you did not specify key \"FLOOD_FLOOD_PASSWORD\" in your .env.custom." + exit 1 + fi + set -a + source env/${name}.env + set +a + # User for Deluge daemon RPC has to be created in deluge auth config file + if [[ ! -z ${FLOOD_PASSWORD} ]]; then + DELUGE_CONFIG_FILE="$HOST_CONFIG_PATH/deluge/auth" + if [[ -r $DELUGE_CONFIG_FILE && -w $DELUGE_CONFIG_FILE ]]; then + if ! grep -q "flood" ${DELUGE_CONFIG_FILE}; then + echo "flood:${FLOOD_PASSWORD}:10" >> ${DELUGE_CONFIG_FILE} + else + echo "[$0] No need to add user/password for flood as it has already been created." + echo "[$0] Consider setting FLOOD_AUTOCREATE_USER_IN_DELUGE_DAEMON variable to false in .env file." + fi + else + echo "[$0] It seems you do not have permission to read or write to ${DELUGE_CONFIG_FILE} ." + echo "[$0] Prompting for sudo password..." + sudo bash <> ${DELUGE_CONFIG_FILE} +else + echo "[$0] No need to add user/password for flood as it has already been created." + echo "[$0] Consider setting FLOOD_AUTOCREATE_USER_IN_DELUGE_DAEMON variable to false in .env file." +fi +EOF + fi + else + echo "ERROR. \"FLOOD_FLOOD_PASSWORD\" variable seems not defined but flood service still has variables defined. Please add the missing variable." + exit 1 + fi + fi + + ###### For services which have "command" field with environment variables ###### var_in_cmd_detected="0" if [[ $(yq ".services.${name}.command[]" services/${file} | { grep "\\$.*\}" || true; } | wc -l) -gt 0 ]]; then