mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-09 06:46:10 +01:00
Merge branch 'stable' into v2.0.3-dev
This commit is contained in:
108
CPScripts/watchdog.sh
Normal file
108
CPScripts/watchdog.sh
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
show_help() {
|
||||
echo -e "\nrun command: \e[31mnohup bash /etc/cyberpanel/watchdog.sh SERVICE_NAME >/dev/null 2>&1 &\e[39m"
|
||||
echo -e "\nreplace \e[31mSERVICE_NAME\e[39m to the service name, acceptable word: \e[31mmariadb\e[39m or \e[31mlsws\e[39m"
|
||||
echo -e "\nWatchdog will check service status every 60 seconds and tries to restart if it is not running and also send an email to designated address"
|
||||
echo -e "\nto exit watchdog , run command \e[31mbash /etc/cyberpanel/watchdog.sh kill\e[39m"
|
||||
echo -e "\n\nplease also create \e[31m/etc/cyberpanel/watchdog.flag\e[39m file with following format:"
|
||||
echo -e "TO=address@email.com"
|
||||
echo -e "SENDER=sender name"
|
||||
echo -e "FROM=sender@email.com"
|
||||
echo -e "You may proceed without flag file , but that will make email sending failed."
|
||||
}
|
||||
|
||||
watchdog_check() {
|
||||
echo -e "\nChecking LiteSpeed ..."
|
||||
pid=$(ps aux | grep "watchdog lsws" | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" == "" ]] ; then
|
||||
echo -e "\nWatchDog for LSWS is gone , restarting..."
|
||||
nohup watchdog lsws > /dev/null 2>&1 &
|
||||
echo -e "\nWatchDog for LSWS has been started..."
|
||||
else
|
||||
echo -e "\nWatchDog for LSWS is running...\n"
|
||||
echo $(ps aux | grep "watchdog lsws" | grep -v grep)
|
||||
fi
|
||||
echo -e "\nChecking MariaDB ..."
|
||||
pid=$(ps aux | grep "watchdog mariadb" | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" == "" ]] ; then
|
||||
echo -e "\nWatchDog for MariaDB is gone , restarting..."
|
||||
nohup watchdog mariadb > /dev/null 2>&1 &
|
||||
echo -e "\nWatchDog for MariaDB has been started..."
|
||||
else
|
||||
echo -e "\nWatchDog for MariaDB is running...\n"
|
||||
echo $(ps aux | grep "watchdog mariadb" | grep -v grep)
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $1 == "mariadb" ]] || [[ $1 == "database" ]] || [[ $1 == "mysql" ]] ; then
|
||||
NAME="mariadb"
|
||||
echo "Watchdog on MariaDB is started up ..."
|
||||
elif [[ $1 == "web" ]] || [[ $1 == "lsws" ]] || [[ $1 == "litespeed" ]] || [[ $1 == "openlitespeed" ]] ; then
|
||||
NAME="lsws"
|
||||
echo "Watchdog on LiteSpeed is started up ..."
|
||||
elif [[ $1 == "help" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] || [[ $1 == "" ]] ; then
|
||||
show_help
|
||||
exit
|
||||
elif [[ $1 == "check" ]] || [[ $1 == "status" ]] ; then
|
||||
watchdog_check
|
||||
exit
|
||||
elif [[ $1 == "kill" ]] ; then
|
||||
pid=$(ps aux | grep "watchdog lsws" | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" != "" ]] ; then
|
||||
kill -15 $pid
|
||||
fi
|
||||
pid=$(ps aux | grep "watchdog mariadb" | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" != "" ]] ; then
|
||||
kill -15 $pid
|
||||
fi
|
||||
echo "watchdo has been killed..."
|
||||
exit
|
||||
else
|
||||
show_help
|
||||
|
||||
echo -e "\n\n\nunknown service name..."
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
|
||||
while [ true = true ]
|
||||
do
|
||||
systemctl status $NAME 2>&1>/dev/null
|
||||
if [[ $? == "0" ]] ; then
|
||||
if [[ $NAME == "mariadb" ]] ; then
|
||||
pid=$(ps aux | grep "/usr/sbin/mysqld" | grep -v grep | awk '{print $2}')
|
||||
echo "-1000" > /proc/$pid/oom_score_adj
|
||||
fi
|
||||
echo "$NAME service is running..."
|
||||
else
|
||||
echo "$NAME is down , try to restart it..."
|
||||
if [[ $NAME == "lsws" ]] ; then
|
||||
pkill lsphp
|
||||
fi
|
||||
if [[ $NAME == "mariadb" ]] ; then
|
||||
pid=$(ps aux | grep "/usr/sbin/mysqld" | grep -v grep | awk '{print $2}')
|
||||
echo "-1000" > /proc/$pid/oom_score_adj
|
||||
fi
|
||||
systemctl stop $NAME
|
||||
systemctl start $NAME
|
||||
if [ -f /etc/cyberpanel/watchdog.flag ] ; then
|
||||
flag="/etc/cyberpanel/watchdog.flag"
|
||||
LINE3=$(awk 'NR==3' $flag)
|
||||
LINE2=$(awk 'NR==2' $flag)
|
||||
LINE1=$(awk 'NR==1' $flag)
|
||||
|
||||
FROM=${LINE3#*=}
|
||||
SENDER=${LINE2#*=}
|
||||
TO=${LINE1#*=}
|
||||
sendmail -F $SENDER -f $FROM -i $TO <<MAIL_END
|
||||
Subject: $NAME is down...
|
||||
To: $TO
|
||||
$NAME is down , watchdog attempted to restarting it...
|
||||
|
||||
MAIL_END
|
||||
fi
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
@@ -74,7 +74,7 @@ fi
|
||||
|
||||
watchdog_setup() {
|
||||
if [[ $WATCHDOG == "ON" ]] ; then
|
||||
wget -O /etc/cyberpanel/watchdog.sh https://$DOWNLOAD_SERVER/misc/watchdog.sh
|
||||
wget -O /etc/cyberpanel/watchdog.sh https://$GIT_CONTENT_URL/stable/CPScripts/watchdog.sh
|
||||
chmod 700 /etc/cyberpanel/watchdog.sh
|
||||
ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog
|
||||
pid=$(ps aux | grep "watchdog lsws" | grep -v grep | awk '{print $2}')
|
||||
@@ -384,7 +384,7 @@ if [[ -d /etc/yum.repos.d ]] ; then
|
||||
if [[ $CENTOS_8 == "True" ]] ; then
|
||||
dnf install zip -y
|
||||
elif [[ $CENTOS_8 == "False" ]] ; then
|
||||
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
|
||||
curl https://$GIT_CONTENT_URL/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -486,7 +486,7 @@ if [[ $SERVER_OS == "Ubuntu" ]] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp72-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp71-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp70-memcached
|
||||
|
||||
|
||||
if [[ $TOTAL_RAM -eq "2048" ]] || [[ $TOTAL_RAM -gt "2048" ]] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt install build-essential zlib1g-dev libexpat1-dev openssl libssl-dev libsasl2-dev libpcre3-dev git -y
|
||||
wget https://$DOWNLOAD/litespeed/lsmcd.tar.gz
|
||||
@@ -657,21 +657,25 @@ check_process() {
|
||||
if systemctl is-active --quiet httpd; then
|
||||
systemctl disable httpd
|
||||
systemctl stop httpd
|
||||
systemctl mask httpd
|
||||
echo -e "\nhttpd process detected, disabling...\n"
|
||||
fi
|
||||
if systemctl is-active --quiet apache2; then
|
||||
systemctl disable apache2
|
||||
systemctl stop apache2
|
||||
systemctl mask apache2
|
||||
echo -e "\napache2 process detected, disabling...\n"
|
||||
fi
|
||||
if systemctl is-active --quiet named; then
|
||||
systemctl stop named
|
||||
systemctl disable named
|
||||
systemctl mask named
|
||||
echo -e "\nnamed process detected, disabling...\n"
|
||||
fi
|
||||
if systemctl is-active --quiet exim; then
|
||||
systemctl stop exim
|
||||
systemctl disable exim
|
||||
systemctl mask exim
|
||||
echo -e "\nexim process detected, disabling...\n"
|
||||
fi
|
||||
}
|
||||
@@ -925,7 +929,7 @@ fi
|
||||
#printf "%s" ""
|
||||
#read TMP_YN
|
||||
|
||||
echo -e "\nPress Enter key to continue with latest version or Enter specific version such as: \e[31m1.9.4\e[39m , \e[31m1.9.5\e[39m ...etc"
|
||||
echo -e "\nPress \e[31mEnter\e[39m key to continue with latest version or Enter specific version such as: \e[31m1.9.4\e[39m , \e[31m2.0.1\e[39m , \e[31m2.0.2\e[39m ...etc"
|
||||
printf "%s" ""
|
||||
read TMP_YN
|
||||
|
||||
@@ -1428,11 +1432,11 @@ fi
|
||||
echo -e "\033[0;32mTCP: 21\033[39m and \033[0;32mTCP: 40110-40210\033[39m for FTP"
|
||||
echo -e "\033[0;32mTCP: 25\033[39m, \033[0;32mTCP: 587\033[39m, \033[0;32mTCP: 465\033[39m, \033[0;32mTCP: 110\033[39m, \033[0;32mTCP: 143\033[39m and \033[0;32mTCP: 993\033[39m for mail service"
|
||||
echo -e "\033[0;32mTCP: 53\033[39m and \033[0;32mUDP: 53\033[39m for DNS service"
|
||||
|
||||
|
||||
if ! timeout 3 telnet mx.zoho.com 25 | grep "Escape" > /dev/null 2>&1 ; then
|
||||
echo -e "Your provider seems \e[31mblocked\033[39m port 25 , E-mail sending may \e[31mnot\033[39m work properly."
|
||||
fi
|
||||
|
||||
|
||||
if [[ $SERVER_COUNTRY = CN ]] ; then
|
||||
if [[ $PROVIDER == "Tencent Cloud" ]] ; then
|
||||
if [[ $SERVER_OS == "Ubuntu" ]] ; then
|
||||
|
||||
@@ -47,13 +47,13 @@ read TMP_YN
|
||||
if [[ $TMP_YN == "1" ]] ; then
|
||||
if [[ ! -f /etc/cyberpanel/watchdog.sh ]] ; then
|
||||
echo -e "\nWatchDog no found..."
|
||||
wget -O /etc/cyberpanel/watchdog.sh https://cyberpanel.sh/misc/watchdog.sh
|
||||
wget -O /etc/cyberpanel/watchdog.sh https://$GIT_CONTENT_URL/$BRANCH_NAME/CPScripts/watchdog.sh
|
||||
chmod 700 /etc/cyberpanel/watchdog.sh
|
||||
ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog
|
||||
echo -e "\nWatchDos has been installed..."
|
||||
echo -e "\nWatchDog has been installed..."
|
||||
set_watchdog
|
||||
else
|
||||
echo -e "\nWatchDos is already installed..."
|
||||
echo -e "\nWatchDog is already installed..."
|
||||
set_watchdog
|
||||
fi
|
||||
elif [[ $TMP_YN == "2" ]] ; then
|
||||
@@ -168,8 +168,9 @@ addons() {
|
||||
echo -e "\n2. Install Memcached server."
|
||||
echo -e "\n3. Install Redis extension for PHP."
|
||||
echo -e "\n4. Install Redis server."
|
||||
echo -e "\n5. Back to Main Menu.\n"
|
||||
printf "%s" "Please enter number [1-5]: "
|
||||
echo -e "\n5. Raise phpMyAdmin upload limits."
|
||||
echo -e "\n6. Back to Main Menu.\n"
|
||||
printf "%s" "Please enter number [1-6]: "
|
||||
read TMP_YN
|
||||
|
||||
if [[ $TMP_YN == "1" ]] ; then
|
||||
@@ -181,13 +182,45 @@ addons() {
|
||||
elif [[ $TMP_YN == "4" ]] ; then
|
||||
install_redis
|
||||
elif [[ $TMP_YN == "5" ]] ; then
|
||||
phpmyadmin_limits
|
||||
elif [[ $TMP_YN == "6" ]] ; then
|
||||
main_page
|
||||
else
|
||||
echo -e " Please enter the right number [1-5]\n"
|
||||
echo -e " Please enter the right number [1-6]\n"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
phpmyadmin_limits() {
|
||||
echo -e "This will change following parameters for PHP 7.3:"
|
||||
echo -e "Post Max Size from default 8M to 500M"
|
||||
echo -e "Upload Max Filesize from default 2M to 500M"
|
||||
echo -e "Memory Limit from default 128M to 768M"
|
||||
echo -e "Max Execution Time from default 30 to 600"
|
||||
echo -e "\nPlease note this will also apply to all sites use PHP 7.3"
|
||||
printf "%s" "Please confirm to proceed: [Y/n]: "
|
||||
read TMP_YN
|
||||
if [[ $TMP_YN == "Y" ]] || [[ $TMP_YN == "y" ]] ; then
|
||||
|
||||
if [[ "$SERVER_OS" == "CentOS" ]] ; then
|
||||
php_ini_path="/usr/local/lsws/lsphp73/etc/php.ini"
|
||||
fi
|
||||
|
||||
if [[ "$SERVER_OS" == "Ubuntu" ]] ; then
|
||||
php_ini_path="/usr/local/lsws/lsphp73/etc/php/7.3/litespeed/php.ini"
|
||||
fi
|
||||
sed -i 's|post_max_size = 8M|post_max_size = 500M|g' $php_ini_path
|
||||
sed -i 's|upload_max_filesize = 2M|upload_max_filesize = 500M |g' $php_ini_path
|
||||
sed -i 's|memory_limit = 128M|memory_limit = 768M|g' $php_ini_path
|
||||
sed -i 's|max_execution_time = 30|max_execution_time = 600|g' $php_ini_path
|
||||
systemctl restart lscpd
|
||||
echo "Change applied..."
|
||||
else
|
||||
echo -e "Please enter Y or n."
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
install_php_redis() {
|
||||
if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
yum install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis lsphp56-redis lsphp55-redis lsphp54-redis
|
||||
|
||||
@@ -1437,7 +1437,7 @@ imap_folder_list_limit = 0
|
||||
|
||||
try:
|
||||
os.remove("/usr/local/lscp/fcgi-bin/lsphp")
|
||||
shutil.copy("/usr/local/lsws/lsphp72/bin/lsphp", "/usr/local/lscp/fcgi-bin/lsphp")
|
||||
shutil.copy("/usr/local/lsws/lsphp73/bin/lsphp", "/usr/local/lscp/fcgi-bin/lsphp")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user