add caddy reload and restart commands

This commit is contained in:
Ruben 2025-08-18 16:42:17 -05:00
commit 233ed6e75c
Signed by: sneexy
GPG key ID: 8ECFA045E63BC583

View file

@ -125,6 +125,13 @@ function info_help {
echo "${bold}--update-helperbot${normal}"
echo " Create a backup of the current helperbot into ${underline}/usr/local/bin/helperbot.bak${normal} and does an in-place upgrade of itself."
echo
echo "${cyan}${bold}${underline}Caddy:${normal}"
echo "${bold}--caddy-reload${normal}"
echo " (Live-)Reload the Caddy configurations."
echo
echo "${bold}--caddy-restart${normal}"
echo " Restart the Caddy container."
echo
echo "${cyan}${bold}${underline}Fediverse:${normal}"
echo "${bold}--sync-blocklists${normal}"
echo " Import blocklist from Sharkey -> Iceshrimp"
@ -743,6 +750,31 @@ function fedi_update_frontends {
fi
}
# ╭──────────────╮
# │ reload caddy │
# ╰──────────────╯
function caddy_reload {
local caddy_name=caddy
# TODO: should we implement some sort of error checking here? in either case this will fail the entire script anyways if caddy isn't running and verbally reports that, so probably not required.
echo "${blue}caddy:${normal} Reloading Caddy..."
docker compose exec -w /etc/caddy $caddy_name caddy reload
echo "${green}Reloaded.${normal}"
}
# ╭───────────────╮
# │ restart caddy │
# ╰───────────────╯
function caddy_restart {
local caddy_dir=/srv/docker/caddy
# TODO: see note for caddy_reload
echo "${blue}caddy:${normal} Restarting Caddy..."
docker compose -f $caddy_dir/compose.yaml down
docker compose -f $caddy_dir/compose.yaml up -d
echo "${green}Restarted.${normal}"
}
# ╭────────────────────────────────────╮
# │ functions and variables - end here │
# ╰────────────────────────────────────╯
@ -800,6 +832,12 @@ while [ -n "$1" ]; do
--update-helperbot) # update helperbot
root_check
update_helperbot;;
--caddy-reload) # reload caddy
root_check
caddy_reload;;
--caddy-restart) # restart caddy
root_check
caddy_restart;;
--sync-blocklists) # fediverse: sync sharkey -> iceshrimp blocklists
if [ ! -v synth_current_system ]; then
detect_system