企业常用shell脚本汇总

举报
torchstar 发表于 2022/12/20 21:44:22 2022/12/20
【摘要】 企业常用shell脚本汇总

一、数据库

#!/usr/bin/env bash

#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
mysql_dir=mysql



get_mysql() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz" "1bc406d2fe18dd877182a0bd603e7bd4"
}

install_mysql() {
	remove_mysql
    test_dir $mysql_dir

    #清理mariadb的东西
    for i in `rpm -qa | grep mariadb`; do rpm -e --nodeps $i; done
    
    test_install autoconf libaio bison ncurses-devel
    groupadd mysql
    useradd -g mysql -s /sbin/nologin mysql
    
    get_mysql
    tar -xf package/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
    mv mysql-5.6.39-linux-glibc2.12-x86_64 ${install_dir}/${mysql_dir}
    chown -R mysql:mysql ${install_dir}/${mysql_dir}
    chown -R mysql:mysql ${log_dir}/${mysql_dir}

    echo 'PATH=$PATH':${install_dir}/${mysql_dir}/bin >> /etc/profile

    clear
	echo "mysql" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${mysql_dir}

日志目录:${log_dir}/${mysql_dir}

环境变量设置完成"
	else
		echo "install ok
    
Installation manual:${install_dir}/${mysql_dir}

Log directory:${log_dir}/${mysql_dir}

Environment variable setting completed"
	fi
}

remove_mysql() {
	rm -rf ${install_dir}/${mysql_dir}
	hang=`grep -n 'PATH=$PATH':${install_dir}/${mysql_dir}/bin /etc/profile | awk -F':' '{print $1}'`
	[ ! $hang ] || sed -i "${hang} d" /etc/profile
	test_remove mysql
	[ "$language" == "cn" ] && echo "mysql卸载完成!" || echo "mysql Uninstall completed!"
}

info_mysql() {
	if [ "$language" == "cn" ];then
		echo "名字:mysql
		
版本:6.39

介绍:数据库,支持多种存储引擎
		
类型:服务"
	else
		echo "Name:mysql

Version:6.39

Introduce:Database, supports multiple storage engines

Type: server"

	fi
}

二、跳板机批量操作脚本

#!/usr/bin/env bash



get_batch() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_batch() {
	remove_batch
    test_bin batch

    clear
	echo "batch" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:/usr/local/bin/batch

启动:batch

使用说明:根据/etc/hosts文件和免密登陆来进行批量ssh操作
支持对/etc/hosts中的主机分组,需要修改脚本
支持对rm等命令进行禁用,防止批量操作产生影响,需要修改脚本"
	else
		echo "install ok
    
Start:batch

Instructions for use: batch ssh operations based on the /etc/hosts file and free login
Support for grouping hosts in /etc/hosts, need to modify the script
Supports the disablement of commands such as rm to prevent batch operations from affecting the script. You need to modify the script."
	fi
}

remove_batch() {
	rm -rf /usr/local/bin/batch
	test_remove batch
	[ "$language" == "cn" ] && echo "batch卸载完成!" || echo "batch Uninstall completed!"
}

info_batch() {
	if [ "$language" == "cn" ];then
		echo "名字:batch
		
版本:1.2

介绍:跳板机批量操作脚本
		
类型:系统管理"

	else
		echo "Name:batch

Version:1.2

Introduce:Springboard batch operation script

Type: System Management"

	fi
}

三、文档管理系统MinDoc

#!/usr/bin/env bash



#[使用设置]

#当前只支持使用sqlite3数据库安装,若使用mysql请手动安装

#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
mindoc_dir=mindoc

#端口
port=8181



get_mindoc() {
    test_package https://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/mindoc.tar.gz 3edf05c97977f71f8b052818fd5a5412
}

install_mindoc() {
    #检测目录
	remove_mindoc
    test_dir $mindoc_dir
    
    #安装服务
    get_mindoc
    tar -xf package/mindoc.tar.gz
    mv mindoc ${install_dir}/${mindoc_dir}
    
    conf=${install_dir}/${mindoc_dir}/conf/app.conf
    sed -i "s/httpport = 8181/httpport = ${port}/g" $conf
	
	chmod +x ${install_dir}/${mindoc_dir}/mindoc_linux_amd64
	${install_dir}/${mindoc_dir}/mindoc_linux_amd64 install
    
    sqlite3 -version
    [ $? -eq 0 ] || bash sai.sh install sqlite
    
    strings /lib64/libc.so.6 |grep ^GLIBC_2.14
    [ $? -eq 0 ] || bash sai.sh install glibc

    test_bin man-mindoc
    sed -i "2a install_dir=${install_dir}" $command
    sed -i "3a log_dir=${log_dir}" $command
    sed -i "4a mindoc_dir=${mindoc_dir}" $command

    clear
	echo "mindoc" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${mindoc_dir}

日志目录:${log_dir}/${mindoc_dir}

启动:man-mindoc start

访问:curl http://127.0.0.1:${port}

管理员账号:admin

管理员密码:123456"
	else
		echo "install ok
    
Installation manual:${install_dir}/${mindoc_dir}

Log directory:${log_dir}/${mindoc_dir}

Start:man-mindoc start

Access:curl http://127.0.0.1:${port}

Administrator account: admin

Administrator password: 123456"
	fi
}

remove_mindoc() {
	rm -rf /usr/local/bin/man-mindoc
	rm -rf ${install_dir}/${mindoc_dir}
	test_remove mindoc
	[ "$language" == "cn" ] && echo "mindoc卸载完成!" || echo "mindoc Uninstall completed!"
}

info_mindoc() {
	if [ "$language" == "cn" ];then
		echo "名字:mindoc
		
版本:0.9

介绍:MinDoc 是一款针对IT团队开发的简单好用的文档管理系统。
		
类型:服务"
	else
		echo "Name:mindoc

Version:0.9

Introduce:MinDoc is a simple and easy-to-use document management system developed for the IT team.

Type: server"
	fi
}

四、配置mysql多实例

#!/usr/bin/env bash



#[使用设置]

#开启实例的端口
cluster_ip=(3307 3308)



source script/mysql.sh

