Linux常用软件安装脚本

tech2023-03-07  140

安装JDK

jieya(){ cd /opt if test -e $a then tar -zxvf $a echo "解压完成" else echo "安装包不存在" result=$? fi } peizhi(){ cd jdk1.8.0_221/ echo "export JAVA_HOME=/opt/jdk1.8.0_221 export CLASSPATH=.:\$JAVA_HOME/lib/rt.jar:\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar export PATH=\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin:\$PATH" >> /etc/profile echo "配置完成" result=$? } sleep 5 sce(){ source /etc/profile result=$? } jieya peizhi sce exit $result

安装完成后可以java -version查看java版本,如果失败可以输入 source /etc/profile 之后再次查看

安装mysql

#!/bin/bash a="client文件路径" b="server文件路径" inyum(){ yum install -y perl yum install -y net-tools yum install -y autoconf echo "依赖包安装完成" result=$? } insql(){ if test -e $a -a -e $b then rpm -ivh $a rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps rpm -ivh $b else echo "文件不存在" fi echo "安装包解压完成,开始配置文件" echo "[client] default-character-set=utf8 [mysqld] skip-grant-tables character_set_server=utf8 collation_server=utf8_general_ci" >> /usr/my.cnf result=$? echo "配置完成" } setpwd(){ echo "正在修改密码" service mysql start mysql << EOF use mysql; update user set password=password('ok'); quit; EOF sed -c '6c #skip-grant-tables' /uer/my.cnf service mysql restart echo "密码修改完成" mysql -uroot -pok <<EOF set password=password('ok'); use mysql; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'ok' WITH GRANT OPTION; FLUSH PRIVILEGES; EOF } inyum insql setpwd exit $result

svn

#!/bin/bash result=1 inyum(){ yum install -y subversion result=$? echo "安装完成" } peizhi(){ mkdir -p /svndata/project svnadmin create /svndata/project/jdbc cd /svndata/project/jdbc/conf echo "[/] root = rw" >> authz echo "root = 1" >> passwd echo "anon-access=none auth-access=write password-db=passwd authz-db=authz" >> svnserve.conf result=$? echo "配置完成" } inyum peizhi exit $result

tomcat

#!/bin/bash a="apache-tomcat-8.5.45.zip" inzip(){ yum install -y unzip yum install -y zip result=$? } intomcat(){ cd /opt if test -e $a then unzip $a fi result=$? } start(){ mv apache-tomcat-8.5.45 tomcat8 cd tomcat8 chmod +x ./bin/* ./bin/startup.sh result=$? } inzip intomcat start exit $result
最新回复(0)