0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[JAWS-UG CLI] EC2 # ユーザデータの作成 (Redmine 3.1.1)

Last updated at Posted at 2017-02-13

前提条件

  1. 準備
    =======

0.1. 設定情報用バケット名の指定

変数の設定
S3_BUCKET_CONF="conf-${AWS_ID}" \
        && echo ${S3_BUCKET_CONF}
変数の設定
S3_BUCKET_LOG="log-${AWS_ID}" \
        && echo ${S3_BUCKET_LOG}

0.2. EC2設定情報ディレクトリの指定

変数の設定
DIR_CONF_EC2='config-ec2-handson-20170213'
コマンド
mkdir -p ${DIR_CONF_EC2}

0.3. AMI設定情報ディレクトリの指定

変数の設定
DIR_CONF_AMI='config-ami-handson-20170213'

0.4. Redmineのバージョンの指定

変数の設定
VERSION_REDMINE='3.3.1'
  1. 事前作業
    ===========
変数の設定
FILE_INPUT="${DIR_CONF_EC2}/userdata.bash" \
        && echo ${FILE_INPUT}
  1. 作成
    =======
変数の確認
cat << ETX

        FILE_INPUT:      ${FILE_INPUT}
        S3_BUCKET_CONF:  ${S3_BUCKET_CONF}
        S3_BUCKET_LOG:   ${S3_BUCKET_LOG}
        DIR_CONF_AMI:    ${DIR_CONF_AMI}
        VERSION_REDMINE: ${VERSION_REDMINE}

ETX
コマンド
cat << EOF > ${FILE_INPUT}
#!/bin/bash
yum -y update
yum -y install ruby23 ruby23-devel
yum -y erase ruby20
yum -y install make gcc gcc-c++ automake autoconf
yum -y install zlib-devel libcurl-devel openssl-devel postgresql-devel
yum -y install httpd httpd-devel
yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts
gem install bundler --no-rdoc --no-ri

# sync conf
aws s3 sync s3://${S3_BUCKET_CONF}/${DIR_CONF_AMI} /tmp/${DIR_CONF_AMI}

# get redmine
cd /tmp/${DIR_CONF_AMI}/
wget http://www.redmine.org/releases/redmine-${VERSION_REDMINE}.tar.gz
tar xzf redmine-${VERSION_REDMINE}.tar.gz
mv redmine-${VERSION_REDMINE} /var/lib/
cd /var/lib/
ln -s redmine-${VERSION_REDMINE} redmine

# setup redmine
cd /var/lib/redmine/
cp /tmp/${DIR_CONF_AMI}/database.yml /var/lib/redmine/config/
/usr/local/bin/bundle install \
  --without development test mysql sqlite \
  --path vendor/bundle
/usr/local/bin/bundle exec rake generate_secret_token

# setup passenger
/usr/bin/gem install passenger --no-rdoc --no-ri
/usr/local/bin/passenger-install-apache2-module --auto
/usr/local/bin/passenger-install-apache2-module --snippet > /tmp/http-passenger.conf

# setup apache
cat /tmp/${DIR_CONF_AMI}/httpd-redmine.conf /tmp/http-passenger.conf > /tmp/redmine.conf
mv /tmp/redmine.conf /etc/httpd/conf.d/
chown -R apache:apache /var/lib/redmine-${VERSION_REDMINE}
ln -s /var/lib/redmine/public /var/www/html/redmine

# start apache
service httpd start
chkconfig httpd on

# setup database (only 1st time)
#cd /var/lib/redmine/
#RAILS_ENV=production bundle exec rake db:migrate
#RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data

aws s3 cp /var/log/cloud-init-output.log s3://${S3_BUCKET_LOG}/redmine-${VERSION_REDMINE}-$(date +%Y%m%d-%H%M%S)

# clean up
rm /tmp/http-passenger.conf
rm -R /tmp/${DIR_CONF_AMI}
EOF

cat ${FILE_INPUT}
  1. 事前作業
    ===========

完了

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?