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

74 lines
2.0 KiB

3 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")
VERSION=$2
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}'`
3 years ago
Install_varnish()
{
5 months ago
echo '正在安装脚本文件...'
3 years ago
mkdir -p $serverPath/source
if [ "${OSNAME}" == "macos" ]; then
brew install varnish
elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ] || [ "${OSNAME}" == "rocky" ]; then
3 years ago
yum install varnish -y
elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then
apt install varnish -y
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Sy varnish
elif [ "${OSNAME}" == "opensuse" ];then
zypper install -y varnish
3 years ago
else
echo "I won't support it"
exit 1
3 years ago
fi
mkdir -p $serverPath/varnish
echo "1.0" > $serverPath/varnish/version.pl
5 months ago
echo '安装完成'
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py initd_install
3 years ago
}
Uninstall_varnish()
{
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py stop
cd ${rootPath} && python3 ${rootPath}/plugins/varnish/index.py initd_uninstall
if [ "${OSNAME}" == "macos" ]; then
3 years ago
brew uninstall varnish
elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ] || [ "${OSNAME}" == "rocky" ]; then
3 years ago
yum remove varnish -y
elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then
3 years ago
apt remove varnish -y
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Rv varnish
elif [ "${OSNAME}" == "opensuse" ];then
3 years ago
zypper remove -y varnish
else
echo "I won't support it"
fi
3 years ago
rm -rf $serverPath/varnish
5 months ago
echo "uninstall varnish"
3 years ago
}
action=$1
if [ "${1}" == 'install' ];then
Install_varnish
else
Uninstall_varnish
fi