| Server IP : 104.21.95.231 / Your IP : 104.23.243.226 Web Server : Apache System : Linux vm3310.eosdns.net 4.18.0-553.132.1.el8_10.x86_64 #1 SMP Thu Jun 11 14:27:43 UTC 2026 x86_64 User : carnalmedia ( 1000) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /mojo/ |
Upload File : |
#!/bin/bash
#
# Script: suspendserver
#
# Usage: suspendserver
#
# Description: A tool for suspending or unsuspending servers
#
# Author: Nikita Shchetinin
#
# Changelog:
# * 25.03.2021: Nikita Shchetinin
# - Initial write
if [ "$(whoami)" != 'root' ]
then
echo "You must execute this script as the root user!"
exit 1
fi
SUSPEND () {
if [ -f /etc/firewalld/zones/public.xml.unsuspended ]
then
echo "/etc/firewalld/zones/public.xml.unsuspended exists so this server is already suspended!"
exit 1
fi
if [ ! -f /etc/firewalld/zones/public.xml ]
then
echo "The public zone does not exist in FirewallD so this server's configuration seems to be very custom and it will not be modified by this script!"
exit 1
else
user=$(who | awk '{ print $1 }')
date=$(date)
cp -f /etc/firewalld/zones/public.xml /etc/firewalld/zones/public.xml.unsuspended
sed -i '/service/d' /etc/firewalld/zones/public.xml
sed -i '/port/d' /etc/firewalld/zones/public.xml
systemctl restart firewalld
echo "The server has been suspended by $user on $date!" >> /etc/motd
echo "The server has been suspended, the backup is at /etc/firewalld/zones/public.xml.unsuspended"
fi
}
UNSUSPEND () {
if [ ! -f /etc/firewalld/zones/public.xml.unsuspended ]
then
echo "/etc/firewalld/zones/public.xml.unsuspended does not exist so there is nothing to restore the firewall's configuration from!"
exit 1
else
mv -f /etc/firewalld/zones/public.xml.unsuspended /etc/firewalld/zones/public.xml
systemctl restart firewalld
sed -i '/The server has been suspended/d' /etc/motd
echo "The server has been unsuspended"
fi
}
INPUT () {
echo "Would you like to suspend or unsuspend this server?"
select action in "Suspend" "Unsuspend"
do
case $action in
Suspend)
SUSPEND
break
;;
Unsuspend)
UNSUSPEND
break
;;
*)
echo "Invalid action!"
exit 1
;;
esac
done
}
HELP () {
echo "A tool for suspending or unsuspending servers"
echo "usage: suspendserver"
}
if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]]
then
HELP
else
INPUT
fi