Centos 6.4上面用Shell脚本一键安装vsftpd

时间:2021-06-07 15:42:55

Centos 6.4上面用Shell脚本一键安装vsftpd

install.sh

#!/bin/bash

if [ `uname -m` == "x86_64" ];then
machine=x86_64
else
machine=i686
fi
ifrpm=$(cat /proc/version | grep -E "redhat|centos")
ifdpkg=$(cat /proc/version | grep -Ei "ubuntu|debian")
ifcentos=$(cat /proc/version | grep centos) if [ "$ifrpm" != "" ];then
yum -y install vsftpd
\cp -f ./config-ftp/rpm_ftp/* /etc/vsftpd/
else
apt-get -y install vsftpd
if cat /etc/shells | grep /sbin/nologin ;then
echo ""
else
echo /sbin/nologin >> /etc/shells
fi
\cp -fR ./config-ftp/apt_ftp/* /etc/
fi if [ ! -f '/etc/vsftpd' ];then
mkdir -p /etc/vsftpd
fi if [ "$ifcentos" != "" ] && [ "$machine" == "i686" ];then
rm -rf /etc/vsftpd/vsftpd.conf
\cp -f ./config-ftp/vsftpdcentosi686.conf /etc/vsftpd/vsftpd.conf
fi if [ ! -f '/storage/vsftpd' ];then
mkdir -p /storage/vsftpd
fi result="`grep '^vsftpd' /etc/passwd | wc -l`" if [ "$result" == "" ];then groupadd vsftpd useradd -g vsftpd -s /sbin/nologin vsftpd
fi /etc/init.d/vsftpd start chown -R vsftpd:vsftpd /storage/vsftpd #bug kill: '500 OOPS: vsftpd: refusing to run with writable root inside chroot()'
chmod a-w /storage/vsftpd MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
LENGTH=""
while [ "${n:=1}" -le "$LENGTH" ]
do
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
let n+=
done
if [ "$ifrpm" != "" ];then
echo $PASS | passwd --stdin vsftpd
else
echo "vsftpd:$PASS" | chpasswd
fi sed -i s/'ftp_password'/${PASS}/g account.log

完整脚本下载:http://pan.baidu.com/s/1o6E15oA