get_mysql_port() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_mysql_port() {
	remove_mysql_port
    [ -f ${install_dir}/${mysql_dir}/scripts/mysql_install_db ] || test_exit "请先安装mysql" "Please install mysql first"
 
     echo "[client]
port=3306
socket=${install_dir}/${mysql_dir}/mysql.sock

[mysqld_multi]
mysqld=${install_dir}/${mysql_dir}/bin/mysqld_safe
mysqladmin=${install_dir}/${mysql_dir}/bin/mysqladmin
log=${log_dir}/${mysql_dir}/mysqld_multi.log

[mysqld]
user=mysql
basedir=${install_dir}/${mysql_dir}
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"  > /etc/my.cnf #基本配置

    for i in `echo ${cluster_ip[*]}`
    do
        [ -d ${install_dir}/${mysql_dir}/data${i} ] && continue
        mkdir ${install_dir}/${mysql_dir}/data${i}
        echo "[mysqld${i}]  
mysqld=mysqld  
mysqladmin=mysqladmin  
datadir=${install_dir}/${mysql_dir}/data${i}
port=${i}
server_id=${i}  
socket=${install_dir}/${mysql_dir}/mysql_${i}.sock  
log-output=file  
slow_query_log = 1  
long_query_time = 1  
slow_query_log_file =${log_dir}/${mysql_dir}/${i}_slow.log  
log-error =${log_dir}/${mysql_dir}/${i}_error.log  
binlog_format = mixed  
log-bin =${log_dir}/${mysql_dir}/${i}_bin" >> /etc/my.cnf
echo >> /etc/my.cnf
    done
    
    chown -R mysql:mysql ${install_dir}/${mysql_dir}
    
    for i in `echo ${cluster_ip}`
    do
        ${install_dir}/${mysql_dir}/scripts/mysql_install_db --basedir=${install_dir}/${mysql_dir} --datadir=${install_dir}/${mysql_dir}/data${i} --defaults-file=/etc/my.cnf &> /dev/null
    done

	clear
	echo "mysql-port" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${mysql_dir}/data*

日志目录:${log_dir}/${mysql_dir}

启动:mysqld_multi start

访问:mysql -S ${install_dir}/${mysql_many_dir}/mysql_${i}.sock"
	else
		echo "install ok
    
Installation manual:${install_dir}/${mysql_dir}

Log directory:${log_dir}/${mysql_dir}

Start:mysqld_multi start

Environment variable setting completed

Access:mysql -S ${install_dir}/${mysql_many_dir}/mysql_${i}.sock"
	fi
}

remove_mysql_port() {
	> /etc/my.cnf
    for i in `echo ${cluster_ip[*]}`
    do
        rm -rf ${install_dir}/${mysql_dir}/data${i}
	done
	test_remove mysql-port
	[ "$language" == "cn" ] && echo "mysql_port卸载完成!" || echo "mysql_port Uninstall completed!"
}

info_mysql_port() {
	if [ "$language" == "cn" ];then
		echo "名字:mysql-port
		
版本:mysql

介绍:配置mysql多实例
		
类型:服务"
	else
		echo "Name:mysql-port

Version:mysql

Introduce:Configure mysql multiple instances

Type: server

"
	fi
}

五、配置mysql单点

#!/usr/bin/env bash



#[使用设置]

#默认端口
port=3306



source script/mysql.sh

get_mysql_single() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_mysql_single() {
	remove_mysql_single
    [ -f ${install_dir}/${mysql_dir}/scripts/mysql_install_db ] || test_exit "请先安装mysql" "Please install mysql first"
    
    echo "[mysql]
default-character-set=utf8
socket=${install_dir}/${mysql_dir}/mysql.sock
[mysqld]
skip-name-resolve
port = ${port}
socket=${install_dir}/${mysql_dir}/mysql.sock
basedir=${install_dir}/${mysql_dir}
datadir=${install_dir}/${mysql_dir}/data
max_connection=200
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M
log-error=${log_dir}/${mysql_dir}/mysql.log
pid-file=${log_dir}/${mysql_dir}/mysql.pid
bind-address = 0.0.0.0" > /etc/my.cnf #这里改需要的配置
    chown mysql:mysql /etc/my.cnf
    
    #初始化脚本
    cd ${install_dir}/${mysql_dir}
    ./scripts/mysql_install_db --user=mysql --basedir=${install_dir}/${mysql_dir} --datadir=${install_dir}/${mysql_dir}/data &> /dev/null
    
    #加入systemctl
    rm -rf /usr/lib/systemd/system/mysql.service
    echo "[Unit]
Description=mysql
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=${install_dir}/${mysql_dir}/support-files/mysql.server start
ExecReload=${install_dir}/${mysql_dir}/support-files/mysql.server restart
ExecStop=${install_dir}/${mysql_dir}/support-files/mysql.server stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target" > /usr/lib/systemd/system/mysql.service

    systemctl daemon-reload

    clear
	echo "caed-single" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${mysql_dir}

日志目录:${log_dir}/${mysql_dir}

启动:systemctl start mysql"
	else
		echo "install ok
    
Installation manual:${install_dir}/${mysql_dir}

Log directory:${log_dir}/${mysql_dir}

Start:systemctl start mysql"
	fi
}

remove_mysql_single() {
	rm -rf rm -rf /usr/lib/systemd/system/mysql.service
	> /etc/my.cnf
	test_remove mysql-single
	[ "$language" == "cn" ] && echo "mysql-single卸载完成!" || echo "mysql-single Uninstall completed!"
}

info_mysql_single() {
	if [ "$language" == "cn" ];then
		echo "名字:mysql-single
		
版本:mysql

介绍:配置mysql单点
		
类型:服务"
	else
		echo "Name:mysql-single

Version:mysql

Introduce:Configure mysql single point

Type: server"
	fi
}

六、Nginx

#!/usr/bin/env bash



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
nginx_dir=nginx



get_nginx() {
    test_package https://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/nginx-1.8.0.tar.gz 3ca4a37931e9fa301964b8ce889da8cb
}

install_nginx() {
    #检测目录
	remove_nginx
    test_dir $nginx_dir
	test_install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel 
	
	useradd -s /sbin/nologin nginx
	get_nginx
    tar -xf package/nginx-1.8.0.tar.gz
	cd nginx-1.8.0
	#这里指定模块,请按需求添加
	./configure --prefix=${install_dir}/${nginx_dir} --user=nginx --group=nginx --with-http_ssl_module --error-log-path=${log_dir}/${nginx_dir}/error.log --http-log-path=${log_dir}/${nginx_dir}/access.log
	make && make install

	ln -s ${install_dir}/${nginx_dir}/sbin/nginx /usr/local/bin/nginx
	nginx -v
	[ $? -eq 0 ] || test_exit "安装失败,请检查脚本" "Installation failed, please check the script"

    clear
	echo "nginx" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${nginx_dir}

日志目录:${log_dir}/${nginx_dir}

启动:nginx

关闭:nginx -s stop

访问:curl http://127.0.0.1:80"
	else
		echo "install ok
    
Installation manual:${install_dir}/${nginx_dir}

Log directory:${log_dir}/${nginx_dir}

Start:nginx

Stop:nginx -s stop

Access:curl http://127.0.0.1:80"
	fi
}

remove_nginx() {
	userdel -r nginx
	rm -rf ${install_dir}/${nginx_dir}
	test_remove nginx
	[ "$language" == "cn" ] && echo "nginx卸载完成!" || echo "nginx Uninstall completed!"
}

info_nginx() {
	if [ "$language" == "cn" ];then
		echo "名字:nginx
		
版本:1.8.0

介绍:Nginx是一款轻量的web服务器
		
类型:服务
"
	else
		echo "Name:nginx

Version:1.8.0

Introduce:Nginx is a lightweight web server

Type: server"
	fi
}

七、Node.js

#!/usr/bin/env bash

#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#服务目录名
modejs_dir=nodejs

get_nodejs() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/node-v8.9.3-linux-x64.tar.xz" "32948a8ca5e6a7b69c03ec1a23b16cd2"
}

