mdserver-web/plugins/rsyncd/install.sh

64 lines
1.5 KiB
Bash
Raw Normal View History

2019-03-05 06:20:04 -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")
sysName=`uname`
2022-07-07 23:18:55 -04:00
#获取信息和版本
# bash /www/server/mdsever-web/scripts/getos.sh
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
2019-03-12 04:28:48 -04:00
install_tmp=${rootPath}/tmp/mw_install.pl
2019-03-05 06:20:04 -05:00
Install_rsyncd()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/rsyncd
2022-06-28 21:43:58 -04:00
2022-07-14 04:12:10 -04:00
if [ "$OSNAME" == "debian'" ] || [ "$OSNAME" == "ubuntu'" ];then
2022-07-07 23:18:55 -04:00
apt install -y rsync
2022-07-14 21:06:05 -04:00
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Sy rsync
2022-07-14 04:12:10 -04:00
else
yum install -y rsync
2022-07-07 23:18:55 -04:00
fi
2022-06-28 21:43:58 -04:00
2019-03-05 06:20:04 -05:00
echo '1.0' > $serverPath/rsyncd/version.pl
echo '安装完成' > $install_tmp
2022-06-28 21:43:58 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/rsyncd/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/rsyncd/index.py initd_install
2019-03-05 06:20:04 -05:00
}
Uninstall_rsyncd()
{
2022-07-14 04:12:10 -04:00
if [ -f /usr/lib/systemd/system/rsyncd.service ] || [ -f /lib/systemd/system/rsyncd.service ];then
2022-06-28 21:43:58 -04:00
systemctl stop rsyncd
systemctl disable rsyncd
2022-07-03 10:23:25 -04:00
rm -rf /usr/lib/systemd/system/rsyncd.service
2022-07-14 04:12:10 -04:00
rm -rf /lib/systemd/system/rsyncd.service
2022-06-28 21:43:58 -04:00
systemctl daemon-reload
fi
if [ -f $serverPath/rsyncd/initd/rsyncd ];then
$serverPath/rsyncd/initd/rsyncd stop
fi
2019-03-05 06:20:04 -05:00
rm -rf $serverPath/rsyncd
echo "卸载完成" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_rsyncd
else
Uninstall_rsyncd
fi