mdserver-web/plugins/rsyncd/install.sh

95 lines
2.1 KiB
Bash
Raw Permalink 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`
2023-02-26 08:46:25 -05:00
if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi
2022-11-01 08:27:20 -04:00
if id www &> /dev/null ;then
echo "www uid is `id -u www`"
echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
else
groupadd www
useradd -g www -s /bin/bash www
fi
2024-11-30 08:44:09 -05:00
# echo $OSNAME
2019-03-05 06:20:04 -05:00
Install_rsyncd()
{
2024-11-30 08:44:09 -05:00
echo '正在安装脚本文件...'
2022-07-27 23:36:23 -04:00
2022-06-28 21:43:58 -04:00
if [ "$OSNAME" == "debian" ] || [ "$OSNAME" == "ubuntu" ];then
2022-07-07 23:18:55 -04:00
apt install -y rsync
2022-07-27 09:29:56 -04:00
apt install -y lsyncd
2022-07-14 21:06:05 -04:00
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Sy rsync
2022-07-27 09:29:56 -04:00
echo y | pacman -Sy lsyncd
elif [[ "$OSNAME" == "macos" ]]; then
2022-07-28 01:10:01 -04:00
# brew install rsync
# brew install lsyncd
echo "ok"
2022-07-14 04:12:10 -04:00
else
yum install -y rsync
2022-07-27 09:29:56 -04:00
yum install -y lsyncd
2022-07-07 23:18:55 -04:00
fi
2022-07-27 23:36:23 -04:00
mkdir -p $serverPath/rsyncd
2022-07-28 03:45:00 -04:00
mkdir -p $serverPath/rsyncd/receive
2022-07-28 01:10:01 -04:00
mkdir -p $serverPath/rsyncd/send
2022-06-28 21:43:58 -04:00
2022-07-27 09:29:56 -04:00
echo '2.0' > $serverPath/rsyncd/version.pl
2024-11-30 08:44:09 -05:00
echo '安装完成'
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
2022-11-01 09:54:14 -04:00
if [ -f /usr/lib/systemd/system/lsyncd.service ] || [ -f /lib/systemd/system/lsyncd.service ];then
systemctl stop lsyncd
systemctl disable lsyncd
rm -rf /usr/lib/systemd/system/lsyncd.service
rm -rf /lib/systemd/system/lsyncd.service
systemctl daemon-reload
fi
2022-06-28 21:43:58 -04:00
if [ -f $serverPath/rsyncd/initd/rsyncd ];then
$serverPath/rsyncd/initd/rsyncd stop
fi
2022-07-27 09:29:56 -04:00
2019-03-05 06:20:04 -05:00
rm -rf $serverPath/rsyncd
2024-11-30 08:44:09 -05:00
echo "卸载完成"
2019-03-05 06:20:04 -05:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_rsyncd
else
Uninstall_rsyncd
fi