install_nodejs() {
    #检测目录
    remove_nodejs
    test_dir $nodejs_dir

    get_nodejs
    tar -xf package/node-v8.9.3-linux-x64.tar.xz
    mv node-v8.9.3-linux-x64 ${install_dir}/${nodejs_dir}
    
    #链接
	rm -rf /usr/local/bin/node
    rm -rf /usr/local/bin/npm
    ln -s ${install_dir}/${nodejs_dir}/bin/node /usr/local/bin/node
    ln -s ${install_dir}/${nodejs_dir}/bin/npm /usr/local/bin/npm

    #对结果进行测试
    node -v
    [ $? -eq 0 ] || test_exit "Installation failed, please check the installation script"
    
    clear
	echo "nodejs" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${nodejs_dir}

环境变量设置完成"
	else
		echo "install ok
    
Installation manual:${install_dir}/${nodejs_dir}

Environment variable setting completed"
	fi
}

remove_nodejs() {
    rm -rf /usr/local/bin/node
    rm -rf /usr/local/bin/npm
	rm -rf ${install_dir}/${nodejs_dir}
	test_remove nodejs
	[ "$language" == "cn" ] && echo "nodejs卸载完成!" || echo "nodejs Uninstall completed!"
}

info_nodejs() {
	if [ "$language" == "cn" ];then
		echo "名字:nodejs
		
版本:8.9.3

介绍: Node.js 就是运行在服务端的 JavaScript。
		
类型:语言"
	else
		echo "Name:nodejs

Version:8.9.3

Introduce:Node.js is JavaScript that runs on the server.

Type: Language"
	fi
}

八、防弱密码爆破脚本

#!/usr/bin/env bash



get_notty() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_notty() {
	remove_notty
    test_bin notty

    clear
	echo "notty" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:/usr/local/bin/notty

启动:notty

修改:修改失败次数请编辑脚本文件

建议:建议将脚本加入crontab"
	else
		echo "install ok

Start:notty

Modify: modify the number of failures, please edit the script file

Recommendation: It is recommended to add the script to the crontab"
	fi
}

remove_notty() {
	rm -rf /usr/local/bin/notty
	test_remove notty
	[ "$language" == "cn" ] && echo "notty卸载完成!" || echo "notty Uninstall completed!"
}

info_notty() {
	if [ "$language" == "cn" ];then
		echo "名字:notty
		
版本:1.2

介绍:防弱密码爆破脚本,5次登陆系统失败的ip会被禁止
		
类型:系统管理"
	else
		echo "Name:notty

Version:1.2

Introduce:Anti-weak password cracking script, 5 failed login ip will be forbidden

Type: System Management"
	fi
}

九、安装python3.6

#!/usr/bin/env bash



#主目录
#install_dir=

#服务目录
#python_dir=python3.6



get_python() {
	test_package https://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/Python-3.6.0.tgz 3f7062ccf8be76491884d0e47ac8b251
}

install_python() {
	remove_python
	test_dir $python_dir
	test_install gcc make cmake openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
	tar -xf package/Python-3.6.0.tgz
	cd Python-3.6.0
	./configure --prefix=${install_dir}/${python_dir}
	make
	make altinstall
	
	#备份python2的连接命令
	mv /usr/bin/python /usr/bin/python.back
	
	#将3的连接默认
	ln -s /usr/local/python3.6/bin/python3.6 /usr/local/bin/python
	ln -s /usr/local/python3.6/bin/python3.6 /usr/local/bin/python3
	
	#修改yum的默认解释器
	sed -i 's,#!/usr/bin/python,#!/usr/bin/python2,g' /usr/bin/yum
	#修改gnome-tweak-tool
	[ -f /usr/bin/gnome-tweak-tool ] && sed -i 's,#!/usr/bin/python,#!/usr/bin/python2,g' /usr/bin/gnome-tweak-tool
	#修改urlgrabber
	[ -f /usr/libexec/urlgrabber-ext-down ] && ed -i 's,#!/usr/bin/python,#!/usr/bin/python2,g' /usr/libexec/urlgrabber-ext-down

	#测试
	python --version |grep 3.6.0
	[ $? -eq 0 ] || test_exit "安装失败,请查看脚本" "Installation failed, please check the script"
	
    #完成
    clear
	echo "python" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:${install}/${python_dir}

python2的默认链接存放/usr/bin/python.back

当前默认python解释器为python3的"
	else
		echo "install ok

Installation directory: ${install}/${python_dir}

The default link for python2 is /usr/bin/python.back

The current default python interpreter is python3"
	fi
}

remove_python() {
	rm -rf ${install_dir}/${python_dir}
	rm -rf /usr/bin/python
	rm -rf /usr/bin/python3
	mv /usr/bin/python.back /usr/bin/python
	test_remove python
	[ "$language" == "cn" ] && echo "python卸载完成!" || echo "Python uninstall complete"
}

info_python() {
	if [ "$language" == "cn" ];then
		echo "名字:python
		
版本:3.6

介绍:安装python3.6
		
类型:语言"
	else
		echo "Name:python

Version:3.6

Introduce:Install python3.6

Type: Language"
	fi
}

十、Redis

#!/usr/bin/env bash



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
redis_dir=redis



get_redis() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/redis-3.2.9.tar.gz" "0969f42d1675a44d137f0a2e05f9ebd2"
}

install_redis() {
    #检测目录
	remove_redis
    test_dir $redis_dir
    
    #安装服务
    get_redis
    tar -xf package/redis-3.2.9.tar.gz
    mv redis ${install_dir}/${redis_dir}
    
    #环境变量
    echo 'PATH=$PATH':${install_dir}/${redis_dir}/bin >> /etc/profile
    
    #测试
    source /etc/profile
    which redis-cli
    [ $? -eq 0 ] || test_exit "Installation failed, please check the script" 

    clear
	echo "redis" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${redis_dir}

日志目录:${log_dir}/${redis_dir}

环境变量设置完成"
	else
		echo "install ok
    
Installation manual:${install_dir}/${redis_dir}

Log directory:${log_dir}/${redis_dir}

Environment variable setting completed"
	fi
}

remove_redis() {
	rm -rf ${install_dir}/${redis_dir}
	hang=`grep -n 'PATH=$PATH':${install_dir}/${redis_dir}/bin /etc/profile | awk -F':' '{print $1}'`
	[ ! $hang ] || sed -i "${hang} d" /etc/profile
	test_remove redis
	[ "$language" == "cn" ] && echo "redis卸载完成!" || echo "redis Uninstall completed!"
}

info_redis() {
	if [ "$language" == "cn" ];then
		echo "名字:redis
		
版本:3.2.9

介绍:开源的内存数据库,常用作缓存或者消息队列。
		
类型:服务"
	else
		echo "Name:redis

Version:3.2.9

Introduce:Open source memory database, often used as a cache or message queue.

Type: server"
	fi
}

十一、redis的web端管理工具

#!/usr/bin/env bash
#redis-browser,redis的可视化工具


#[使用设置]
#主目录,相当于/usr/local
#install_dir=

#日志主目录
#log_dir=

#服务目录名
redis_browser_dir=redis-browser

