mdserver-web/plugins/swap/install.sh

69 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2021-01-29 05:05:43 -05:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
SYSOS=`uname`
VERSION=$2
2024-07-24 14:43:57 -04:00
# cd /www/server/mdserver-web/plugins/swap && /bin/bash install.sh install 1.1
2021-01-29 05:05:43 -05:00
Install_swap()
{
2022-11-18 11:46:08 -05:00
if [ -d $serverPath/swap ];then
exit 0
fi
2024-11-30 08:44:09 -05:00
echo '正在安装脚本文件...'
2021-01-29 05:05:43 -05:00
mkdir -p $serverPath/source
mkdir -p $serverPath/swap
echo "${VERSION}" > $serverPath/swap/version.pl
if [ "$sysName" == "Darwin" ];then
pass
else
2022-10-06 05:28:37 -04:00
dd if=/dev/zero of=$serverPath/swap/swapfile bs=1M count=1024
2022-06-18 11:17:19 -04:00
chmod 600 $serverPath/swap/swapfile
mkswap $serverPath/swap/swapfile
swapon $serverPath/swap/swapfile
2021-01-29 05:05:43 -05:00
fi
2024-11-30 08:44:09 -05:00
echo '安装完成'
2022-06-28 21:36:31 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/swap/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/swap/index.py initd_install
2021-01-29 05:05:43 -05:00
}
Uninstall_swap()
{
2022-06-18 11:17:19 -04:00
swapoff $serverPath/swap/swapfile
2022-06-28 21:36:31 -04:00
2022-07-11 03:21:40 -04:00
if [ -f /usr/lib/systemd/system/swap.service ] || [ -f /lib/systemd/system/swap.service ];then
2022-06-28 21:36:31 -04:00
systemctl stop swap
systemctl disable swap
2022-07-11 03:21:40 -04:00
rm -rf /usr/lib/systemd/system/swap.service
2022-06-28 21:36:31 -04:00
rm -rf /lib/systemd/system/swap.service
systemctl daemon-reload
fi
if [ -f $serverPath/swap/initd/swap ];then
$serverPath/swap/initd/swap stop
fi
rm -rf $serverPath/swap
2022-06-18 11:17:19 -04:00
2024-11-30 08:44:09 -05:00
echo "Uninstall_swap"
2021-01-29 05:05:43 -05:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_swap
else
Uninstall_swap
fi