Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

前提条件

0. 準備

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}

2. 作成

変数の確認
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}

3. 事前作業

完了

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away