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/install.sh

52 lines
1016 B

4 years ago
#!/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`
install_tmp=${rootPath}/tmp/mw_install.pl
VERSION=$2
Install_swap()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/source
mkdir -p $serverPath/swap
echo "${VERSION}" > $serverPath/swap/version.pl
if [ "$sysName" == "Darwin" ];then
pass
else
3 years ago
dd if=/dev/zero of=$serverPath/swap/swapfile bs=1M count=2048
chmod 600 $serverPath/swap/swapfile
mkswap $serverPath/swap/swapfile
swapon $serverPath/swap/swapfile
4 years ago
fi
echo '安装完成' > $install_tmp
}
Uninstall_swap()
{
3 years ago
swapoff $serverPath/swap/swapfile
4 years ago
rm -rf $serverPath/swap
3 years ago
if [ -f /lib/systemd/system/swap.service ];then
rm -rf /lib/systemd/system/swap.service
fi
4 years ago
echo "Uninstall_swap" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_swap
else
Uninstall_swap
fi