diff --git a/generate.sh b/generate.sh index 211bea8..851b610 100644 --- a/generate.sh +++ b/generate.sh @@ -4,14 +4,14 @@ CONFIG_PATH="/opt/adguardhome/conf/AdGuardHome.yaml" # Admin username if [ -z "$ADMIN_USERNAME" ]; then - echo "Container requires ADMIN_USERNAME environment variable" + echo "$(date -Iseconds) [error] Container requires ADMIN_USERNAME environment variable" exit 1 fi sed -i "s|ADMIN_USERNAME|$ADMIN_USERNAME|g" "$CONFIG_PATH" # Admin password if [ -z "$ADMIN_PASSWORD" ]; then - echo "Container requires ADMIN_PASSWORD environment variable" + echo "$(date -Iseconds) [error] Container requires ADMIN_PASSWORD environment variable" exit 1 fi ADMIN_PASSWORD_ENCRYPTED=$(htpasswd -B -n -b "$ADMIN_USERNAME" "$ADMIN_PASSWORD" | cut -d ":" -f 2) @@ -19,29 +19,29 @@ sed -i "s|ADMIN_PASSWORD_ENCRYPTED|$ADMIN_PASSWORD_ENCRYPTED|g" "$CONFIG_PATH" # Upstream DNS if [ -z "$UPSTREAM_DNS" ]; then - echo "Container requires UPSTREAM_DNS environment variable" + echo "$(date -Iseconds) [error] Container requires UPSTREAM_DNS environment variable" exit 1 fi sed -i "s|UPSTREAM_DNS|$UPSTREAM_DNS|g" "$CONFIG_PATH" # Allow filter -echo "Applying allow filter rules (if any)" +echo "$(date -Iseconds) [info] Applying allow filter rules (if any)" if [ -n "$SPACE_SEPARATED_FILTER_ALLOW" ]; then # Add each rule from the allow list echo "$SPACE_SEPARATED_FILTER_ALLOW" | tr ' ' '\n' | while read -r FILTER_ALLOW; do - echo "... allowing '$FILTER_ALLOW'" - sed -i "s: - FILTER_ALLOW: - \"@||$FILTER_ALLOW\"\n - FILTER_ALLOW:g" "$CONFIG_PATH" + echo "$(date -Iseconds) [info] ... allowing '$FILTER_ALLOW'" + sed -i "s: - FILTER_ALLOW: - \"@@||$FILTER_ALLOW\"\n - FILTER_ALLOW:g" "$CONFIG_PATH" done fi # Remove the allow placeholder sed -i "/FILTER_ALLOW/d" $CONFIG_PATH # Deny filter -echo "Applying deny filter rules (if any)" +echo "$(date -Iseconds) [info] Applying deny filter rules (if any)" if [ -n "$SPACE_SEPARATED_FILTER_DENY" ]; then # Add each rule from the deny list echo "$SPACE_SEPARATED_FILTER_DENY" | tr ' ' '\n' | while read -r FILTER_DENY; do - echo "... denying '$FILTER_DENY'" + echo "$(date -Iseconds) [info] ... denying '$FILTER_DENY'" sed -i "s: - FILTER_DENY: - \"$FILTER_DENY\"\n - FILTER_DENY:g" "$CONFIG_PATH" done fi @@ -49,4 +49,4 @@ fi sed -i "/FILTER_DENY/d" "$CONFIG_PATH" # Final output -cat $CONFIG_PATH +echo "$(date -Iseconds) [info] Finished configuring AdGuardHome"