mirror of https://github.com/fengyuhetao/shell.git
commit
fa7d1b4ece
|
@ -0,0 +1,194 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:elasticsearch 5.4.1/6.0.1/6.3.1安装
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_elasticsearch.log
|
||||
env_file=/etc/profile.d/elasticsearch.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
software_config_file=${install_path}elasticsearch/config/elasticsearch.yml
|
||||
sysversion=$(rpm -q centos-release|cut -d- -f3)
|
||||
jvm_conf="/usr/local/elasticsearch/config/jvm.options"
|
||||
sys_mem=`free -m|grep Mem:|awk '{print $2}'|awk '{sum+=$1} END {print sum/1024}'|cut -d. -f1`
|
||||
hostname=elk-server
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 elasticsearch 5.4.1/6.0.1/6.3.1 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install elasticsearch 5.4.1"
|
||||
echo "2: Install elasticsearch 6.0.1"
|
||||
echo "3: Install elasticsearch 6.3.1"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/elasticsearch/elasticsearch-5.4.1.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/elasticsearch/elasticsearch-6.0.1.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/elasticsearch/elasticsearch-6.3.1.tar.gz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4|5}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
# 配置主机名,第一个为主机名
|
||||
config_hostname() {
|
||||
if [ ${sysversion} -eq 6 ];then
|
||||
hostname $1
|
||||
elif [ ${sysversion} -eq 7 ];then
|
||||
hostnamectl set-hostname $1
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` hostname $1 config fail">> ${install_log_path}${install_log_name}
|
||||
fi
|
||||
}
|
||||
|
||||
config_limits() {
|
||||
output_msg "配置limits"
|
||||
cat >>/etc/security/limits.conf<<EOF
|
||||
* soft nofile 65536
|
||||
* hard nofile 65536
|
||||
* soft nproc 65536
|
||||
* hard nproc 65536
|
||||
EOF
|
||||
echo "vm.max_map_count = 655360" >>/etc/sysctl.conf
|
||||
sysctl -p >/dev/null 2>&1
|
||||
|
||||
}
|
||||
|
||||
# 添加配置文件
|
||||
add_config() {
|
||||
cat > $1 << EOF
|
||||
cluster.name: my-application
|
||||
node.name: ${hostname}
|
||||
path.data: /usr/local/elasticsearch/data
|
||||
path.logs: /usr/local/elasticsearch/logs
|
||||
network.host: 127.0.0.1
|
||||
http.port: 9200
|
||||
discovery.zen.ping.unicast.hosts: ["$hostname"]
|
||||
EOF
|
||||
}
|
||||
|
||||
config_user() {
|
||||
useradd $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $1 user add success">> ${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $1 user add fail">> ${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
chown ${1}.${1} ${install_path}elasticsearch/ -R
|
||||
}
|
||||
|
||||
config_jvm() {
|
||||
if [ ${sys_mem} -eq 0 ];then
|
||||
sed -i "s#`grep "^-Xmx" ${jvm_conf}`#"-Xmx512m"#g" ${jvm_conf}
|
||||
sed -i "s#`grep "^-Xms" ${jvm_conf}`#"-Xms512m"#g" ${jvm_conf}
|
||||
else
|
||||
sed -i "s#`grep "^-Xmx" ${jvm_conf}`#"-Xmx${sys_mem}g"#g" ${jvm_conf}
|
||||
sed -i "s#`grep "^-Xms" ${jvm_conf}`#"-Xms${sys_mem}g"#g" ${jvm_conf}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
config_hostname $hostname
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}elasticsearch
|
||||
add_config $software_config_file
|
||||
check_dir ${install_path}elasticsearch/{data,logs}
|
||||
config_user elasticsearch
|
||||
config_env ${install_path}elasticsearch/bin
|
||||
config_limits
|
||||
config_jvm
|
||||
echo "请使用一下命令启动服务:'su - elasticsearch -c 'nohup /usr/local/elasticsearch/bin/elasticsearch &'"
|
||||
|
||||
}
|
||||
|
||||
main
|
|
@ -0,0 +1,136 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:filebeat 5.6.1/6.1.3/6.3.2 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_filebeat.log
|
||||
env_file=/etc/profile.d/filebeat.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
software_config_file=${install_path}filebeat/filebeat.yml
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 filebeat 5.6.1/6.1.3/6.3.2 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install filebeat 5.6.1"
|
||||
echo "2: Install filebeat 6.1.3"
|
||||
echo "3: Install filebeat 6.3.2"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/filebeat/filebeat-5.6.1-linux-x86_64.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/filebeat/filebeat-6.1.3-linux-x86_64.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/filebeat/filebeat-6.3.2-linux-x86_64.tar.gz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
# 添加配置文件
|
||||
add_config() {
|
||||
cat> $1 <<EOF
|
||||
filebeat.prospectors:
|
||||
- input_type: log
|
||||
paths:
|
||||
- /var/log/*.log
|
||||
output.logstash:
|
||||
hosts: ["127.0.0.1:5044"]
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}filebeat
|
||||
add_config ${software_config_file}
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:git 2.0.0/2.10.0/2.18.0 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_git.log
|
||||
env_file=/etc/profile.d/git.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
#software_config_file=${install_path}
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 git 2.0.0/2.10.0/2.18.0 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install git 2.0.0"
|
||||
echo "2: Install git 2.10.0"
|
||||
echo "3: Install git 2.18.0"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/git/git-2.0.0.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/git/git-2.10.0.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/git/git-2.18.0.tar.gz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# yum 安装软件包,可传入多个软件包,用空格隔开
|
||||
yum_install_software() {
|
||||
output_msg "yum 安装软件"
|
||||
yum -y install $* >/dev/null 2>${install_log_path}${install_log_name}
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S`yum install $* 完成" >>${install_log_path}${install_log_name}
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 编译安装git,传入$1 为解压后软件包的名称
|
||||
source_install_git() {
|
||||
output_msg "编译安装git"
|
||||
mv ${install_path}${1} ${install_path}tmp${1}
|
||||
cd ${install_path}tmp${1} && make prefix=${install_path}git all >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
make prefix=${install_path}git install >/dev/null 2>&1 echo "`date +%F' '%H:%M:%S` git source install success ">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` git source install fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
check_yum_command make make
|
||||
yum_install_software curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
|
||||
source_install_git ${software_name}
|
||||
mv /usr/bin/git /usr/bin/git.bak
|
||||
|
||||
rm -fr ${download_path}
|
||||
config_env ${install_path}git/bin
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:grafana 5.1.0/5.1.5/5.2.2 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_grafana.log
|
||||
env_file=/etc/profile.d/grafana.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 grafana 5.1.0/5.1.5/5.2.2 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install grafana 5.1.0"
|
||||
echo "2: Install grafana 5.1.5"
|
||||
echo "3: Install grafana 5.2.2"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/grafana/grafana-5.1.0-1.x86_64.rpm"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/grafana/grafana-5.1.5-1.x86_64.rpm"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/grafana/grafana-5.2.2-1.x86_64.rpm"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 安装grafana插件,传入安装的插件的名称
|
||||
install_grafana_plugins() {
|
||||
output_msg "grafana插件安装"
|
||||
check_yum_command grafana-cli
|
||||
grafana-cli plugins install $* >/dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` grafana plugins $* install success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` grafana plugins $* install success!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
for filename in `ls $download_path`;do
|
||||
yum -y install $download_path$filename >/dev/null 2>&1
|
||||
done
|
||||
install_grafana_plugins alexanderzobnin-zabbix-app
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:kafka 0.10.2/0.11.0/1.1.0/2.0.0 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_kafka.log
|
||||
env_file=/etc/profile.d/kafka.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
software_config_file=${install_path}kafka/config/server.properties
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装kafka 0.10.2/0.11.0/1.1.0/2.0.0 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install kafka 0.10.2"
|
||||
echo "2: Install kafka 0.11.0"
|
||||
echo "3: Install kafka 1.1.0"
|
||||
echo "4: Install kafka 2.0.0"
|
||||
echo "5: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kafka/kafka_2.12-0.10.2.2.tgz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kafka/kafka_2.12-0.11.0.3.tgz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kafka/kafka_2.12-1.1.0.tgz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kafka/kafka_2.12-2.0.0.tgz"
|
||||
elif [ "${softversion}" == "5" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4|5}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ] || [ "${file##*.}" == "tgz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
# 添加配置文件
|
||||
add_config() {
|
||||
cat> $1 <<EOF
|
||||
broker.id=1 #kafka集群标识,不能相同,第一台是1以此类推,其他都一样。
|
||||
log.dirs=/usr/local/kafka/kafka-logs
|
||||
host.name=127.0.0.1 #主机ip
|
||||
#zookeeper.connect=127.0.0.1:2181 #zookeeper连接
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tgz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}kafka
|
||||
add_config ${software_config_file}
|
||||
check_dir ${install_path}kafka/kafka-logs
|
||||
config_env ${install_path}kafka/bin
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:kibana 6.0.1/6.2.4/6.3.1 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_kibana.log
|
||||
env_file=/etc/profile.d/kibana.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
software_config_file=${install_path}kibana/config/kibana.yml
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 kibana 6.0.1/6.2.4/6.3.1 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install kibana 6.0.1"
|
||||
echo "2: Install kibana 6.2.4"
|
||||
echo "3: Install kibana 6.3.1"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kibana/kibana-6.0.1-linux-x86_64.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kibana/kibana-6.2.4-linux-x86_64.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/kibana/kibana-6.3.1-linux-x86_64.tar.gz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
# 添加配置文件
|
||||
add_config() {
|
||||
cat> $1 <<EOF
|
||||
server.port: 5601
|
||||
server.host: "0.0.0.0"
|
||||
elasticsearch.url: "http://127.0.0.1:9200"
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s ${install_path}$software_name ${install_path}kibana
|
||||
add_config ${software_config_file}
|
||||
config_env ${install_path}kibana/bin
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:logstash 5.4/6.1/6.3 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_logstash.log
|
||||
env_file=/etc/profile.d/logstash.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
software_config_file=${install_path}logstash/config/01-syslog.conf
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 logstash 5.4/6.1/6.3 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install logstash-5.4"
|
||||
echo "2: Install logstash-6.1"
|
||||
echo "3: Install logstash-6.3"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/logstash/logstash-5.4.1.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/logstash/logstash-6.1.3.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/logstash/logstash-6.3.2.tar.gz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
# 添加配置文件
|
||||
add_config() {
|
||||
cat> $1 <<EOF
|
||||
input {
|
||||
beats {
|
||||
port => "5044"
|
||||
}
|
||||
}
|
||||
output {
|
||||
elasticsearch {
|
||||
hosts => "127.0.0.1:9200"
|
||||
}
|
||||
stdout { codec => rubydebug }
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}logstash
|
||||
add_config ${software_config_file}
|
||||
config_env ${install_path}logstash/bin
|
||||
}
|
||||
|
||||
main
|
|
@ -0,0 +1,125 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:maven 3.0.5/3.3.9/3.5.4 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_maven.log
|
||||
env_file=/etc/profile.d/maven.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
#software_config_file=${install_path}filebeat/filebeat.yml
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 maven 3.0.5/3.3.9/3.5.4 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install maven 3.0.5"
|
||||
echo "2: Install maven 3.2.9"
|
||||
echo "3: Install maven 3.5.4"
|
||||
echo "4: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/maven/apache-maven-3.0.5-bin.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/maven/apache-maven-3.3.9-bin.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/maven/apache-maven-3.5.4-bin.tar.gz"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'-bin.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}maven
|
||||
config_env ${install_path}maven/bin
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:tomcat 6.0/7.0/8.5/9.0 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_tomcat.log
|
||||
env_file=/etc/profile.d/tomcat.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 tomcat 6.0/7.0/8.5/9.0 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install tomcat-6.0"
|
||||
echo "2: Install tomcat-7.0"
|
||||
echo "3: Install tomcat-8.5"
|
||||
echo "4: Install tomcat-9.0"
|
||||
echo "5: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/tomcat/apache-tomcat-6.0.9.zip"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/tomcat/apache-tomcat-7.0.79.zip"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/tomcat/apache-tomcat-8.5.20.zip"
|
||||
elif [ "${softversion}" == "4" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/tomcat/apache-tomcat-9.0.0.M26.zip"
|
||||
elif [ "${softversion}" == "5" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3|4|5}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
check_yum_command unzip unzip
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.zip' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}tomcat
|
||||
config_env ${install_path}tomcat/bin
|
||||
}
|
||||
|
||||
main
|
|
@ -0,0 +1,137 @@
|
|||
#!/bin/bash
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:zookeeper 3.4/3.5 安装
|
||||
|
||||
# 定义安装目录、及日志信息
|
||||
. /etc/init.d/functions
|
||||
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
download_path=/tmp/tmpdir/
|
||||
install_log_name=install_zookeeper.log
|
||||
env_file=/etc/profile.d/zookeeper.sh
|
||||
install_log_path=/var/log/appinstall/
|
||||
install_path=/usr/local/
|
||||
software_config_file=${install_path}zookeeper/conf/zoo.cfg
|
||||
|
||||
clear
|
||||
echo "##########################################"
|
||||
echo "# #"
|
||||
echo "# 安装 zookeeper 3.4/3.5 #"
|
||||
echo "# #"
|
||||
echo "##########################################"
|
||||
echo "1: Install zookeeper 3.4"
|
||||
echo "2: Install zookeeper 3.5"
|
||||
echo "3: EXIT"
|
||||
# 选择安装软件版本
|
||||
read -p "Please input your choice:" softversion
|
||||
if [ "${softversion}" == "1" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/zookeeper/zookeeper-3.4.12.tar.gz"
|
||||
elif [ "${softversion}" == "2" ];then
|
||||
URL="https://anchnet-script.oss-cn-shanghai.aliyuncs.com/zookeeper/zookeeper-3.5.4-beta.tar.gz"
|
||||
elif [ "${softversion}" == "3" ];then
|
||||
echo "you choce channel!"
|
||||
exit 1;
|
||||
else
|
||||
echo "input Error! Place input{1|2|3}"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# 传入内容,格式化内容输出,可以传入多个参数,用空格隔开
|
||||
output_msg() {
|
||||
for msg in $*;do
|
||||
action $msg /bin/true
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 判断命令是否存在,第一个参数 $1 为判断的命令,第二个参数为提供该命令的yum 软件包名称
|
||||
check_yum_command() {
|
||||
output_msg "命令检查:$1"
|
||||
hash $1 >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` check command $1 ">>${install_log_path}${install_log_name} && return 0
|
||||
else
|
||||
yum -y install $2 >/dev/null 2>&1
|
||||
# hash $Command || { echo "`date +%F' '%H:%M:%S` $2 is installed fail">>${install_log_path}${install_log_name} ; exit 1 }
|
||||
fi
|
||||
}
|
||||
|
||||
# 判断目录是否存在,传入目录绝对路径,可以传入多个目录
|
||||
check_dir() {
|
||||
output_msg "目录检查"
|
||||
for dirname in $*;do
|
||||
[ -d $dirname ] || mkdir -p $dirname >/dev/null 2>&1
|
||||
echo "`date +%F' '%H:%M:%S` $dirname check success!" >> ${install_log_path}${install_log_name}
|
||||
done
|
||||
}
|
||||
|
||||
# 下载文件并解压至安装目录,传入url链接地址
|
||||
download_file() {
|
||||
output_msg "下载源码包"
|
||||
mkdir -p $download_path
|
||||
for file in $*;do
|
||||
wget $file -c -P $download_path &> /dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
echo "`date +%F' '%H:%M:%S` $file download success!">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%s` $file download fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 解压文件,可以传入多个压缩文件绝对路径,用空格隔开,解压至安装目录
|
||||
extract_file() {
|
||||
output_msg "解压源码"
|
||||
for file in $*;do
|
||||
if [ "${file##*.}" == "gz" ];then
|
||||
tar -zxf $file -C $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
elif [ "${file##*.}" == "zip" ];then
|
||||
unzip -q $file -d $install_path && echo "`date +%F' '%H:%M:%S` $file extrac success!,path is $install_path">>${install_log_path}${install_log_name}
|
||||
else
|
||||
echo "`date +%F' '%H:%M:%S` $file type error, extrac fail!">>${install_log_path}${install_log_name} && exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 配置环境变量,第一个参数为添加环境变量的绝对路径
|
||||
config_env() {
|
||||
output_msg "环境变量配置"
|
||||
echo "export PATH=\$PATH:$1" >${env_file}
|
||||
source ${env_file} && echo "`date +%F' '%H:%M:%S` 软件安装完成!">> ${install_log_path}${install_log_name}
|
||||
|
||||
}
|
||||
|
||||
# 添加配置文件
|
||||
add_config() {
|
||||
cat> $1 <<EOF
|
||||
tickTime=2000 #服务之间或者客户端与服务段之间心跳时间
|
||||
initLimit=10 #Follower启动过程中,从Leader同步所有最新数据的时间
|
||||
syncLimit=5 #Leader与集群之间的通信时间
|
||||
dataDir=/usr/local/zookeeper/data #zookeeper存储数据
|
||||
datalogDir=/usr/local/zookeeper/logs #zookeeper存储数据的日志
|
||||
clientPort=2181 #zookeeper默认端口
|
||||
#server.1=127.0.0.1:2888:3888 #集群配置
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
check_dir $install_log_path $install_path
|
||||
check_yum_command wget wget
|
||||
download_file $URL
|
||||
|
||||
software_name=$(echo $URL|awk -F'/' '{print $NF}'|awk -F'.tar.gz' '{print $1}')
|
||||
for filename in `ls $download_path`;do
|
||||
extract_file ${download_path}$filename
|
||||
done
|
||||
rm -fr ${download_path}
|
||||
ln -s $install_path$software_name ${install_path}zookeeper
|
||||
add_config ${software_config_file}
|
||||
check_dir "${install_path}zookeeper/data" "${install_path}zookeeper/logs"
|
||||
echo "1">${install_path}zookeeper/data/myid
|
||||
config_env ${install_path}zookeeper/bin
|
||||
}
|
||||
|
||||
main
|
||||
|
Loading…
Reference in New Issue