Compare commits
2 Commits
f9531228d6
...
feature/tr
| Author | SHA1 | Date | |
|---|---|---|---|
| 79a7a0d4c6 | |||
| 93e709841b |
@@ -272,62 +272,60 @@ update_authelia_config() {
|
||||
local existing_notifier=$(yq e '.notifier // ""' "$AUTHELIA_CONFIG_BACKUP")
|
||||
|
||||
# Update secrets in temp file if they existed in the backup
|
||||
if [[ -n "$existing_jwt_secret" && "$existing_jwt_secret" != '""' && "$existing_jwt_secret" != "null" ]]; then
|
||||
existing_jwt_secret="$existing_jwt_secret" \
|
||||
yq e -i '.identity_validation.reset_password.jwt_secret = strenv(existing_jwt_secret)' "$TEMP_CONFIG"
|
||||
fi
|
||||
if [[ -n "$existing_jwt_secret" && "$existing_jwt_secret" != '""' && "$existing_jwt_secret" != "null" ]]; then
|
||||
existing_jwt_secret="$existing_jwt_secret" \
|
||||
yq e -i '.identity_validation.reset_password.jwt_secret = strenv(existing_jwt_secret)' "$TEMP_CONFIG"
|
||||
fi
|
||||
|
||||
if [[ -n "$existing_session_secret" && "$existing_session_secret" != '""' && "$existing_session_secret" != "null" ]]; then
|
||||
existing_session_secret="$existing_session_secret" \
|
||||
yq e -i '.session.secret = strenv(existing_session_secret)' "$TEMP_CONFIG"
|
||||
fi
|
||||
if [[ -n "$existing_session_secret" && "$existing_session_secret" != '""' && "$existing_session_secret" != "null" ]]; then
|
||||
existing_session_secret="$existing_session_secret" \
|
||||
yq e -i '.session.secret = strenv(existing_session_secret)' "$TEMP_CONFIG"
|
||||
fi
|
||||
|
||||
if [[ -n "$existing_storage_key" && "$existing_storage_key" != '""' && "$existing_storage_key" != "null" ]]; then
|
||||
existing_storage_key="$existing_storage_key" \
|
||||
yq e -i '.storage.encryption_key = strenv(existing_storage_key)' "$TEMP_CONFIG"
|
||||
fi
|
||||
if [[ -n "$existing_storage_key" && "$existing_storage_key" != '""' && "$existing_storage_key" != "null" ]]; then
|
||||
existing_storage_key="$existing_storage_key" \
|
||||
yq e -i '.storage.encryption_key = strenv(existing_storage_key)' "$TEMP_CONFIG"
|
||||
fi
|
||||
|
||||
if [[ -n "$existing_redis_pass" && "$existing_redis_pass" != '""' && "$existing_redis_pass" != "null" ]]; then
|
||||
existing_redis_pass="$existing_redis_pass" \
|
||||
yq e -i '.session.redis.password = strenv(existing_redis_pass)' "$TEMP_CONFIG"
|
||||
fi
|
||||
|
||||
if [[ -n "$existing_notifier" && "$existing_notifier" != '""' && "$existing_notifier" != "null" ]]; then
|
||||
existing_notifier="$existing_notifier" \
|
||||
yq e -i '.notifier = strenv(existing_notifier)' "$TEMP_CONFIG"
|
||||
fi
|
||||
if [[ -n "$existing_redis_pass" && "$existing_redis_pass" != '""' && "$existing_redis_pass" != "null" ]]; then
|
||||
existing_redis_pass="$existing_redis_pass" \
|
||||
yq e -i '.session.redis.password = strenv(existing_redis_pass)' "$TEMP_CONFIG"
|
||||
fi
|
||||
|
||||
if [[ -n "$existing_notifier" && "$existing_notifier" != '""' && "$existing_notifier" != "null" ]]; then
|
||||
existing_notifier="$existing_notifier" \
|
||||
yq e -i '.notifier = strenv(existing_notifier)' "$TEMP_CONFIG"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update domain settings from .env
|
||||
echo -e "${BLUE}Applying Tailscale domain settings...${NC}"
|
||||
|
||||
if command -v yq &> /dev/null; then
|
||||
# Replace placeholder full hostname
|
||||
yq e -i "walk(if type == \"string\" and . == \"tailscale-nas.your-tailnet.ts.net\" then \"${FULL_HOSTNAME}\" else . end)" "$TEMP_CONFIG"
|
||||
# Replace placeholder full hostname - using proper yq syntax instead of walk()
|
||||
yq e -i "(.. | select(tag == \"!!str\" and . == \"tailscale-nas.your-tailnet.ts.net\")) = \"${FULL_HOSTNAME}\"" "$TEMP_CONFIG"
|
||||
|
||||
# Replace placeholder tailnet domain
|
||||
yq e -i "walk(if type == \"string\" and . == \"your-tailnet.ts.net\" then \"${TAILNET_DOMAIN}\" else . end)" "$TEMP_CONFIG"
|
||||
# Replace placeholder tailnet domain - using proper yq syntax instead of walk()
|
||||
yq e -i "(.. | select(tag == \"!!str\" and . == \"your-tailnet.ts.net\")) = \"${TAILNET_DOMAIN}\"" "$TEMP_CONFIG"
|
||||
|
||||
# Move temp file to final location
|
||||
mv "$TEMP_CONFIG" "$AUTHELIA_CONFIG"
|
||||
# Move temp file to final location
|
||||
mv "$TEMP_CONFIG" "$AUTHELIA_CONFIG"
|
||||
|
||||
echo -e "${GREEN}Authelia configuration updated successfully!${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Warning: 'yq' is not installed. Using sed to update configuration.${NC}"
|
||||
echo -e "${YELLOW}This is less reliable and may not preserve all settings.${NC}"
|
||||
echo -e "${GREEN}Authelia configuration updated successfully!${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Warning: 'yq' is not installed. Using sed to update configuration.${NC}"
|
||||
echo -e "${YELLOW}This is less reliable and may not preserve all settings.${NC}"
|
||||
|
||||
# Create a new file from the example
|
||||
cp "$AUTHELIA_CONFIG_EXAMPLE" "$AUTHELIA_CONFIG.new"
|
||||
# Create a new file from the example
|
||||
cp "$AUTHELIA_CONFIG_EXAMPLE" "$AUTHELIA_CONFIG.new"
|
||||
|
||||
# Replace placeholders manually
|
||||
sed -i "s|tailscale-nas\.your-tailnet\.ts\.net|${FULL_HOSTNAME}|g" "$AUTHELIA_CONFIG.new"
|
||||
sed -i "s|your-tailnet\.ts\.net|${TAILNET_DOMAIN}|g" "$AUTHELIA_CONFIG.new"
|
||||
# Replace placeholders manually
|
||||
sed -i "s|tailscale-nas\.your-tailnet\.ts\.net|${FULL_HOSTNAME}|g" "$AUTHELIA_CONFIG.new"
|
||||
sed -i "s|your-tailnet\.ts\.net|${TAILNET_DOMAIN}|g" "$AUTHELIA_CONFIG.new"
|
||||
|
||||
# Move the new file to the final location
|
||||
mv "$AUTHELIA_CONFIG.new" "$AUTHELIA_CONFIG"
|
||||
# Move the new file to the final location
|
||||
mv "$AUTHELIA_CONFIG.new" "$AUTHELIA_CONFIG"
|
||||
|
||||
echo -e "${YELLOW}Authelia configuration updated with sed.${NC}"
|
||||
echo -e "${YELLOW}Authelia configuration updated with sed.${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Authelia configuration update completed.${NC}"
|
||||
@@ -335,7 +333,6 @@ update_authelia_config() {
|
||||
echo -e "${CYAN} docker compose restart authelia${NC}"
|
||||
}
|
||||
|
||||
|
||||
##################################################
|
||||
# PART 3: Update service configurations
|
||||
##################################################
|
||||
|
||||
Reference in New Issue
Block a user