1 Star 0 Fork 52

山东元政数字技术有限公司/UnifiedDeploymentPlatform

forked from java110/HCDoc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ftpd.sh 6.28 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
public_file=/hcdemo/shellinstall/dlurl.sh
if [ ! -f $public_file ];then
mkdir -p /hcdemo/shellinstall/
wget -O $public_file https://dl.winqi.cn/install/install/dlurl.sh -T 20;
fi
. $public_file
download_Url=${NODE_URL}/install
Root_Path=`cat /var/hc_setupPath.conf`
Setup_Path=$Root_Path/server/pure-ftpd
run_path='/root'
pure_ftpd_version='1.0.49'
[ -z "${cpuCore}" ] && cpuCore="1"
#Install_Yum为临时依赖模块,正式一键标本会移除!!!!
Install_Yum(){
Run_User="www"
wwwUser=$(cat /etc/passwd|grep www)
if [ "${wwwUser}" == "" ];then
groupadd ${Run_User}
useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
fi
yumPacks="wget tar zip unzip openssl openssl-devel gcc libxml2 libxml2-devel libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs icu libicu-devel c-ares"
yum install -y ${yumPacks}
}
Service_Add(){
if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
chkconfig --add pure-ftpd
chkconfig --level 2345 pure-ftpd on
elif [ "${PM}" == "apt-get" ]; then
update-rc.d pure-ftpd defaults
fi
}
Service_Del(){
if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
chkconfig --del pure-ftpd
chkconfig --level 2345 pure-ftpd off
elif [ "${PM}" == "apt-get" ]; then
update-rc.d pure-ftpd remove
fi
}
Install_Pureftpd()
{
cd ${run_path}
rm -rf ${Setup_Path}
rm -f /etc/init.d/pure-ftpd
if [ ! -f "pure-ftpd-${pure_ftpd_version}.tar.gz" ];then
wget ${download_Url}/src/pure-ftpd-${pure_ftpd_version}.tar.gz -T 20
fi
tar -zxf pure-ftpd-${pure_ftpd_version}.tar.gz
cd pure-ftpd-${pure_ftpd_version}
echo "Installing pure-ftpd..."
./configure --prefix=${Setup_Path} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc2640 --with-ftpwho --with-tls
make && make install
if [ ! -f "${Setup_Path}/bin/pure-pw" ];then
echo '========================================================'
GetSysInfo
echo -e "ERROR: pure-ftpd installation failed.";
rm -rf ${Setup_Path}
exit 0;
fi
echo "Copy configure files..."
wget ${download_Url}/install/src/pure-config.pl -T20
\cp pure-config.pl ${Setup_Path}/sbin/
chmod 755 ${Setup_Path}/sbin/pure-config.pl
sed -i "s@/usr/local@$Root_Path/server@g" ${Setup_Path}/sbin/pure-config.pl
mkdir ${Setup_Path}/etc
wget -O ${Setup_Path}/etc/pure-ftpd.conf ${download_Url}/conf/pure-ftpd.conf -T20
wget -O /etc/init.d/pure-ftpd ${download_Url}/init/pureftpd.init -T20
chmod +x /etc/init.d/pure-ftpd
touch ${Setup_Path}/etc/pureftpd.passwd
touch ${Setup_Path}/etc/pureftpd.pdb
StartUp pureftpd
cd ${run_path}
rm -rf pure-ftpd*
if [[ -s ${Setup_Path}/sbin/pure-config.pl && -s ${Setup_Path}/etc/pure-ftpd.conf && -s /etc/init.d/pure-ftpd ]]; then
echo "Starting pureftpd..."
if [ -f "/hcdemo/backup/ftpd_backup.pdb" ];then
\cp -a -r /hcdemo/backup/ftpd_backup.pdb ${Setup_Path}/etc/pureftpd.pdb
fi
if [ -f "/hcdemo/backup/ftpd_backup.passwd" ];then
\cp -a -r /hcdemo/backup/ftpd_backup.passwd ${Setup_Path}/etc/pureftpd.passwd
fi
if [ -f "/hcdemo/backup/ftpd_backup.conf" ];then
\cp -a -r /hcdemo/backup/ftpd_backup.conf ${Setup_Path}/etc/pure-ftpd.conf
fi
address=`curl https://dl.winqi.cn/api/getIpAddress`
if [ "$address" == "" ];then
address='hc.demo.winqi.cn';
fi
mkdir -p /etc/ssl/private
openssl req -x509 -nodes -days 3560 -newkey rsa:1024 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem<<EOF
CN
Chongqing
Changshou
HC-DEMO
HC:
$address
hcdemo@winqi.cn
EOF
if [ -f '/etc/ssl/private/pure-ftpd.pem' ];then
chmod 600 /etc/ssl/private/pure-ftpd.pem
Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -i centos)
DEBIAN_CHECK=$(cat /etc/issue|grep Debian|grep 10)
if [ "${DEBIAN_CHECK}" == "${Centos8Check}" ];then
sed -i "s/# TLS/TLS/" /hcdemo/server/pure-ftpd/etc/pure-ftpd.conf
fi
fi
/etc/init.d/pure-ftpd start
echo "${pure_ftpd_version}" > ${Setup_Path}/version.pl
else
echo "Pureftpd install failed!"
fi
}
Update_Pureftpd(){
cd ${run_path}
mkdir -p ${Setup_Path}/src
rm -rf ${Setup_Path}/src/*
cd ${Setup_Path}/src
\cp -a -r ${Setup_Path}/etc/pureftpd.pdb /hcdemo/backup/ftpd_backup.pdb
\cp -a -r ${Setup_Path}/etc/pureftpd.passwd /hcdemo/backup/ftpd_backup.passwd
\cp -a -r ${Setup_Path}/etc/pure-ftpd.conf /hcdemo/backup/ftpd_backup.conf
if [ ! -f "pure-ftpd-${pure_ftpd_version}.tar.gz" ];then
wget ${download_Url}/src/pure-ftpd-${pure_ftpd_version}.tar.gz -T 20
fi
tar -zxf pure-ftpd-${pure_ftpd_version}.tar.gz
cd pure-ftpd-${pure_ftpd_version}
echo "Installing pure-ftpd..."
./configure --prefix=${Setup_Path} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc2640 --with-ftpwho --with-tls
make && make install
\cp -a -r /hcdemo/backup/ftpd_backup.pdb ${Setup_Path}/etc/pureftpd.pdb
\cp -a -r /hcdemo/backup/ftpd_backup.passwd ${Setup_Path}/etc/pureftpd.passwd
\cp -a -r /hcdemo/backup/ftpd_backup.conf ${Setup_Path}/etc/pure-ftpd.conf
/etc/init.d/pure-ftpd restart
echo "${pure_ftpd_version}" > ${Setup_Path}/version.pl
rm -f ${Setup_Path}/version_check.pl
}
Uninstall_Pureftpd()
{
if [ -f "/hcdemo/server/pure-ftpd/sbin/pure-ftpd" ];then
\cp -a -r ${Setup_Path}/etc/pureftpd.pdb /hcdemo/backup/ftpd_backup.pdb
\cp -a -r ${Setup_Path}/etc/pureftpd.passwd /hcdemo/backup/ftpd_backup.passwd
\cp -a -r ${Setup_Path}/etc/pure-ftpd.conf /hcdemo/backup/ftpd_backup.conf
/etc/init.d/pure-ftpd stop
pkill -9 pure-ftpd
chkconfig --del pure-ftpd
rm -f /etc/init.d/pure-ftpd
rm -rf $Setup_Path
fi
}
actionType=$1
if [ "$actionType" == 'install' ];then
Install_Yum #正式版会移除该模块
Install_Pureftpd
Service_Add
elif [ "$actionType" == 'uninstall' ];then
Service_Del
Uninstall_Pureftpd
elif [ "$actionType" == 'update' ]; then
Update_Pureftpd
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/sdyzsz/UnifiedDeploymentPlatform.git
git@gitee.com:sdyzsz/UnifiedDeploymentPlatform.git
sdyzsz
UnifiedDeploymentPlatform
UnifiedDeploymentPlatform
master

搜索帮助