Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/swap/init.d/swap.tpl

55 lines
1.1 KiB

4 years ago
#!/bin/bash
4 years ago
# chkconfig: 2345 55 25
4 years ago
# description: MW Cloud Service
4 years ago
### BEGIN INIT INFO
4 years ago
# Provides: bt
4 years ago
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
4 years ago
# Short-Description: starts mw
# Description: starts the mw
4 years ago
### END INIT INFO
4 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
4 years ago
4 years ago
app_file={$SERVER_PATH}
4 years ago
4 years ago
app_start(){
4 years ago
isStart=`free -m|grep Swap|awk '{print $2}'`
if [ "$isStart" == '0' ];then
4 years ago
echo -e "Starting swap... \c"
swapon $app_file
echo -e "\033[32mdone\033[0m"
4 years ago
else
4 years ago
echo "Starting swap already running"
4 years ago
fi
4 years ago
}
4 years ago
app_stop()
{
echo -e "Stopping swap... \c";
swapoff $app_file
echo -e "\033[32mdone\033[0m"
4 years ago
}
4 years ago
app_status()
{
isStart=`free -m|grep Swap|awk '{print $2}'`
if [ "$isStart" == '0' ];then
4 years ago
echo -e "\033[32mswap already running\033[0m"
4 years ago
else
4 years ago
echo -e "\033[31mswap not running\033[0m"
4 years ago
fi
}
4 years ago
case "$1" in
4 years ago
'start') app_start;;
'stop') app_stop;;
4 years ago
'restart'|'reload')
4 years ago
app_stop
4 years ago
app_start;;
'status') app_status;;
esac