#填写redis的主机名节点,最少2个
cluster_name=(service1 service2 service3)
cluster_ip=(192.168.2.108:7000 192.168.2.108:7002 192.168.2.108:7004) 

#redis_browser的端口
port=1212

#redis_browser监听
listen=0.0.0.0



get_redis_browser() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/redis-4.0.1.gem" "a4b74c19159531d0aa4c3bf4539b1743"
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/redis-browser-0.5.1.gem" "dbe6a5e711dacbca46e68b10466d9da4"
}

install_redis_browser() {
	remove_redis_browser
    test_dir $redis_browser_dir
    
    test_install gem
	test_rely nodejs ruby
    
    get_redis_browser
    gem update —system
    gem sources —add https://gems.ruby-china.org/ —remove https://rubygems.org/
    gem sources -l
    gem install material/redis-4.0.1.gem
    gem install material/redis-browser-0.5.1.gem
    
    d=1 #名字,从第2个起
    echo "connections:" >> ${install_dir}/${redis_browser_dir}/config.yml
    
    for i in `echo ${cluster_ip[*]}`
    do
        if [ "$i" == "${cluster_ip[0]}" ];then #第一个跳过做默认
            continue
        fi
        
        b=`echo $i | awk -F':' '{print $1}'` 
        c=`echo $i | awk -F':' '{print $2}'`
        cp material/redis_browser.yuml ./one #复制一份格式文件做修改
        
        sed -i "1s/service3:/${cluster_name[$d]}" one
        sed -i "2s/host: 192.168.1.3/host: $b/g" one
        sed -i "3s/port: 7004/port: $c/g" one
        sed -i "5s,url_db_0: redis://192.168.1.3:7004/0,url_db_0: redis://${i}/0,g" one
        cat one >> ${install_dir}/${redis_browser_dir}/config.yml
        let d++
        rm -rf one
    done

    #启动脚本
    test_bin man-redis-browser
    sed -i "2a port=${port}" $command
    sed -i "3a listen=${listen}" $command
    sed -i "4a install_dir=$install_dir" $command
    sed -i "5a log_dir=$log_dir" $command
    sed -i "6a redis_browser_dir=$redis_browser_dir" $command
    sed -i "7a one=${cluster_ip}" $command

    #测试
    
    
    clear
	echo "redis-browser" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${redis_browser_dir}

日志目录:${log_dir}/${redis_browser_dir}

启动:man-redis-browser start

访问:curl http://127.0.0.1:${port}"
	else
		echo "install ok
    
Installation manual:${install_dir}/${redis_browser_dir}

Log directory:${log_dir}/${redis_browser_dir}

Start:man-redis-browser start

Access:curl http://127.0.0.1:${port}"
	fi
}

remove_redis_browser() {
	rm -rf ${install_dir}/${redis_browser_dir}
	rm -rf /usr/local/bin/man-redis-browser
	test_remove redis-browser
	[ "$language" == "cn" ] && echo "redis-browser卸载完成!" || echo "redis-browser Uninstall completed!"
}


info_redis_browser() {
	if [ "$language" == "cn" ];then
		echo "名字:redis-browser
		
版本:0.5.1

介绍:redis的web端管理工具
		
类型:服务"
	else
		echo "Name:redis-browser

Version:0.5.1

Introduce:Redis web-side management tool

Type: server"
	fi
}

十二、配置redis集群

#!/usr/bin/env bash
#此脚本将创建集群,需要设置端口


#[使用设置]

#所有要加入集群的节点,前一半节点皆为主
cluster_ip="127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005"

#默认1主1从,设置2就是1主2从
node=1



source script/redis.sh

get_redis_cluster() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/redis-4.0.1.gem" "a4b74c19159531d0aa4c3bf4539b1743"
}

install_redis_cluster() {  
	remove_redis_cluster
    [ -f ${install_dir}/${redis_dir}/src/redis-trib.rb ] || test_exit "请先安装redis"

    get_redis_cluster
    test_install ruby-devel rubygems rpm-build
    test_rely ruby
    gem install package/redis-4.0.1.gem
    
    #启动
    ${install_dir}/${redis_dir}/src/redis-trib.rb create --replicas ${node} ${cluster_ip}
}

remove_redis_cluster() {
	[ "$language" == "cn" ] && echo "redis-cluster无法卸载,需要每个节点删除存储文件再重新创建集群!" || echo "Redis-cluster cannot be unloaded. Each node needs to delete the storage file and re-create the cluster!"
}

info_redis_cluster() {
	if [ "$language" == "cn" ];then
		echo "名字:redis-cluster
		
版本:redis

介绍:配置redis集群,需要先创建多个节点
		
类型:服务"
	else
		echo "Name:redis-cluster

Version:redis

Introduce:Configure a redis cluster, you need to create multiple nodes first

Type: server"
	fi
}

十三、配置redis多实例

#!/usr/bin/env bash
#启动多个端口


#[使用设置]

#将安装如下端口实例
port=(6379)

#监听ip
listen=0.0.0.0



#加载依赖
source script/redis.sh

get_redis_port() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_redis_port() {
	remove_redis_port
    [ -d ${install_dir}/${redis_dir} ] || test_exit "请先安装redis"

    get_redis_port
    for i in `echo ${port[*]}`
    do
        command=/usr/local/bin/man-redis${i} #创建单独管理脚本
        if [ ! -f $command ];then
            cp material/man-redis $command
        
            sed -i "2a port=${i}" $command
            sed -i "3a install_dir=${install_dir}" $command
            sed -i "4a log_dir=${log_dir}" $command
            sed -i "5a redis_dir=${redis_dir}" $command
        
            chmod +x $command
        else
            continue #如果管理脚本存在,则跳过这个端口
        fi

        conf=${install_dir}/${redis_dir}/cluster/${i}/${i}.conf
        
        mkdir -p ${install_dir}/${redis_dir}/cluster/${i}
        cp material/redis_7000.conf $conf
        
        sed -i "s/^bind 127.0.0.1/bind ${listen}/g" $conf
        sed -i "/^port/cport ${i}" $conf
        sed -i "/^cluster-config-file/ccluster-config-file nodes_${i}.conf" $conf
        sed -i "/^pidfile/cpidfile redis_${i}.pid" $conf
        sed -i "/^dir/cdir ${install_dir}/${redis_dir}/cluster/${i}" $conf 
    done

    #创建总管理脚本
    echo '#!/bin/bash

for i in `ls /usr/local/bin/man-redis*`
do  
    [ "$i" == "/usr/local/bin/man-redis" ] && continue || $i $1
done' >> /usr/local/bin/man-redis
    chmod +x /usr/local/bin/man-redis

    clear
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${redis_dir}

日志目录:${log_dir}/${redis_dir}

启动:man-redis start"
	else
		echo "install ok
    
Installation manual:${install_dir}/${redis_dir}

Log directory:${log_dir}/${redis_dir}

Start:man-redis start"
	fi
}

remove_redis_port() {
	rm -rf /usr/local/bin/man-redis
	for i in `echo ${port[*]}`
    do
		rm -rf /usr/local/bin/man-redis${i}
		rm -rf ${install_dir}/${redis_dir}/cluster/${i}
		[ "$language" == "cn" ] && echo "节点${i}卸载完成!" || echo "node${i} Uninstall completed!"
	done
}

