This script will get a list of users. Adjust the domain
variable as needed.
vim /etc/sysconfig/imunify360/get-users-script.sh
#!/bin/bash
# Script to generate user info in JSON format based on UID_MIN and UID_MAX
# Extract UID_MIN and UID_MAX from /etc/login.defs
UID_MIN=$(awk '/^UID_MIN/ { print $2 }' /etc/login.defs)
UID_MAX=$(awk '/^UID_MAX/ { print $2 }' /etc/login.defs)
output='{"data":['
first=true
# Read through /etc/passwd and filter users within the UID range
while IFS=: read -r username _ uid _ _ _ home shell; do
if [ "$uid" -ge "$UID_MIN" ] && [ "$uid" -le "$UID_MAX" ]; then
if [ "$first" = true ]; then
first=false
else
output+=','
fi
domain="${username}.com"
email="${username}@${domain}"
user_json=$(cat <<EOF
{
"id": $uid,
"username": "$username",
"owner": "root",
"domain": "$domain",
"package": {
"name": "package",
"owner": "root"
},
"email": "$email",
"locale_code": "EN_us"
}
EOF
)
output+="$user_json"
fi
done < /etc/passwd
output+='], "metadata": { "result": "ok" }}'
# Output final JSON
echo "$output"
vim /etc/sysconfig/imunify360/get-domains-script.sh
#!/bin/bash
# Script to output domain JSON info
cat <<EOF
{
"data": {
"example.com": {
"document_root": "/home/username/public_html/",
"is_main": true,
"owner": "username"
},
"subdomain.example.com": {
"document_root": "/home/username/public_html/subdomain/",
"is_main": false,
"owner": "username"
}
},
"metadata": {
"result": "ok"
}
}
EOF
vim /etc/sysconfig/imunify360/panel-infotest.sh
#!/bin/bash
# Function to check if a port is open
check_port() {
nc -z -w1 $1 $2
return $?
}
# Main script execution
main() {
local host="localhost"
local name=""
local version="unknown" # This script does not fetch versions, it is static for now
# Webmin
if check_port $host 10000; then
name="Webmin"
# Cockpit
elif check_port $host 9090; then
name="Cockpit"
# ISPConfig
elif check_port $host 8080; then
name="ISPConfig"
# Ajenti
elif check_port $host 8000; then
name="Ajenti"
# Froxlor
elif check_port $host 4430; then
name="Froxlor"
# Vestacp
elif check_port $host 8083; then
name="VestaCP"
# CentOS Web Panel (CWP)
elif check_port $host 2030 || check_port $host 2031; then
name="CentOS Web Panel"
# HestiaCP
elif check_port $host 8083; then
name="HestiaCP"
# BlueOnyx
elif check_port $host 444; then
name="BlueOnyx"
# WebCP
elif check_port $host 24522; then
name="WebCP"
# InterWorx
elif check_port $host 2443 || check_port $host 2080; then
name="InterWorx"
else
# If no known panel port is open, check for custom port (example range: 8000-9000)
# Note: This can be slow and may lead to false positives.
for port in $(seq 8000 9000); do
if check_port $host $port; then
name="Unknown Panel (custom port $port)"
break
fi
done
if [ -z "$name" ]; then
echo '{"metadata": {"result": "no web panel found"}}'
exit 1
fi
fi
echo "{
\"data\": {
\"name\": \"$name\",
\"version\": \"$version\"
},
\"metadata\": {
\"result\": \"ok\"
}
}"
}
main
chmod +x /etc/sysconfig/imunify360/get-users-script.sh
chmod +x /etc/sysconfig/imunify360/get-domains-script.sh
chmod +x /etc/sysconfig/imunify360/panel-infotest.sh