/dev/null systemctl stop firewalld set_shell脚本一键安装je">
赞
踩
#!/usr/bin/bash ##jenkins ##ShanHai git_install(){ echo "即将部署git,请耐心等待" yum install net-tools make curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y &>/dev/null systemctl stop firewalld setenforce 0 &>/dev/null tar xf git-2.9.5.tar.gz &>/dev/null cd git-2.9.5 echo "即将进行编译安装,时间较长,请耐心等待~" make prefix=/usr/local/git all &>/dev/null make prefix=/usr/local/git install &>/dev/null echo "编译安装完成,即将设置配置文件" cd ~/7.jenkins cat /etc/bashrc | grep JAVA &>/dev/null if [ $? -eq 0 ];then echo "配置文件已设置,无需操作" else echo "配置文件未设置,即将设置" cat >>/etc/bashrc<<-EOF PATH=\$PATH:\$HOME/bin:/usr/local/git/bin JAVA_HOME=/usr/local/jdk export PATH=\$PATH:\$JAVA_HOME/bin export M2_HOME=/usr/local/maven export M2=\$M2_HOME/bin PATH=\$M2:\$PATH:\$HOME/bin:/usr/local/git/bin export JAVA_HOME=/usr/local/jdk export PATH CATALINA_HOME=/usr/local/tomcat export CATALINA_HOME EOF echo "配置文件设置成功" fi source /etc/bashrc git --version &>/dev/null if [ $? -eq 0 ];then echo "git 部署成功" else echo "git 部署失败,请手动检查" fi } jdk_install(){ echo "即将部署jdk,请耐心等待" tar xvzf jdk-8u151-linux-x64.tar.gz -C /usr/local &>/dev/null cd /usr/local mv jdk1.8.0_151 jdk cd ~/7.jenkins source /etc/bashrc java -version &>/dev/null if [ $? -eq 0 ];then echo "jdk 部署成功" else echo "jdk 部署失败,请手动检查" fi } maven_install(){ echo "即将部署maven,请耐心等待" tar xvzf apache-maven-3.5.3-bin.tar.gz -C /usr/local &>/dev/null mv /usr/local/apache-maven-3.5.3/ /usr/local/maven source /etc/bashrc mvn -version &>/dev/null if [ $? -eq 0 ];then echo "maven 部署成功" else echo "maven 部署失败,请手动检查" fi } tomcat_install(){ echo "即将部署tomcat,请耐心等待" tar xvzf apache-tomcat-9.0.1.tar.gz -C /usr/local &>/dev/null mv /usr/local/apache-tomcat-9.0.1/ /usr/local/tomcat source /etc/bashrc echo "即将启动tomcat" /usr/local/tomcat/bin/startup.sh &>/dev/null sleep 5 netstat -ntlp | grep 8080 &>/dev/null if [ $? -eq 0 ];then echo "tomcat 启动成功" echo "启动成功,即将自动关闭" sleep 5 /usr/local/tomcat/bin/shutdown.sh &>/dev/null pkill java sleep 5 netstat -ntlp | grep 8080 &>/dev/null if [ $? -eq 0 ];then echo "tomcat 关闭失败" else echo "tomcat 关闭成功" fi else echo "tomcat 启动失败,请手动检查" fi } jenkins_install(){ echo "即将部署jenkins,请耐心等待" cp jenkins.war /usr/local/tomcat/webapps/ echo "即将启动tomcat" /usr/local/tomcat/bin/startup.sh &>/dev/null sleep 5 netstat -ntlp | grep 8080 &>/dev/null if [ $? -eq 0 ];then echo "tomcat 启动成功" echo "jenkins部署成功,密码为:" cat /root/.jenkins/secrets/initialAdminPassword else echo "tomcat 启动失败,请手动检查" fi } get_keygen(){ echo "即将进行免密设置,请耐心等候" yum -y install expect &>/dev/null /usr/bin/expect <<-EOF spawn ssh-keygen expect { ".ssh/id_rsa):" { send "\r"; exp_continue } "Overwrite (y/n)?" { send "y\r"; exp_continue } "no passphrase):" { send "\r"; exp_continue } "again:" { send "\r" }; } expect eof EOF } send_key(){ /usr/bin/expect <<-EOF spawn ssh-copy-id -i 192.168.218.155 expect { "yes/no" { send "yes\r"; exp_continue } "password:" { send "1\r" }; } expect eof EOF echo "免密设置成功,即将免密登陆" ssh 192.168.218.155 } git_install jdk_install maven_install tomcat_install jenkins_install get_keygen send_key
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。