info_redis_port() {
	if [ "$language" == "cn" ];then
		echo "名字:redis-port
		
版本:redis

介绍:配置redis多实例
		
类型:服务"
	else
		echo "Name:redis-port

Version:redis

Introduce:Configure redis multi-instance

Type: server"
	fi
}

十四、Ruby

#!/usr/bin/env bash



get_ruby() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_ruby() {
    remove_ruby

    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
	\curl -sSL https://get.rvm.io | bash -s stable
    
	[ -f /etc/profile.d/rvm.sh ] || test_exit "rvm下载失败,请重新安装ruby" "Rvm download failed, please re-install ruby"
    
	#设置环境变量
    echo source /etc/profile.d/rvm.sh >> ~/.bashrc
    source ~/.bashrc
    echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db

    #安装
    rvm install 2.4.1
    rvm use 2.4.1 --default
	
	#测试
	rvm use 2.4.1 --default
	[ $? -eq 0 ] || test_exit "ruby安装失败,请检查脚本" "Ruby installation failed, please check the script"
    
    clear
	echo "ruby" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:/usr/local/rvm

环境变量设置完成"
	else
		echo "install ok
    
Installation manual:/usr/local/rvm

Environment variable setting completed"
	fi
}

remove_ruby() {
	[ "$language" == "cn" ] && echo "当前不支持卸载" || echo "Does not currently support uninstallation"
}

info_ruby() {
	if [ "$language" == "cn" ];then
		echo "名字:ruby
		
版本:2.4.1

介绍:Ruby,一种简单快捷的面向对象(面向对象程序设计)脚本语言
		
类型:语言"
	else
		echo "Name:ruby

Version:2.4.1

Introduce:Ruby, a simple and fast object-oriented (object-oriented programming) scripting language

Type: Language"
	fi
}

十五、SQLite

#!/usr/bin/env bash



get_sqlite() {
    test_package http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/sqlite-snapshot-201803072139.tar.gz b2447f8009fba42eabaeef6fcf208e2c
}

install_sqlite() {
    #检测目录
	remove_sqlite
    test_dir $sqlite_dir
    test_install gcc cmake
    
    #安装服务
    get_sqlite
    tar -xf package/sqlite-snapshot-201803072139.tar.gz
    cd sqlite-snapshot-201803072139
    ./configure
    make && make install
    
    #测试
    sqlite3 -version
    [ $? -eq 0 ] || test_exit "安装错误,请检查脚本" "Installation error, please check the script"

    clear
    echo "sqlite" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${sqlite_dir}

环境变量设置完成"
	else
		echo "install ok
    
Installation manual:${install_dir}/${sqlite_dir}

Environment variable setting completed"
	fi
}

remove_sqlite() {
	[ "$language" == "cn" ] && echo "当前不支持卸载" || echo "Does not currently support uninstallation"
}

info_sqlite() {
	if [ "$language" == "cn" ];then
		echo "名字:sqlite
		
版本:3.23.0

介绍:SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统
		
类型:服务"
	else
		echo "Name:sqlite

Version:6.39

Introduce:SQLite, a lightweight database, is a relational database management system that adheres to ACID

Type: server"
	fi
}

十六、俄罗斯方块小游戏

#!/usr/bin/env bash



get_tetris() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_tetris() {
	remove_tetris
    test_bin tetris

    clear
	echo "tetris" >> conf/installed.txt
    if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:/usr/local/bin/tetris

启动:tetris"
	else
		echo "install ok
    
Installation manual:/usr/local/bin/tetris

Start:tetris"
	fi
}

remove_tetris() {
	rm -rf /usr/local/bin/tetris
	test_remove tetris
	[ "$language" == "cn" ] && echo "tetris卸载完成!" || echo "tetris Uninstall completed!"
}

info_tetris() {
	if [ "$language" == "cn" ];then
		echo "名字:tetris
		
版本:1.0

介绍:俄罗斯方块小游戏
		
类型:休闲游戏"
	else
		echo "Name:tetris

Version:1.0

Introduce:Tetris Games

Type: casual games"
	fi
}

十七、ZooKeeper

#!/usr/bin/env bash



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
zookeeper_dir=zookeeper



get_zookeeper() {
    test_package http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/zookeeper-3.5.2-alpha.tar.gz adc27d412f283c0dc6ec9d08e30f4ec0
}

install_zookeeper() {
    #检测目录
	remove_zookeeper
    test_dir $zookeeper_dir
    test_rely jdk

    get_zookeeper
    tar -xf   package/zookeeper-3.5.2-alpha.tar.gz
    mv zookeeper-3.5.2-alpha ${install_dir}/${zookeeper_dir}

    #测试
    
    clear
	echo "zookeeper" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${zookeeper_dir}

日志目录:${log_dir}/${zookeeper_dir}"
	else
		echo "install ok
    
Installation manual:${install_dir}/${zookeeper_dir}

Log directory:${log_dir}/${zookeeper_dir}"
	fi
}

remove_zookeeper() {
	rm -rf ${install_dir}/${zookeeper_dir}
	test_remove zookeeper
	[ "$language" == "cn" ] && echo "zookeeper卸载完成!" || echo "zookeeper Uninstall completed!"
}

info_zookeeper() {
	if [ "$language" == "cn" ];then
		echo "名字:zookeeper
		
版本:3.5.2

介绍:ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务
		
类型:服务"
	else
		echo "Name:zookeeper

Version:3.5.2

Introduce:ZooKeeper is a distributed, open source distributed application coordination service

Type: server"
	fi
}

十八、配置zookeeper集群

#!/usr/bin/env bash
#设置完毕后,再每个节点上安装此脚本


#[使用设置]

#集群所有节点的ip
cluster_ip=(192.168.2.108 192.168.2.109)

#端口
port=2181



source script/zookeeper.sh

get_zookeeper_cluster() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_zookeeper_cluster() {
	remove_zookeeper_cluster
    [ -f ${install_dir}/${zookeeper_dir}/conf/zoo.cfg.dynamic ] || test_exit "请先安装zookeeper"

    #配置文件
    echo "clientPort=${port}
dataDir=${install_dir}/${zookeeper_dir}/data
syncLimit=5
tickTime=2000
initLimit=10
dataLogDir=${install_dir}/${zookeeper_dir}
dynamicConfigFile=${install_dir}/${zookeeper_dir}/conf/zoo.cfg.dynamic" > ${install_dir}/${zookeeper_dir}/conf/zoo.cfg

    #输出配置
    rm -rf  ${install_dir}/${zookeeper_dir}/conf/zoo.cfg.dynamic
    d=1
    for i in `echo ${cluster_ip[*]}`
    do
        echo "server.${d}=${i}:2888:3888" >> ${install_dir}/${zookeeper_dir}/conf/zoo.cfg.dynamic
        let d++
    done
    
    #id号
    mkdir ${install_dir}/${zookeeper_dir}/data
    id=`process_id`
    echo "$id" > ${install_dir}/${zookeeper_dir}/data/myid
    
    #监听ipv4,默认ipv6
    sed -i '150c "-Dzookeeper.log.file=${ZOO_LOG_FILE}" "-Djava.net.preferIPv4Stack=true"  "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \/' ${install_dir}/${zookeeper_dir}/bin/zkServer.sh

    #脚本
    command=/usr/local/bin/man-zookeeper-cluster
    rm -rf $command
    echo "#!/bin/bash
${install_dir}/${zookeeper_dir}/bin/zkServer.sh" '$1' > $command
    chmod +x $command

    clear
	echo "zookeeper-cluster" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${zookeeper_dir}

日志目录:${log_dir}/${zookeeper_dir}

启动:man-zookeeper-cluster start"
	else
		echo "install ok
    
Installation manual:${install_dir}/${zookeeper_dir}

Log directory:${log_dir}/${zookeeper_dir}

Start:man-zookeeper-cluster start"
	fi
}

