Skip to content

Add progress indicator to run-seedbox.sh #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 🔥)

Expand Down
67 changes: 55 additions & 12 deletions run-seedbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 <<EOF
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
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
Expand Down