mdserver-web/plugins/varnish/install.sh

74 lines
2.0 KiB
Bash
Raw Permalink Normal View History

2022-06-11 08:11:05 -04: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")
VERSION=$2
2022-07-12 11:16:20 -04:00
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
2022-06-11 08:11:05 -04:00
Install_varnish()
{
2024-11-30 08:44:09 -05:00
echo '正在安装脚本文件...'
2022-06-11 08:11:05 -04:00
mkdir -p $serverPath/source
2022-07-11 03:16:17 -04:00
if [ "${OSNAME}" == "macos" ]; then
2022-06-11 08:13:00 -04:00
brew install varnish
2022-07-14 04:23:05 -04:00
elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ] || [ "${OSNAME}" == "rocky" ]; then
2022-06-11 08:11:05 -04:00
yum install varnish -y
2022-07-11 03:16:17 -04:00
elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then
2022-07-03 11:26:21 -04:00
apt install varnish -y
2022-07-14 21:08:11 -04:00
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Sy varnish
2022-07-11 03:16:17 -04:00
elif [ "${OSNAME}" == "opensuse" ];then
2022-07-03 11:26:21 -04:00
zypper install -y varnish
2022-06-11 08:11:05 -04:00
else
echo "I won't support it"
2022-07-06 20:51:13 -04:00
exit 1
2022-06-11 08:11:05 -04:00
fi
mkdir -p $serverPath/varnish
echo "1.0" > $serverPath/varnish/version.pl
2024-11-30 08:44:09 -05:00
echo '安装完成'
2022-07-06 20:51:13 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py initd_install
2022-06-11 08:11:05 -04:00
}
Uninstall_varnish()
{
2022-07-06 20:51:13 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py stop
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py initd_uninstall
2022-07-11 03:16:17 -04:00
if [ "${OSNAME}" == "macos" ]; then
2022-07-06 22:38:56 -04:00
brew uninstall varnish
2022-07-14 04:23:31 -04:00
elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ] || [ "${OSNAME}" == "rocky" ]; then
2022-07-06 22:38:56 -04:00
yum remove varnish -y
2022-07-13 23:12:49 -04:00
elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then
2022-07-06 22:38:56 -04:00
apt remove varnish -y
2022-07-14 21:08:11 -04:00
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Rv varnish
2022-07-11 03:16:17 -04:00
elif [ "${OSNAME}" == "opensuse" ];then
2022-07-06 22:38:56 -04:00
zypper remove -y varnish
else
echo "I won't support it"
fi
2022-06-11 08:11:05 -04:00
rm -rf $serverPath/varnish
2024-11-30 08:44:09 -05:00
echo "uninstall varnish"
2022-06-11 08:11:05 -04:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_varnish
else
Uninstall_varnish
fi