#!/bin/bash
# panel-svc restart|reload <httpd|php-fpm|mysqld>
set -euo pipefail
. /opt/panel/bin/panel-lib.sh
a="${1:-}"; s="${2:-}"
[[ "$a" =~ ^(restart|reload)$ ]] || die "action: restart|reload"
[[ "$s" =~ ^(httpd|php-fpm|mysqld)$ ]] || die "service: httpd|php-fpm|mysqld"
[ "$s" = mysqld ] && [ "$a" = reload ] && a=restart
[ "$s" = httpd ] && { apachectl -t >/dev/null 2>&1 || die "apache config is broken — not restarting"; }
systemctl "$a" "$s" && echo "$s: $a ok"
LOGNAME_PANEL=panel log "service $s $a"
