Frigga自动安装脚本(linux5.8/6.5测试稳定)

2018-07-20    来源:open-open

容器云强势上线!快速搭建集群,上万Linux镜像随意使用
#!/bin/bash

PATH="$PATH:/usr/local/bin:/usr/bin"
RUBY_VERSION="2.2.3"
RUBY_NAME="ruby-$RUBY_VERSION"
RUBY_FILE_TAR="$RUBY_NAME.tar.gz"
SOFT_DIR="/opt/soft"
INSTALL_DIR="/opt/ops/Frigga"
HTTP_CONF="conf/frigga.yml"
FRIGGA_CMD="/opt/ops/Frigga/bin/frigga.rb"
FRIGGA_BIN_DIR=`dirname $FRIGGA_CMD`

ADMIN="admin"
PASSWD="pswd"
PORT="5555"

REBOOT_RUN="/etc/rc.local"
ENV_FILE="/etc/profile"

# OS:
OS=`cat /etc/issue|head -1|awk '{print $3}'|cut -d'.' -f 1`

# Install gcc
yum -y install gcc gcc-c++ zlib git openssl openssl-devel

# Install ruby && gem
[ -d "$INSTALL_DIR" ] && rm -rf $INSTALL_DIR
mkdir -p $INSTALL_DIR
mkdir -p $SOFT_DIR
cd $SOFT_DIR
[ -f "$RUBY_FILE_TAR" ] && rm -f $RUBY_FILE_TAR
[ -d "$RUBY_NAME" ] && rm -rf $RUBY_NAME

which ruby > /dev/null 2>&1
if [ $? -eq 0 ]; then
    yum -y remove ruby
fi

wget --no-check-certificate https://cache.ruby-lang.org/pub/ruby/2.2/$RUBY_FILE_TAR
tar -zxf $RUBY_FILE_TAR
cd $RUBY_NAME
./configure
make
make install

ln -s /usr/local/bin/ruby /bin/ruby
ln -s /usr/local/bin/ruby /usr/bin/ruby
ln -s /usr/local/bin/gem /bin/gem

gem source -r https://rubygems.org/ -a https://ruby.taobao.org/
if [ $? != 0 ];then
  echo "====Error:"
  echo "gem source -r https://rubygems.org/ -a https://ruby.taobao.org/   FAIL!"
  exit 1
fi
gem install bundle eventmachine
ln -s /usr/local/bin/bundle /bin/bundle
ln -s /usr/local/bin/thor /bin/thor

# Install Frigga && god
cd $INSTALL_DIR
which git > /dev/null 2>&1
if [ $? != 0 ];then
    if [ $OS -eq 5 ]; then
        cd /tmp
        wget https://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
        rpm -ivh epel-release-5-4.noarch.rpm
    fi
    if [ $OS -eq 6 ]; then
        cd /tmp
        wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
        rpm -ivh epel-release-6-8.noarch.rpm
    fi
    yum -y install git
fi
which git > /dev/null 2>&1
[ $? != 0 ] && echo "git is not exist." && exit 1
cd $INSTALL_DIR
git clone https://github.com/xiaomi-sa/frigga.git $INSTALL_DIR
[ $? != 0 ] && echo "git Frigga FAIL." && exit 1

ln -s $FRIGGA_CMD /bin/frigga
mkdir gods
mkdir conf.d
chmod 777 log/

sed -i "s/admin/$ADMIN/;s/123/$PASSWD/;s/9001/$PORT/" $HTTP_CONF
#sed -i "s/^frigga_path/#&/g" $FRIGGA_CMD
#sed -i "s*#{frigga_path}*$FRIGGA_BIN_DIR*g" $FRIGGA_CMD
#sed -i "s*ruby*/bin/ruby*g" $FRIGGA_CMD

ruby ./script/run.rb start
ln -s /usr/local/bin/god /bin/god

# Reboot auto run
RUN_CONTENT="""
## 第一次启动会失败,所以添加两次 Frigga:
/bin/ruby /opt/ops/Frigga/script/run.rb start >> /tmp/god_err.log 2>&1
/bin/ruby /opt/ops/Frigga/script/run.rb start >> /tmp/god_err.log 2>&1
"""
echo "$RUN_CONTENT" >> $REBOOT_RUN

# Tomcat add config
# cp setenv.sh /tomcat/bin
# chown lbs:lbs /tomcat/bin/setenv.sh
# chmod +x /tomcat/bin/setenv.sh


标签: ssl

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。

上一篇:solr的查询语法

下一篇:IOS sqlite3