remove_zookeeper_cluster() {
	man-zookeeper-cluster stop
	rm -rf /usr/local/bin/man-zookeeper-cluster
	test_remove zookeeper-cluster
	[ "$language" == "cn" ] && echo "zookeeper_cluster卸载完成!" || echo "zookeeper_cluster Uninstall completed!"
}

info_zookeeper_cluster() {
	if [ "$language" == "cn" ];then
		echo "名字:zookeeper_cluster
		
版本:zookeeper

介绍:配置zookeeper集群
		
类型:服务"
	else
		echo "Name:zookeeper_cluster

Version:zookeeper

Introduce:Configure the zookeeper cluster

Type: server"
	fi
}

十九、系统管理Calibre

#!/usr/bin/env bash



get_calibre() {
	[ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_calibre() {
	remove_calibre
	test_rely chinese-font
	test_install libGL.so.1 mesa-libGL Mesa-libGL-devel libXcomposit qt5-qtquickcontrols qt5-qtdeclarative-devel

	#安装包
	wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
	
	#测试
	ebook-convert --version
	[ $? -eq 0 ] || test_exit "安装失败,请检查脚本" "Installation failed, please check the script"
	ebook-convert conf/installed.txt installed.pdf
	[ -f installed.pdf ] || test_exit "生成pdf失败,请检查脚本" "Failed to generate pdf, please check the script"
	
    #完成
    clear
	echo "calibre" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

ebook-convert a.txt a.pdf 方式生成pdf文件"
	else
		echo "install ok

Ebook-convert a.txt a.pdf method to generate pdf file"
	fi
}

remove_calibre() {
	[ "$language" == "cn" ] && echo "calibre当前无法卸载!" || echo "calibre cannot be uninstalled at this time!"
}

info_calibre() {
	if [ "$language" == "cn" ];then
		echo "名字:calibre
		
版本:3.18.0

介绍:Calibre是基于python的电子书制作软件,可导出PDF、EPUB、MOBI、Word格式电子书。
		
类型:系统管理"
	else
		echo "Name:calibre

Version:0

Introduce:Calibre is a python-based e-book making software that exports PDF, EPUB, MOBI, and Word format e-books.

Type: System Management"
	fi
}

二十、抽卡人生shell版本

#!/usr/bin/env bash



get_card_life() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_card_life() {
	remove_card_life
    test_bin card-life

    clear
	echo "card-life" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:/usr/local/bin/card-life

启动:card-life"
	else
		echo "install ok
    
Installation manual:/usr/local/bin/card-life

Start:card-life"
	fi
}

remove_card_life() {
	rm -rf /usr/local/bin/card-life
	test_remove card-life
	[ "$language" == "cn" ] && echo "card-life卸载完成!" || echo "card-life Uninstall completed!"
}

info_card_life() {
	if [ "$language" == "cn" ];then
		echo "名字:card-life
		
版本:1.4

介绍:抽卡人生shell版本
		
类型:卡牌游戏"
	else
		echo "Name:card-life

Version:1.4

Introduce:Draw card life shell version

Type: card game"
	fi
}

二一、查看系统信息

#!/usr/bin/env bash



get_cha() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_cha() {
	remove_cha	
    test_bin cha

    clear
	echo "cha" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:/usr/local/bin/cha

启动:cha -c"
	else
		echo "install ok
    
Installation manual:/usr/local/bin/cha

Start:cha"
	fi
}

remove_cha() {
	rm -rf /usr/local/bin/cha
	test_remove cha
	[ "$language" == "cn" ] && echo "cha卸载完成!" || echo "cha Uninstall completed!"
}

info_cha() {
	if [ "$language" == "cn" ];then
		echo "名字:cha
		
版本:1.0

介绍:查看系统信息
		
类型:系统管理"
	else
		echo "Name:cha

Version:1.0

Introduce:Check system information

Type: System Management"
	fi
}

二二、安装中文字体

#!/usr/bin/env bash



get_chinese_font() {
    test_package https://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/simhei.ttf 5b4ceb24c33f4fbfecce7bd024007876
	test_package https://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/simsun.ttc bc9c5051b849545eaecb9caeed711d79
}

install_chinese_font() {
	remove_chinese_font
	test_install fontconfig ttmkfdir
	mkdir -p /usr/share/fonts/chinese
	
	#放字体到文件夹
	get_chinese_font
	cp package/simhei.ttf /usr/shared/fonts/chinese/
	cp simsun.ttc /usr/shared/fonts/chinese/
	chmod -R 755 /usr/shared/fonts/chinese
	
	#将字体的文件夹位置写到配置文件
	
    ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
	sed -i '28a <dir>/usr/shared/fonts/chinese</dir>' /etc/fonts/fonts.conf
	fc-cache
	fc-list

    #完成
    clear
	echo "chinese-font" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

fc-list 查看是否有中文字体"
	else
		echo "install ok

fc-list See if there is a Chinese font"
	fi
}

remove_chinese_font() {
	[ "$language" == "cn" ] && echo "chinese-font当前无法卸载!" || echo "Chinese-font cannot be uninstalled at this time!"
}

info_chinese_font() {
	if [ "$language" == "cn" ];then
		echo "名字:chinese-font
		
版本:0

介绍:安装中文字体
		
类型:系统管理"
	else
		echo "Name:chinese-font

Version:0

Introduce:Install Chinese font

Type: System Management"
	fi
}

二三、显示字符时间

#!/usr/bin/env bash



get_clocks() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_clocks() {
	remove_clocks
    test_bin clocks

    clear
	echo "clocks" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:/usr/local/bin/clocks

启动:clocks"
	else
		echo "install ok
    
Installation manual:/usr/local/bin/clocks

Start:clocks"
	fi
}

remove_clocks() {
	rm -rf /usr/local/bin/clocks
	test_remove clocks
	[ "$language" == "cn" ] && echo "clocks卸载完成!" || echo "clocks Uninstall completed!"
}

info_clocks() {
	if [ "$language" == "cn" ];then
		echo "名字:clocks
		
版本:1.0

介绍:显示字符时间
		
类型:字符游戏"
	else
		echo "Name:clocks

Version:1.0

Introduce:Display character time

Type: Character game"
	fi
}

二四、glibc

#!/usr/bin/env bash



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#服务目录名
glibc_dir=glibc-2.14



get_glibc() {
    test_package http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/glibc-2.14.tar.gz 4657de6717293806442f4fdf72be821b
}

install_glibc() {
    #检测目录
	remove_glibc
    test_dir $glibc_dir
    test_install gcc cmake
    
    #安装服务
    get_glibc
    tar -xf package/glibc-2.14.tar.gz
    cd glibc-2.14
    mkdir build
    cd build
    ../configure --prefix=${install_dir}/${glibc_dir}
    make && make install
    cd ..
    cd ..
    rm -rf glibc-2.14
    
    #清除软连接
    rm -rf /lib64/libc.so.6
    ln -s ${install_dir}/${glibc_dir}/lib/libc-2.14.so /lib64/libc.so.6

    clear
	echo "glibc" >> conf/installed.txt
    if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${glibc_dir}"
	else
		echo "install ok
    
Installation manual:${install_dir}/${glibc_dir}"
	fi
}

remove_glibc() {
	[ "$language" == "cn" ] && echo "暂时无法卸载!" || echo "Unable to uninstall now!"
}

info_glibc() {
	if [ "$language" == "cn" ];then
		echo "名字:glibc
		
版本:2.14

介绍:glibc是GNU发布的libc库,即c运行库
		
类型:系统文件"
	else
		echo "Name:glibc

Version:2.14

Introduce:Glibc is the libc library released by GNU, ie the c runtime library

Type: System Files"
	fi
}

二五、打boss小游戏

#!/usr/bin/env bash



get_hit_boss() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_hit_boss() {
	remove_hit_boss
    test_bin hit-boss

    clear
	echo "hit-boss" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:/usr/local/bin/hit-boss

启动:hit-boss"
	else
		echo "install ok
    
Start:hit-boss"
	fi
}

remove_hit_boss() {
	rm -rf /usr/local/bin/hit-boss
	test_remove hit-boss
	[ "$language" == "cn" ] && echo "hit-boss卸载完成!" || echo "hit-boss Uninstall completed!"
}

info_hit_boss() {
	if [ "$language" == "cn" ];then
		echo "名字:hit-boss
		
版本:1.2

介绍:打boss小游戏,你将挑战大法师安东尼
		
类型:字符游戏"
	else
		echo "Name:hit-boss

Version:1.2

Introduce:Play boss game and you will challenge Archmage Anthony

Type: Character game"
	fi
}

二六、查询ip地址所在地

#!/usr/bin/env bash



get_ip_location() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_ip_location() {
	remove_ip_location
    test_bin ip-location

    clear
	echo "ip-location" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功

安装目录:/usr/local/bin/ip-location

启动:ip-location"
	else
		echo "install ok
    
Start:ip-location"
	fi
}

remove_ip_location() {
	rm -rf /usr/local/bin/ip-location
	test_remove ip-location
	[ "$language" == "cn" ] && echo "ip-location卸载完成!" || echo "ip-location Uninstall completed!"
}

info_ip_location() {
	if [ "$language" == "cn" ];then
		echo "名字:ip-location
		
版本:1.2

介绍:查询ip地址所在地
		
类型:系统管理"
	else
		echo "Name:ip-location

Version:1.2

Introduce:Query ip address location

Type: System Management"
	fi
}

二七、JDK

#!/usr/bin/env bash



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#服务目录名
jdk_dir=jdk-1.8



get_jdk() {
    test_package http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/jdk-8u152-linux-x64.tar.gz adfb92ae19a18b64d96fcd9a3e7bfb47
}

install_jdk() {
    remove_jdk
    test_dir $jdk_dir
    yum -y remove java-1.8.0-openjdk
    
    #安装服务
    get_jdk
    tar -xf package/jdk-8u152-linux-x64.tar.gz
    mv jdk1.8.0_152 ${install_dir}/${jdk_dir}
    
    #环境变量
    echo "export JAVA_HOME=${install_dir}/${jdk_dir}" >> /etc/profile
    echo "export JRE_HOME=${install_dir}/${jdk_dir}/jre" >> /etc/profile
    echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib' >> /etc/profile
    echo 'export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' >> /etc/profile
    
    source /etc/profile
    
    #测试
    java -version
    [ $? -eq 0 ] || test_exit "安装失败,请检查脚本" "Installation failed, please check the script"

    clear
	echo "jdk" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${jdk_dir}

环境变量设置完成"
	else
		echo "install ok
    
Installation manual:${install_dir}/${jdk_dir}

Environment variable setting completed"
	fi
}

remove_jdk() {
	rm -rf ${install_dir}/${jdk_dir}
	sed -i '/^export JAVA_HOME=/d' /etc/profile
    sed -i '/^export JRE_HOME=/d'  /etc/profile
    sed -i '/^export CLASSPATH=/d' /etc/profile
    sed -i '/^export PATH=$JAVA_HOME/d'  /etc/profile

	[ "$language" == "cn" ] && echo "卸载完成" || echo "Uninstall completed"
}

info_jdk() {
	if [ "$language" == "cn" ];then
		echo "名字:jdk
		
版本:1.8

介绍:JDK是 Java 语言的软件开发工具包
		
类型:语言"
	else
		echo "Name:jdk

Version:1.8

Introduce:JDK is a Java language software development kit

Type: Language"
	fi
}

二八、持续与集成工具

#!/usr/bin/env bash
#jenkins基本环境


#[使用设置]
#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
jenkins_dir=jenkins

#开启的端口号
port=8080

#默认监听所有
listen=0.0.0.0



get_jenkins() {
    test_package http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/jenkins.war 08386ff41dbf7dd069c750f3484cc140
}

install_jenkins() {
	remove_jenkins
    test_dir $jenkins_dir
    
    #安装依赖和包
    test_rely jdk
    get_jenkins
    mkdir ${install_dir}/${jenkins_dir}
    cp package/jenkins.war ${install_dir}/${jenkins_dir}/
    
    #配置启动脚本
    test_bin man-jenkins

    sed -i "2a port=$port" $command
    sed -i "3a listen=$listen" $command
    sed -i "4a install_dir=$install_dir" $command
    sed -i "5a log_dir=$log_dir" $command
    sed -i "6a jenkins_dir=$jenkins_dir" $command

    #完成
    clear
	echo "jenkins" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${jenkins_dir}

日志目录:${log_dir}/${jenkins_dir}

启动:man-jenkins start

访问:curl http://127.0.0.1:${port}"
	else
		echo "install ok
    
Installation manual:${install_dir}/${jenkins_dir}

Log directory:${log_dir}/${jenkins_dir}

Start:man-jenkins start

Access:curl http://127.0.0.1:${port}"
	fi
}

remove_jenkins() {
	rm -rf /usr/local/bin/man-jenkins
	rm -rf ${install_dir}/${jenkins_dir}
	test_remove jenkins
	[ "$language" == "cn" ] && echo "jenkins卸载完成!" || echo "jenkins Uninstall completed!"
}

info_jenkins() {
	if [ "$language" == "cn" ];then
		echo "名字:jenkins
		
版本:2.104

介绍:持续与集成工具
		
类型:服务"
	else
		echo "Name:jenkins

Version:2.104

Introduce:Continuous and integrated tools

Type: server"
	fi
}

二八、Kafka

#!/usr/bin/env bash



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#日志目录
#log_dir=

#服务目录名
kafka_dir=kafka



get_kafka() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/kafka_2.12-0.10.2.1.tgz" "fab4b35ba536938144489105cb0091e0"
}

install_kafka() {
	remove_kafka
    test_dir $kafka_dir
	test_rely jdk
    
    #安装依赖和包
    get_kafka
    tar -xf package/kafka_2.12-0.10.2.1.tgz
    mv kafka_2.12-0.10.2.1 ${install_dir}/${kafka_dir}

    #完成
    clear
	echo "kafka" >> conf/installed.txt
	if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${kafka_dir}"
	else
		echo "install ok
    
Installation manual:${install_dir}/${jenkins_dir}"
	fi
}

remove_kafka() {
	rm -rf ${install_dir}/${kafka_dir}
	test_remove kafka
	[ "$language" == "cn" ] && echo "kafka卸载完成!" || echo "kafka Uninstall completed!"
}

info_kafka() {
	if [ "$language" == "cn" ];then
		echo "名字:kafka
		
版本:2.12

介绍:Kafka是由Apache软件基金会开发的一个开源流处理平台
		
类型:服务"
	else
		echo "Name:kafka

Version:2.12

Introduce:Kafka is an open source stream processing platform developed by the Apache Software Foundation

Type: server"
	fi
}

二九、配置kafka集群

#!/usr/bin/env bash



#[使用设置]

#zookeeper集群的ip,包括他自己
cluster_ip=(192.168.2.108:2181 192.168.2.109:2181)

#端口
port=9092

#监听地址,如果填写localhost,则监听本地
listen=localhost



#如果非sai安装的,修改被加载脚本
source script/kafka.sh

get_kafka_cluster() {
    [ "$language" == "cn" ] && echo "不用下载" || echo "Do not download"
}

install_kafka_cluster() {
    #检测依赖
	remove_kafka_cluster
	conf=${install_dir}/${kafka_dir}/config/server.properties
    [ -f $conf ] || test_exit "请先安装kakfa" "Please install kafka first"

    #修改配置
    rm -rf $conf
    cp material/server.properties $conf
    
    id=`process_id`
    ip=`process_ip`
    
    #算出地址字符串
    for i in `echo ${cluster_ip[*]}` 
    do
        if [ "$i" == "${cluster_ip[0]}" ];then #刨去第一个,不然最前面会多个,
            cluster_dizhi=`echo $i`
        else
            cluster_dizhi=`echo ${cluster_dizhi},$i`
        fi
    done

    sed -i "21s/broker.id=1/broker.id=${id}/g" $conf
    sed -i "35s/port=9092/port=${port}/g" $conf
    if [ "$listen" == "localhost" ];then
        sed -i "36s/advertised.host.name=192.168.100.11/advertised.host.name=${ip}/g" $conf
    else
        sed -i "36s/advertised.host.name=192.168.100.11/advertised.host.name=${listen}/g" $conf
    fi
    sed -i "64s,log.dirs=/ops/log/kafka,log.dirs=${log_dir}/${kafka_dir},g" $conf
    sed -i "120s/zookeeper.connect=B-S-01:2181/zookeeper.connect=${cluster_dizhi}/g" $conf

    #创建脚本
    test_bin man-kafka-cluster
    sed -i "2a port=${port}" $command
    sed -i "3a dir=${install_dir}/${kafka_dir}" $command
   
	clear
	echo "kafka-cluster" >> conf/installed.txt
    if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${kafka_dir}

日志目录:${log_dir}/${kafka_dir}

启动:man-kafka-cluster start"
	else
		echo "install ok
    
Installation manual:${install_dir}/${kafka_dir}

Log directory:${log_dir}/${kafka_dir}

Start:man-kafka-cluster start"
	fi
}

remove_kafka_cluster() {
	rm -rf /usr/local/bin/man-kafka-cluster
	test_remove kafka-cluster
	[ "$language" == "cn" ] && echo "kafka-cluster卸载完成!" || echo "kafka-cluster Uninstall completed!"
}

info_kafka_cluster() {
	if [ "$language" == "cn" ];then
		echo "名字:kafka-cluster
		
版本:kafka

介绍:配置kafka集群
		
类型:服务"
	else
		echo "Name:kafka-cluster

Version:kafka

Introduce:Configure kafka cluster

Type: server"
	fi
}

三十、kafka的web端管理工具

#!/usr/bin/env bash
#kafka-manager,可以用来监控kafka



#[使用设置]

#主目录,相当于/usr/local
#install_dir=

#日志主目录,相当于/var/log
#log_dir=

#服务目录名
kafka_manager_dir=kafka-manager

#zookeeper集群地址用,分隔
cluster_ip="192.168.2.108:2181,192.168.2.109:2181"

#启动端口
port=9000



get_kafka_manager() {
    test_package "http://shell-auto-install.oss-cn-zhangjiakou.aliyuncs.com/package/kafka-manager-1.3.3.14.zip" "297da17fa75969bc66207e991118b35d"
}

install_kafka_manager() {
	remove_kafka_manager
    test_install unzip
    test_dir ${kafka_manager_dir}
	
    #安装包
    get_kafka_manager
    unzip package/kafka-manager-1.3.3.14.zip
    mv kafka-manager-1.3.3.14 ${install_dir}/${kafka_manager_dir}

    #修改配置文件
    conf=${install_dir}/${kafka_manager_dir}/conf/application.conf
    a=kafka-manager.zkhosts='"'${cluster_ip}'"'
    sed -i "23c $a" $conf

    #创建管理脚本
    test_bin man-kafka-manager

    sed -i "2a port=${port}" $command
    sed -i "3a dir=${install_dir}/${kafka_manager_dir}" $command
    sed -i "4a log=${log_dir}/${kafka_manager_dir}" $command
    
    #完成
    clear
	echo "kafka-manager" >> conf/installed.txt
    if [ "$language" == "cn" ];then
		echo "安装成功
		
安装目录:${install_dir}/${kafka_manager_dir}

日志目录:${log_dir}/${kafka_manager_dir}

启动:man-kafka-manager start

访问:curl http://127.0.0.1:${port}"
	else
		echo "install ok
    
Installation manual:${install_dir}/${kafka_manager_dir}

Log directory:${log_dir}/${kafka_manager_dir}

Start:man-kafka-manager start

Access:curl http://127.0.0.1:${port}"
	fi
}

remove_kafka_manager() {
	rm -rf ${install_dir}/${kafka_manager_dir}
	rm -rf /usr/local/bin/man-kafka-manager
	test_remove kafka-manager
	[ "$language" == "cn" ] && echo "kafka_manager卸载完成!" || echo "kafka_manager Uninstall completed!"
}

info_kafka_manager() {
	if [ "$language" == "cn" ];then
		echo "名字:kafka_manager
		
版本:1.3.3.14

介绍:kafka的web端管理工具
		
类型:服务"
	else
		echo "Name:kafka_manager

Version:1.3.3.14

Introduce:Kafka web-side management tool

Type: server"
	fi
}
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。