feat: improve edit_subpath function with better error handling and efficient Caddy reload

- Add service status validation before editing subpath
- Use systemctl reload for Caddy config changes
- Add fallback to restart if reload fails
- Enhance user feedback with old/new subpath comparison
- Improve error handling and status verification
This commit is contained in:
Whispering Wind
2025-05-29 23:21:56 +03:30
committed by GitHub
parent ee90f8ec88
commit 1781ca446d
3 changed files with 27 additions and 9 deletions

View File

@ -619,9 +619,8 @@ normalsub_handler() {
elif ! [[ "$subpath" =~ [A-Z] ]] || ! [[ "$subpath" =~ [a-z] ]] || ! [[ "$subpath" =~ [0-9] ]]; then
echo "Error: SUBPATH must include at least one uppercase letter, one lowercase letter, and one number."
else
sed -i "s|^SUBPATH=.*|SUBPATH=${subpath}|" "$NORMALSUB_ENV"
systemctl restart hysteria-normal-sub.service
echo "SUBPATH updated successfully!"
python3 $CLI_PATH normal-sub -a edit_subpath -sp "$subpath"
# echo "SUBPATH updated successfully!"
break
fi
done