Compare commits
2 Commits
4b519610af
...
f9531228d6
| Author | SHA1 | Date | |
|---|---|---|---|
| f9531228d6 | |||
| 9b1d42cea1 |
@ -301,42 +301,33 @@ update_authelia_config() {
|
|||||||
|
|
||||||
# Update domain settings from .env
|
# Update domain settings from .env
|
||||||
echo -e "${BLUE}Applying Tailscale domain settings...${NC}"
|
echo -e "${BLUE}Applying Tailscale domain settings...${NC}"
|
||||||
|
|
||||||
# Update domain in session section
|
if command -v yq &> /dev/null; then
|
||||||
yq e -i ".session.cookies[0].domain = \"${TAILNET_DOMAIN}\"" "$TEMP_CONFIG"
|
# 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"
|
||||||
# Update domain in access_control (find wildcard domain rule and update it)
|
|
||||||
# This assumes there's a rule with a wildcard domain like "*.example.com"
|
# Replace placeholder tailnet domain
|
||||||
local domain_rule_index=$(yq e ".access_control.rules | map(.domain) | map(select(. == \"*.*\")) | indices" "$TEMP_CONFIG" | head -n 1 | tr -d '[]')
|
yq e -i "walk(if type == \"string\" and . == \"your-tailnet.ts.net\" then \"${TAILNET_DOMAIN}\" else . end)" "$TEMP_CONFIG"
|
||||||
if [[ -n "$domain_rule_index" && "$domain_rule_index" != "null" ]]; then
|
|
||||||
yq e -i ".access_control.rules[$domain_rule_index].domain = \"${WILDCARD_DOMAIN}\"" "$TEMP_CONFIG"
|
# Move temp file to final location
|
||||||
fi
|
mv "$TEMP_CONFIG" "$AUTHELIA_CONFIG"
|
||||||
|
|
||||||
# Update authelia_url if it exists (it's a URL that must match cookie scope)
|
echo -e "${GREEN}Authelia configuration updated successfully!${NC}"
|
||||||
if yq e -e '.identity_validation.reset_password.authelia_url' "$TEMP_CONFIG" &>/dev/null; then
|
else
|
||||||
yq e -i ".identity_validation.reset_password.authelia_url = \"https://${FULL_HOSTNAME}\"" "$TEMP_CONFIG"
|
echo -e "${YELLOW}Warning: 'yq' is not installed. Using sed to update configuration.${NC}"
|
||||||
fi
|
echo -e "${YELLOW}This is less reliable and may not preserve all settings.${NC}"
|
||||||
|
|
||||||
# Move the temp file to the final location
|
# Create a new file from the example
|
||||||
mv "$TEMP_CONFIG" "$AUTHELIA_CONFIG"
|
cp "$AUTHELIA_CONFIG_EXAMPLE" "$AUTHELIA_CONFIG.new"
|
||||||
|
|
||||||
echo -e "${GREEN}Authelia configuration updated successfully!${NC}"
|
# Replace placeholders manually
|
||||||
else
|
sed -i "s|tailscale-nas\.your-tailnet\.ts\.net|${FULL_HOSTNAME}|g" "$AUTHELIA_CONFIG.new"
|
||||||
echo -e "${YELLOW}Warning: 'yq' is not installed. Using sed to update configuration.${NC}"
|
sed -i "s|your-tailnet\.ts\.net|${TAILNET_DOMAIN}|g" "$AUTHELIA_CONFIG.new"
|
||||||
echo -e "${YELLOW}This is less reliable and may not preserve all settings.${NC}"
|
|
||||||
|
# Move the new file to the final location
|
||||||
# Create a new file from the example
|
mv "$AUTHELIA_CONFIG.new" "$AUTHELIA_CONFIG"
|
||||||
cp "$AUTHELIA_CONFIG_EXAMPLE" "$AUTHELIA_CONFIG.new"
|
|
||||||
|
echo -e "${YELLOW}Authelia configuration updated with sed.${NC}"
|
||||||
# Update domain settings with sed (more fragile)
|
|
||||||
sed -i "s/domain: \".*\"/domain: \"${TAILNET_DOMAIN}\"/" "$AUTHELIA_CONFIG.new"
|
|
||||||
sed -i "s/domain: \"\\*\\..*\"/domain: \"${WILDCARD_DOMAIN}\"/" "$AUTHELIA_CONFIG.new"
|
|
||||||
sed -i "s|authelia_url: \"https://.*\"|authelia_url: \"https://${FULL_HOSTNAME}\"|" "$AUTHELIA_CONFIG.new"
|
|
||||||
|
|
||||||
# Move the new file to the final location
|
|
||||||
mv "$AUTHELIA_CONFIG.new" "$AUTHELIA_CONFIG"
|
|
||||||
|
|
||||||
echo -e "${YELLOW}Authelia configuration updated with sed. Secret values might need to be manually transferred.${NC}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}Authelia configuration update completed.${NC}"
|
echo -e "${GREEN}Authelia configuration update completed.${NC}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user