自动部署ftp脚本
Posted dccrussell
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动部署ftp脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash #author:dcc #date:2018/05/25 #version:v1 #description:install vsftpd if [ ! -d "$HOME/mylog" ];then mkdir $HOME/mylog fi log_path="$HOME/mylog/install.log" #test yum whether can use? test01=`yum repolist | grep ‘repolist: ‘|sed -n ‘s/repolist: //p‘` if [ "$test01" == "0" ];then echo "error_code:1;the yum.repo can‘t be used" >> $log_path echo "Error:yum can not be used" exit 1 fi #install echo "`date`:install ftp start:" >> $log_path yum -y install vsftpd >> $log_path #check rpm -q vsftpd &> /dev/null if [ $? -eq 0 ];then systemctl restart vsftpd &> /dev/null systemctl enable vsftpd &> /dev/null else echo "vsftpd install failed" >> $log_path exit 2 fi #check systemctl status vsftpd | grep ‘running‘ &> /dev/null if [ ! $? -eq 0 ];then echo "start vsftpd failed" >> $log_path exit 3 else echo "start vsftpd success" >> $log_path fi #firewall config firewall-cmd --permanent --zone=trusted --add-service=ftp &> /dev/null if [ $? -eq 0 ];then firewall-cmd --reload &> /dev/null if [ $? -eq 0 ];then echo success exit 0 else echo "firewall reload failed" >> $log_path exit 4 fi else echo "firewall set failed" >> $log_path exit 5 fi
以上是关于自动部署ftp脚本的主要内容,如果未能解决你的问题,请参考以下文章