Add status.sh script to get status of project services
This commit is contained in:
25
core/scripts/status.sh
Normal file
25
core/scripts/status.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -a services=(
|
||||
"hysteria-server.service"
|
||||
"webpanel.service"
|
||||
"hysteria-bot.service"
|
||||
"normalsub.service"
|
||||
"singbox.service"
|
||||
"wg-quick@wgcf.service"
|
||||
)
|
||||
|
||||
status_json="{"
|
||||
for service in "${services[@]}"; do
|
||||
if systemctl is-active --quiet "$service"; then
|
||||
status_json+="\"$service\":true,"
|
||||
else
|
||||
status_json+="\"$service\":false,"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove trailing comma and close JSON properly
|
||||
status_json="${status_json%,}}"
|
||||
|
||||
# Format output as valid JSON
|
||||
echo "$status_json" | jq -M .
|
||||
Reference in New Issue
Block a user