From 4f48b7049288036fdcc06ebc8425bf9e615cc47c Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 6 Nov 2016 13:33:38 +0900 Subject: [PATCH 01/34] add some OAuth2 plugins --- inst-script/config-alminium | 39 +++++++++++++++++++++++++++++++ redmine/setup/redmine-plugins.lst | 4 ++-- redmine/setup/redmine-plugins1 | 20 +++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/inst-script/config-alminium b/inst-script/config-alminium index 6ba43f90..55637562 100755 --- a/inst-script/config-alminium +++ b/inst-script/config-alminium @@ -68,6 +68,7 @@ fi # source inst-script/config-email.sh +# jenkins if [ -e jenkins/setup/$OS/install.sh -a "$ALM_ENABLE_JENKINS" = "" ]; then echo -n "継続的インテグレーションツールのJenkinsのインストール・設定を" echo -n "行うことができます。デフォルトはインストールしません。" @@ -75,5 +76,43 @@ if [ -e jenkins/setup/$OS/install.sh -a "$ALM_ENABLE_JENKINS" = "" ]; then echo -n "" echo -n "Jenkinsをインストールしますか?(y/N)" read ALM_ENABLE_JENKINS + echo "" +fi + +# OAuth2認証 +if [ "$ALM_OAUTH2_METHOD" = "" ]; then + echo "### 本機能は実験中(動作確認が不十分)です ###" + echo "OAuth2認証を利用することができます。" + echo "現在利用出来るのは、GoogleまたはGitLabです。" + echo "google, github, gitlab*, または, N(OAuth2認証を利用しない)を選択してください。" + echo "* gitlabサービスはオンプレミスサービスを指定可能" + echo "OAuth2認証サービスを選択してください:" + echo " 1: Google" + echo " 2: GitHub" + echo " 3: GitLab (オンプレミスサービスも指定可能)" + echo " 4: Azure" + echo " other: OAuth2認証を利用しない" + echo -n "利用したいサービスの番号をお選びください: " + read ALM_OAUTH2_METHOD + if [ "$ALM_OAUTH2_METHOD" = "" ] ; then + ALM_OAUTH2_METHOD="N" + fi fi +case $ALM_OAUTH2_METHOD in +1) + ALM_OAUTH2_METHOD=google + ;; +2) + ALM_OAUTH2_METHOD=github + ;; +3) + ALM_OAUTH2_METHOD=gitlab + ;; +4) + ALM_OAUTH2_METHOD=azure + ;; +*) + ALM_OAUTH2_METHOD=N + ;; +esac diff --git a/redmine/setup/redmine-plugins.lst b/redmine/setup/redmine-plugins.lst index b712ad1b..440822a9 100644 --- a/redmine/setup/redmine-plugins.lst +++ b/redmine/setup/redmine-plugins.lst @@ -26,5 +26,5 @@ open_flash_chart,master,https://github.com/drakontia/redmine_open_flash_chart.gi redmine_local_avatars,master,https://github.com/thorin/redmine_local_avatars.git redmine_git_branch_hook,master,https://github.com/mikoto20000/redmine_git_branch_hook.git redmine_dmsf,master,https://github.com/danmunn/redmine_dmsf.git -redmine_oauth_provider,master,https://github.com/suer/redmine_oauth_provider.git -redmine_omniauth_gitlab,master,https://github.com/ayapapa/redmine_omniauth_gitlab.git +#redmine_oauth_provider,master,https://github.com/suer/redmine_oauth_provider.git +redmine_oauth_provider,master,https://github.com/ipcross/redmine_oauth_provider.git diff --git a/redmine/setup/redmine-plugins1 b/redmine/setup/redmine-plugins1 index c2d1c4f0..2940e729 100644 --- a/redmine/setup/redmine-plugins1 +++ b/redmine/setup/redmine-plugins1 @@ -84,12 +84,30 @@ if [ -f plugins/redmine_hudson/Gemfile ]; then mv plugins/redmine_hudson/Gemfile plugins/redmine_hudson/Gemfile.org fi -#for DMSF +# for DMSF # avoid bandle install error because of rubyzip version conflict if [ -f $ALM_INSTALL_DIR/plugins/redmine_dmsf/Gemfile ]; then sed -i.org "s/gem 'rubyzip',/gem 'rubyzip'#,/" $ALM_INSTALL_DIR/plugins/redmine_dmsf/Gemfile fi +# for OAuth2認証 +cd ./plugins +case $ALM_OAUTH2_METHOD in +google) + git clone -b master https://github.com/twinslash/redmine_omniauth_google.git + ;; +github) + git clone -b v0.0.3 https://github.com/ares/redmine_omniauth_github.git + ;; +gitlab) + git clone -b 0.0.1 https://github.com/ayapapa/redmine_omniauth_gitlab.git + ;; +azure) + git clone -b master https://github.com/sohelzerdoumi/redmine_omniauth_azure.git + ;; +esac +cd .. + # redmineに必要なgemをインストール bundle install --path vendor/bundle --without development test xapian From e6efc5d4f3f7ed63f1c4a103d7602bdfab1b9169 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Tue, 8 Nov 2016 00:03:22 +0900 Subject: [PATCH 02/34] Update config-logs update for wrong permission of redmine's log. --- inst-script/config-logs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inst-script/config-logs b/inst-script/config-logs index 201273a1..49ac2531 100755 --- a/inst-script/config-logs +++ b/inst-script/config-logs @@ -10,12 +10,14 @@ backup_and_new_logdir() { local group=$5 pushd $parent_dir - if [ -d $log_dir ]; then + if [ -d $old_log_dir -a "`ls $old_log_dir`" != "" \ + -a "`readlink -f $old_log_dir`" != "$ALM_LOG_DIR/$new_log_dir" ]; then mkdir -p $old_log_dir.backup tar cvfz $old_log_dir.backup/"`date +%F-%H-%M-%S`".tar.gz $old_log_dir + cp -p $old_log_dir/* $ALM_LOG_DIR/$new_log_dir/ rm -r $old_log_dir fi - chown $owner:$group $ALM_LOG_DIR/$new_log_dir + chown -R $owner:$group $ALM_LOG_DIR/$new_log_dir ln -s $ALM_LOG_DIR/$new_log_dir $parent_dir/$old_log_dir popd } From ffc257593d0f2df0d36976a273426ea3c742683b Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 19 Nov 2016 14:10:25 +0900 Subject: [PATCH 03/34] to suppport external db(#93) --- backup | 80 ++++++++++++++++++--------------- etc/vcs.conf | 6 +-- inst-script/check-os | 3 -- inst-script/config-db | 4 +- inst-script/config-logs | 13 +++--- inst-script/debian/install_db | 4 ++ inst-script/debian/packages.lst | 2 +- inst-script/debian/pre-install | 6 ++- inst-script/functions | 36 +++++++++++++++ inst-script/install-redmine | 30 +++---------- inst-script/post-install | 1 + inst-script/select-db | 30 +++++++++++++ redmine/setup/createdb.sql | 2 +- restore | 19 +++++--- smelt | 9 ++++ uninstall | 26 ++++++++--- upgrade | 2 +- 17 files changed, 183 insertions(+), 90 deletions(-) create mode 100755 inst-script/debian/install_db create mode 100644 inst-script/functions create mode 100755 inst-script/select-db diff --git a/backup b/backup index 2eabacc2..28328506 100755 --- a/backup +++ b/backup @@ -1,16 +1,26 @@ #!/bin/bash ############################################################ # backup for ALMinium. -# 第一引数:バックアップディレクトリ(defaultは/var/opt/alminium-backup) +# 第1引数:バックアップディレクトリ(defaultは/var/opt/alminium-backup) +# 第2引数:データベースホスト名 +# 第3引数:データベース管理者パスワード ############################################################ +ALM_DB_HOST=${ALM_DB_HOST:-$2} +ALM_DB_HOST=${ALM_DB_HOST:-localhost} +ALM_DB_ROOT_PASS=${ALM_DB_ROOT_PASS:-$3} + ALM_CURRENT_DIR=${ALM_CURRENT_DIR:-`pwd`} +# include functions +source inst-script/functions + +# backup directry if [ "$1" != "" ]; then if [ "`echo $1 | cut -c 1`" = "/" ]; then ALM_BACKUP_DIR=$1 else - ALM_BACKUP_DIR=$ALM_CURRENT_DIR/$1 + ALM_BACKUP_DIR=${ALM_CURRENT_DIR}/$1 fi else # デフォルトバックアップディレクトリを設定 @@ -25,10 +35,8 @@ if [ "`whoami`" != 'root' ]; then fi #バックアップディレクトリのチェック -if [ ! -d $ALM_BACKUP_DIR ]; then - mkdir -p $ALM_BACKUP_DIR - #echo "バックアップディレクトリが見つかりませんでした。処理を中止します" - #exit 1 +if [ ! -d ${ALM_BACKUP_DIR} ]; then + mkdir -p ${ALM_BACKUP_DIR} fi # バックアップファイル名決定 @@ -36,56 +44,56 @@ ALM_BACKUP_ID=`date +"%Y-%m-%d-%H-%M-%S"` ALM_DBBACKUP_NAME=db.dump ALM_FILE_BACKUP=files.tar.gz ALM_REPOS_BACKUP=repo.tar.gz -ALM_BACKUP_NAME=$ALM_BACKUP_DIR/${ALM_BACKUP_ID}-alm-backup.tar.gz +ALM_BACKUP_NAME=${ALM_BACKUP_ID}-alm-backup.tar.gz # バックアップ開始 -echo "[`date`] : ALMiniumのデータの($ALM_BACKUP_NAME)へのバックアップを開始します。" +echo "[`date`] ALMiniumのデータのバックアップを開始します。" +echo "バックアップファイル名 : ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME}" + +# バックアップ結果チェック +check_backup_result() { + if [ -f ${ALM_BACKUP_DIR}/$1 -a -s ${ALM_BACKUP_DIR}/$1 ]; then + echo "$2(${ALM_BACKUP_DIR}/$1)が成功しました。" + else + echo "$2(${ALM_BACKUP_DIR}/$1)が失敗しました。" + exit 1 + fi +} -#データベースをバックアップ echo "MySQLデータベースをバックアップします。" -mysqldump -uroot alminium > $ALM_BACKUP_DIR/$ALM_DBBACKUP_NAME -if [ -f $ALM_BACKUP_DIR/$ALM_DBBACKUP_NAME ]; then - echo "MySQLデータベースのバックアップが成功しました。" -else - echo "MySQLデータベースのバックアップが失敗しました。" - exit 1 -fi +mysqldump `db_option` alminium > $ALM_BACKUP_DIR/$ALM_DBBACKUP_NAME +check_backup_result ${ALM_DBBACKUP_NAME} "データベースバックアップ" #redmineの添付ファイルをバックアップ echo "Redmineの添付ファイルをバックアップします。" pushd /opt/alminium/files/ -tar czf $ALM_BACKUP_DIR/$ALM_FILE_BACKUP . -if [ -f $ALM_BACKUP_DIR/$ALM_FILE_BACKUP ]; then - echo "Redmineの添付ファイルのバックアップが成功しました。" -else - echo "Redmineの添付ファイルのバックアップが失敗しました。" - exit 1 -fi +tar czf ${ALM_BACKUP_DIR}/${ALM_FILE_BACKUP} . +check_backup_result ${ALM_FILE_BACKUP} "添付ファイルバックアップ" popd #ソースコードリポジトリ echo "ソースコードリポジトリをバックアップします。" pushd /var/opt/alminium/ -tar czf $ALM_BACKUP_DIR/$ALM_REPOS_BACKUP . -if [ -f $ALM_BACKUP_DIR/$ALM_REPOS_BACKUP ]; then - echo "ソースコードリポジトリのバックアップが成功しました。" -else - echo "ソースコードリポジトリのバックアップが失敗しました。" - exit 1 -fi +tar czf ${ALM_BACKUP_DIR}/${ALM_REPOS_BACKUP} . +check_backup_result ${ALM_REPOS_BACKUP} "ソースコードリポジトリバックアップ" popd # バックアップ統合 -pushd $ALM_BACKUP_DIR -tar czf $ALM_BACKUP_NAME ./$ALM_DBBACKUP_NAME ./$ALM_FILE_BACKUP ./$ALM_REPOS_BACKUP +pushd ${ALM_BACKUP_DIR} +tar czf ./${ALM_BACKUP_NAME} \ + ./${ALM_DBBACKUP_NAME} ./${ALM_FILE_BACKUP} ./${ALM_REPOS_BACKUP} +check_backup_result ${ALM_BACKUP_NAME} "バックアップファイル統合" # バックアップ終了 -echo "[`date`] : ALMiniumのデータの($ALM_BACKUP_NAME)へのバックアップが終了しました。" +echo "[`date`] ALMiniumのデータのバックアップが終了しました。" +echo "バックアップファイル名:${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME}" # 古いバックアップファイルを削除 -if [ "$ALM_BACKUP_EXPIRY" != "" ]; then - echo "[`date`] : $ALM_BACKUP_EXPIRY日経過したバックアップファイルを削除します。" - find $ALM_BACKUP_DIR/*.tar.gz -mtime +$ALM_BACKUP_EXPIRY -exec rm -f {} \; +if [ "${ALM_BACKUP_EXPIRY}" != "" ]; then + echo -n "[`date`] ${ALM_BACKUP_EXPIRY}日経過した" + echo "バックアップファイルを削除します。" + find ${ALM_BACKUP_DIR}/*.tar.gz \ + -mtime +${ALM_BACKUP_EXPIRY} -exec rm -f {} \; fi popd diff --git a/etc/vcs.conf b/etc/vcs.conf index 0f27b76f..959521ca 100644 --- a/etc/vcs.conf +++ b/etc/vcs.conf @@ -19,7 +19,7 @@ AuthName Subversion # for Redmine Authentication - RedmineDSN "DBI:mysql:database=alminium;host=localhost" + RedmineDSN "DBI:mysql:database=alminium;host=#DB_HOST#" RedmineDbUser "alminium" RedmineDbPass "alminium" @@ -49,7 +49,7 @@ SetEnv GIT_HTTP_EXPORT_ALL AuthName Git # for Redmine Authentication - RedmineDSN "DBI:mysql:database=alminium;host=localhost" + RedmineDSN "DBI:mysql:database=alminium;host=#DB_HOST#" RedmineDbUser "alminium" RedmineDbPass "alminium" RedmineGitSmartHttp yes @@ -108,7 +108,7 @@ WSGIScriptAlias #SUBDIR#/hg /etc/opt/alminium/hgweb.wsgi AuthName Mercurial # for Redmine Authentication - RedmineDSN "DBI:mysql:database=alminium;host=localhost" + RedmineDSN "DBI:mysql:database=alminium;host=#DB_HOST#" RedmineDbUser "alminium" RedmineDbPass "alminium" diff --git a/inst-script/check-os b/inst-script/check-os index a2fbc955..08aae51b 100755 --- a/inst-script/check-os +++ b/inst-script/check-os @@ -9,7 +9,6 @@ if [ "$OS" = "" ]; then APACHE_LOG_DIR=httpd MYSQL_LOG_DIR=mysql MYSQLD='/etc/init.d/mysqld' - MYSQL='mysql' CHK=`egrep "CentOS release 5|Red Hat Enterprise Linux .* 5" /etc/redhat-release` if [ "$CHK" != '' ]; then OS='rhel5' @@ -35,7 +34,6 @@ if [ "$OS" = "" ]; then APACHE_LOG_DIR=apache2 MYSQL_LOG_DIR=mysql MYSQLD='/etc/init.d/mysql' - MYSQL='mysql' OS='debian' echo "Ubuntu 14.04 が検出されました。" elif [ -f /etc/lsb-release -a "`grep 16.04 /etc/lsb-release`" != "" ]; then @@ -44,7 +42,6 @@ if [ "$OS" = "" ]; then APACHE_LOG_DIR=apache2 MYSQL_LOG_DIR=mysql MYSQLD='/etc/init.d/mysql' - MYSQL='mysql' OS='ubuntu1604' ETH0=enp0s3 if [ ! -f jenkins/setup/ubuntu1604 ]; then diff --git a/inst-script/config-db b/inst-script/config-db index e1c8a636..1d772478 100755 --- a/inst-script/config-db +++ b/inst-script/config-db @@ -1,11 +1,9 @@ #!/bin/bash # setup database -$MYSQLD start if [ "$ALM_UPGRADE" = "" ]; then # create DB - $MYSQL < redmine/setup/createdb.sql - + mysql `db_option` < redmine/setup/createdb.sql # create directory for vcs mkdir -p $ALM_VAR_DIR/{git,svn,hg,maven,github} chown -R $APACHE_USER:$APACHE_USER $ALM_VAR_DIR/* diff --git a/inst-script/config-logs b/inst-script/config-logs index 49ac2531..0de7fb8a 100755 --- a/inst-script/config-logs +++ b/inst-script/config-logs @@ -10,15 +10,16 @@ backup_and_new_logdir() { local group=$5 pushd $parent_dir - if [ -d $old_log_dir -a "`ls $old_log_dir`" != "" \ - -a "`readlink -f $old_log_dir`" != "$ALM_LOG_DIR/$new_log_dir" ]; then - mkdir -p $old_log_dir.backup - tar cvfz $old_log_dir.backup/"`date +%F-%H-%M-%S`".tar.gz $old_log_dir - cp -p $old_log_dir/* $ALM_LOG_DIR/$new_log_dir/ + if [ -d $old_log_dir -a "`readlink -f $old_log_dir`" != "$ALM_LOG_DIR/$new_log_dir" ]; then + if [ "`ls $old_log_dir`" != "" ]; then + mkdir -p $old_log_dir.backup + tar cvfz $old_log_dir.backup/"`date +%F-%H-%M-%S`".tar.gz $old_log_dir + cp -p $old_log_dir/* $ALM_LOG_DIR/$new_log_dir/ + fi rm -r $old_log_dir + ln -s $ALM_LOG_DIR/$new_log_dir $parent_dir/$old_log_dir fi chown -R $owner:$group $ALM_LOG_DIR/$new_log_dir - ln -s $ALM_LOG_DIR/$new_log_dir $parent_dir/$old_log_dir popd } diff --git a/inst-script/debian/install_db b/inst-script/debian/install_db new file mode 100755 index 00000000..98dfffa3 --- /dev/null +++ b/inst-script/debian/install_db @@ -0,0 +1,4 @@ +#!/bin/bash + +apt-get install -y mysql-client + diff --git a/inst-script/debian/packages.lst b/inst-script/debian/packages.lst index 9d2c4f21..ac934e75 100644 --- a/inst-script/debian/packages.lst +++ b/inst-script/debian/packages.lst @@ -14,7 +14,7 @@ libsqlite3-dev libssl-dev make mercurial -mysql-server +#mysql-server ruby-switch ruby2.1 ruby2.1-dev diff --git a/inst-script/debian/pre-install b/inst-script/debian/pre-install index 0dbdc18b..0c7b8f36 100755 --- a/inst-script/debian/pre-install +++ b/inst-script/debian/pre-install @@ -43,4 +43,8 @@ else a2dismod ssl fi -service mysql start +# DB +if [ "${ALM_DB_HOST}" = "localhost" ]; then + apt-get -y install mysql-server + service mysql start +fi diff --git a/inst-script/functions b/inst-script/functions new file mode 100644 index 00000000..22db319d --- /dev/null +++ b/inst-script/functions @@ -0,0 +1,36 @@ + +# DB操作コマンドオプション +db_option() { + local db_host=${ALM_DB_HOST:-localhost} + local root_pass=${ALM_DB_ROOT_PASS} + + if [ "${root_pass}" = "" ] ; then + echo "-uroot -h${db_host}" + else + echo "-uroot -h${db_host} -p${root_pass}" + fi +} + +# DBのsettingsテーブルのレコード有無チェック +db_exist_record() { + echo "SELECT * FROM settings WHERE name = '$1';" | mysql `db_option` alminium +} + +# DB内のsettingsテーブルの指定レコード$1を指定の値$2に書き換える +# レコードが存在しない場合は、新たにレコードを挿入する +db_update_setting() { + if [ "`db_exist_record $1`" = "" ]; then + echo "REPLACE INTO settings(name,value,updated_on) " \ + "VALUES ('$1','$2', current_date);" | mysql `db_option` alminium + else + echo "UPDATE settings SET value = '$2' WHERE name = '$1';" | mysql `db_option` alminium + fi +} + +# データベース接続テスト +# 戻り値が非nullなら接続成功 +db_test() { + DBCMD="mysql `db_option`" + echo `${DBCMD} -e "select user from user;" mysql 2>/dev/null` +} + diff --git a/inst-script/install-redmine b/inst-script/install-redmine index aaef425f..9e1b1def 100755 --- a/inst-script/install-redmine +++ b/inst-script/install-redmine @@ -3,26 +3,6 @@ # install Redmine # ################### -# -# functions -# - -# DBのsettingsテーブルのレコード有無チェック -exist_record() { - echo "SELECT * FROM settings WHERE name = '$1';" | mysql alminium -} - -# DB内のsettingsテーブルの指定レコード$1を指定の値$2に書き換える -# レコードが存在しない場合は、新たにレコードを挿入する -update_setting() { - if [ "`exist_record $1`" = "" ]; then - echo "REPLACE INTO settings(name,value,updated_on) " \ - "VALUES ('$1','$2', current_date);" | mysql alminium - else - echo "UPDATE settings SET value = '$2' WHERE name = '$1';" | mysql alminium - fi -} - # protocol protocol() { if [ "$ALM_ENABLE_SSL" = "y" ]; then @@ -32,7 +12,6 @@ protocol() { fi } - # # scripts # @@ -56,6 +35,9 @@ cp -fr redmine/public/themes/* $ALM_INSTALL_DIR/public/themes/ cp ./{backup,restore} ./inst-script/config-backup \ ./inst-script/$OS/service-restart $ALM_INSTALL_DIR/ +# update db-config +sed -i "s/localhost/${ALM_DB_HOST}/" $ALM_INSTALL_DIR/config/database.yml + # avoid bandle install error because of nokogiri version conflict mv $ALM_INSTALL_DIR/Gemfile $ALM_INSTALL_DIR/Gemfile.org sed "s/gem \"nokogiri\", \">= 1.6.7.2\"/gem \"nokogiri\"#, \">= 1.6.7.2\"/" $ALM_INSTALL_DIR/Gemfile.org > $ALM_INSTALL_DIR/Gemfile @@ -67,7 +49,7 @@ source redmine/setup/redmine-plugins if [ "$ALM_UPGRADE" = "" ]; then # Customize echo "*** run initialize SQL ***" - $MYSQL alminium < redmine/setup/init.mysql + mysql `db_option` alminium < redmine/setup/init.mysql fi # install hooks @@ -81,6 +63,6 @@ cp -fr redmine/hooks $ALM_INSTALL_DIR/ chown -R $APACHE_USER:$APACHE_USER $ALM_INSTALL_DIR/* # config settings -update_setting 'host_name' ${ALM_HOSTNAME}$ALM_SUBDIR -update_setting 'protocol' `protocol` +db_update_setting 'host_name' ${ALM_HOSTNAME}$ALM_SUBDIR +db_update_setting 'protocol' `protocol` diff --git a/inst-script/post-install b/inst-script/post-install index dd428fc7..15dc3b94 100755 --- a/inst-script/post-install +++ b/inst-script/post-install @@ -20,6 +20,7 @@ do -e "s|$REPLACE_JENKINS||" \ -e "s|#SUBDIR#|$ALM_SUBDIR|" \ -e "s|#DOCUMENTROOT#|$DOCMENT_ROOT|" \ + -e "s|#DB_HOST#|$ALM_DB_HOST|" \ "etc/$FILE" > "$ALM_ETC_DIR/$FILE" done diff --git a/inst-script/select-db b/inst-script/select-db new file mode 100755 index 00000000..2f14a9a8 --- /dev/null +++ b/inst-script/select-db @@ -0,0 +1,30 @@ +# select db + +# アップグレード時でDBホスト名の指定が無い場合は、ここで指示待ち +if [ "${ALM_UPGRADE}" != "y" -a "${ALM_DB_HOST}" = "" ]; then + echo + echo -n 既に設置済みのMySQLデータベースサービスを利用しますか?[y/N] + read USE_EXISTING_MYSQL; + if [ "${USE_EXISTING_MYSQL}" = "y" ]; then + # db client install + source inst-script/$OS/install_db + # DBへのアクセスが成功するまでループしながらチェック + while [ "${DB_TEST}" = "" ] + do + echo -n データベースサーバー名を入力してください: + read ALM_DB_HOST + echo -n データベース管理者パスワードを入力してください: + read ALM_DB_ROOT_PASS + DB_TEST=`db_test` + if [ "${DB_TEST}" = "" ]; then + echo データベースに接続できませんでした。 + fi + done + else + ALM_DB_HOST=localhost + ALM_DB_ROOT_PASS= + fi +fi + +ALM_DB_HOST=${ALM_DB_HOST:-localhost} + diff --git a/redmine/setup/createdb.sql b/redmine/setup/createdb.sql index 78e23af7..515a8144 100644 --- a/redmine/setup/createdb.sql +++ b/redmine/setup/createdb.sql @@ -1,2 +1,2 @@ CREATE DATABASE alminium DEFAULT CHARACTER SET utf8; -GRANT ALL PRIVILEGES ON alminium.* TO alminium@localhost IDENTIFIED BY 'alminium'; +GRANT ALL PRIVILEGES ON alminium.* TO alminium@'%' IDENTIFIED BY 'alminium'; diff --git a/restore b/restore index 66708e25..4ae5299a 100755 --- a/restore +++ b/restore @@ -1,8 +1,14 @@ #!/bin/bash -###################################### -# restore from ALMinium's backup. # -# 第一引数:バックアップファイル名 # -###################################### +######################################### +# restore from ALMinium's backup. # +# 第一引数:バックアップファイル名 # +# 第2引数:データベースホスト名 # +# 第3引数:データベース管理者パスワード # +######################################### + +ALM_DB_HOST=${ALM_DB_HOST:-$2} +ALM_DB_HOST=${ALM_DB_HOST:-localhost} +ALM_DB_ROOT_PASS=${ALM_DB_ROOT_PASS:-$3} ALM_CURRENT_DIR=${ALM_CURRENT_DIR:-`pwd`} @@ -28,6 +34,9 @@ ALM_DBBACKUP_NAME=/tmp/db.dump ALM_FILE_BACKUP=/tmp/files.tar.gz ALM_REPOS_BACKUP=/tmp/repo.tar.gz +# include functions +source inst-script/functions + # バックアップの復元 echo "${ALM_BACKUP_NAME}を復元します。" cd /tmp @@ -39,7 +48,7 @@ echo "***Redmine添付ファイルを復元しています..." cd /opt/alminium/files/ && tar xzf $ALM_FILE_BACKUP if [ "$ALM_DB_RESTORE" != "no" ]; then echo "***データベースを復元しています..." - mysql -uroot alminium < $ALM_DBBACKUP_NAME + mysql `db_option` alminium < $ALM_DBBACKUP_NAME echo "データ復元が完了しました。" #データベースのマイグレーション echo "データベースのマイグレーションを実施します。" diff --git a/smelt b/smelt index 1cdb46a8..53b57ded 100755 --- a/smelt +++ b/smelt @@ -11,6 +11,9 @@ ALM_GIT_VERSION=${ALM_GIT_VERSION:-2.9.0} ALM_GIT_AUTO_UPGRADE=${ALM_GIT_AUTO_UPGRADE:-N} ALM_LOG_DIR=${ALM_LOG_DIR:-/var/log/alminium} +ALM_DB_HOST= +ALM_DB_ROOT_PASS= + RAILS_ENV=production RM_VER=${RM_VER:-`cat RM_VERSION`} @@ -24,6 +27,9 @@ else ALM_UPGRADE="" fi +# include functions +source inst-script/functions + # check memory size source inst-script/check-mem @@ -53,6 +59,9 @@ fi git submodule sync git submodule update +# select db +source inst-script/select-db + # pre install source inst-script/pre-install diff --git a/uninstall b/uninstall index 44f47860..fe954d34 100755 --- a/uninstall +++ b/uninstall @@ -1,4 +1,10 @@ #!/bin/bash +# 第1引数:データベースホスト名 +# 第2引数:データベース管理者パスワード + +ALM_DB_HOST=${ALM_DB_HOST:-$1} +ALM_DB_HOST=${ALM_DB_HOST:-localhost} +ALM_DB_ROOT_PASS=${ALM_DB_ROOT_PASS:-$2} GEM=`which gem2.0` GEM=${GEM:-gem} @@ -6,19 +12,27 @@ ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} +# include functions +source inst-script/functions + +# start uninstall echo "ALMiniumをアンインストールします。" echo "" + +# remove db echo -n "データベース(全てのRedmineの情報)とリポジトリを削除しますか?(y/N)" read YN if [ "$YN" = "y" ]; then - mysql alminium -e "REVOKE ALL ON alminium.* FROM alminium@localhost" - mysql alminium -e "DELETE FROM mysql.user WHERE User LIKE 'alminium'" - mysql alminium -e "FLUSH PRIVILEGES" - mysql alminium -e "DROP DATABASE alminium" + DBCMD="mysql `db_option`" + $DBCMD alminium -e "REVOKE ALL ON alminium.* FROM alminium@localhost" + $DBCMD alminium -e "DELETE FROM mysql.user WHERE User LIKE 'alminium'" + $DBCMD alminium -e "FLUSH PRIVILEGES" + $DBCMD alminium -e "DROP DATABASE alminium" rm -fr $ALM_INSTALL_DIR/* $ALM_INSTALL_DIR/.[^.]* $ALM_VAR_DIR/* fi +# remove apache2 config echo "" echo -n "Apacheの設定を削除しますか?(y/N)" read YN @@ -30,7 +44,7 @@ if [ "$YN" = "y" ]; then rm -fr $ALM_ETC_DIR/* fi - +# uninstall jenkins echo "" echo -n "Jenkisとその設定を削除しますか?(y/N)" read YN @@ -39,7 +53,7 @@ if [ "$YN" = "y" ]; then source jenkins/setup/uninstall.sh fi - +# remove cache echo "" echo -n "キャッシュされたファイルを削除しますか?(y/N)" read YN diff --git a/upgrade b/upgrade index 41f97f02..d3ffd26b 100755 --- a/upgrade +++ b/upgrade @@ -79,7 +79,7 @@ source ./smelt -u #バックアップの復元 ALM_DB_RESTORE=no -source ./restore $ALM_BACKUP_NAME +source ./restore ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME} # log復元 restore_log() { From 49b5eab7dffadeae4ef85ecab9ab3594969444be Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 19 Nov 2016 18:54:10 +0900 Subject: [PATCH 04/34] to suppport external db(#93) --- inst-script/ubuntu1604/install_db | 4 ++++ inst-script/ubuntu1604/packages.lst | 1 - inst-script/ubuntu1604/pre-install | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100755 inst-script/ubuntu1604/install_db diff --git a/inst-script/ubuntu1604/install_db b/inst-script/ubuntu1604/install_db new file mode 100755 index 00000000..98dfffa3 --- /dev/null +++ b/inst-script/ubuntu1604/install_db @@ -0,0 +1,4 @@ +#!/bin/bash + +apt-get install -y mysql-client + diff --git a/inst-script/ubuntu1604/packages.lst b/inst-script/ubuntu1604/packages.lst index c3b4469a..f5f1397a 100644 --- a/inst-script/ubuntu1604/packages.lst +++ b/inst-script/ubuntu1604/packages.lst @@ -15,7 +15,6 @@ libsqlite3-dev libssl-dev make mercurial -mysql-server php-mysql ruby ruby-dev diff --git a/inst-script/ubuntu1604/pre-install b/inst-script/ubuntu1604/pre-install index 53f8167d..ba20dcf0 100755 --- a/inst-script/ubuntu1604/pre-install +++ b/inst-script/ubuntu1604/pre-install @@ -37,4 +37,9 @@ else a2dismod ssl fi -service mysql start +# DB +if [ "${ALM_DB_HOST}" = "localhost" ]; then + apt-get -y install mysql-server + service mysql start +fi + From 5a1fc0d26d9283d2b30fd87c627849d3e3a7b0ef Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 19 Nov 2016 21:07:37 +0900 Subject: [PATCH 05/34] to suppport external db(#93) --- backup | 2 +- restore | 16 ++++++++-------- uninstall | 2 +- upgrade | 7 +++++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/backup b/backup index 28328506..68e67c05 100755 --- a/backup +++ b/backup @@ -61,7 +61,7 @@ check_backup_result() { } echo "MySQLデータベースをバックアップします。" -mysqldump `db_option` alminium > $ALM_BACKUP_DIR/$ALM_DBBACKUP_NAME +mysqldump `db_option` alminium > ${ALM_BACKUP_DIR}/${ALM_DBBACKUP_NAME} check_backup_result ${ALM_DBBACKUP_NAME} "データベースバックアップ" #redmineの添付ファイルをバックアップ diff --git a/restore b/restore index 4ae5299a..196b908d 100755 --- a/restore +++ b/restore @@ -1,7 +1,7 @@ #!/bin/bash ######################################### # restore from ALMinium's backup. # -# 第一引数:バックアップファイル名 # +# 第1引数:バックアップファイル名 # # 第2引数:データベースホスト名 # # 第3引数:データベース管理者パスワード # ######################################### @@ -21,7 +21,7 @@ fi # バックアップファイルをチェック if [ "$1" = "" ]; then - echo "第一引数にバックアップファイルを指定してください。" + echo "第1引数にバックアップファイルを指定してください。" exit 1 fi @@ -40,15 +40,15 @@ source inst-script/functions # バックアップの復元 echo "${ALM_BACKUP_NAME}を復元します。" cd /tmp -tar xzf $ALM_BACKUP_NAME +tar xzf ${ALM_BACKUP_NAME} echo "***リポジトリーデータを復元しています..." -cd /var/opt/alminium/ && tar xzf $ALM_REPOS_BACKUP +cd /var/opt/alminium/ && tar xzf ${ALM_REPOS_BACKUP} echo "***Redmine添付ファイルを復元しています..." -cd /opt/alminium/files/ && tar xzf $ALM_FILE_BACKUP -if [ "$ALM_DB_RESTORE" != "no" ]; then +cd /opt/alminium/files/ && tar xzf ${ALM_FILE_BACKUP} +if [ "${ALM_DB_RESTORE}" != "no" ]; then echo "***データベースを復元しています..." - mysql `db_option` alminium < $ALM_DBBACKUP_NAME + mysql `db_option` alminium < ${ALM_DBBACKUP_NAME} echo "データ復元が完了しました。" #データベースのマイグレーション echo "データベースのマイグレーションを実施します。" @@ -60,7 +60,7 @@ if [ "$ALM_DB_RESTORE" != "no" ]; then echo "データベースのマイグレーションが完了しました。" fi -cd $ALM_CURRENT_DIR +cd ${ALM_CURRENT_DIR} if [ -f service-restart ]; then echo "サービスを再起動します。" source ./service-restart diff --git a/uninstall b/uninstall index fe954d34..485c8755 100755 --- a/uninstall +++ b/uninstall @@ -25,7 +25,7 @@ read YN if [ "$YN" = "y" ]; then DBCMD="mysql `db_option`" - $DBCMD alminium -e "REVOKE ALL ON alminium.* FROM alminium@localhost" + $DBCMD alminium -e "REVOKE ALL ON alminium.* FROM alminium@'%'" $DBCMD alminium -e "DELETE FROM mysql.user WHERE User LIKE 'alminium'" $DBCMD alminium -e "FLUSH PRIVILEGES" $DBCMD alminium -e "DROP DATABASE alminium" diff --git a/upgrade b/upgrade index d3ffd26b..961eb561 100755 --- a/upgrade +++ b/upgrade @@ -1,6 +1,9 @@ #!/bin/bash ############################################################ # upgrader for ALMinium. +# 第1引数:バックアップディレクトリ(defaultは/var/opt/alminium-backup) +# 第2引数:データベースホスト名 +# 第3引数:データベース管理者パスワード ############################################################ ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} @@ -31,7 +34,7 @@ echo "#####################################################################" read DO_CONTINUE # バックアップ実行 -source backup $1 +source backup $1 $2 $3 if [ $? -gt 0 ]; then echo "バックアップに失敗したため、処理を中止します" exit 1 @@ -79,7 +82,7 @@ source ./smelt -u #バックアップの復元 ALM_DB_RESTORE=no -source ./restore ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME} +source ./restore ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME} $2 $3 # log復元 restore_log() { From 7359075bcbf82d40daf4448a891e28e4896b2951 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 19 Nov 2016 22:15:58 +0900 Subject: [PATCH 06/34] to suppport external db(#93) --- .../debian/{install_db => install_db_client} | 0 inst-script/debian/pre-install | 4 ++-- inst-script/rhel6/install_db_client | 4 ++++ inst-script/rhel6/packages.lst | 1 - inst-script/rhel6/pre-install | 18 +++++++++++++----- inst-script/select-db | 6 +++--- .../{install_db => install_db_client} | 0 inst-script/ubuntu1604/pre-install | 4 ++-- uninstall | 13 ++++++++----- 9 files changed, 32 insertions(+), 18 deletions(-) rename inst-script/debian/{install_db => install_db_client} (100%) create mode 100755 inst-script/rhel6/install_db_client rename inst-script/ubuntu1604/{install_db => install_db_client} (100%) diff --git a/inst-script/debian/install_db b/inst-script/debian/install_db_client similarity index 100% rename from inst-script/debian/install_db rename to inst-script/debian/install_db_client diff --git a/inst-script/debian/pre-install b/inst-script/debian/pre-install index 0c7b8f36..bfe584ed 100755 --- a/inst-script/debian/pre-install +++ b/inst-script/debian/pre-install @@ -44,7 +44,7 @@ else fi # DB -if [ "${ALM_DB_HOST}" = "localhost" ]; then - apt-get -y install mysql-server +if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then + apt-get install -y mysql-server service mysql start fi diff --git a/inst-script/rhel6/install_db_client b/inst-script/rhel6/install_db_client new file mode 100755 index 00000000..51cb7d42 --- /dev/null +++ b/inst-script/rhel6/install_db_client @@ -0,0 +1,4 @@ +#!/bin/bash + +yum install -y mysql + diff --git a/inst-script/rhel6/packages.lst b/inst-script/rhel6/packages.lst index 47e4c7a9..651546d6 100644 --- a/inst-script/rhel6/packages.lst +++ b/inst-script/rhel6/packages.lst @@ -27,7 +27,6 @@ mod_perl mod_wsgi mysql mysql-devel -mysql-server ncurses-devel openssl-devel patch diff --git a/inst-script/rhel6/pre-install b/inst-script/rhel6/pre-install index 61e8364e..557b9eab 100644 --- a/inst-script/rhel6/pre-install +++ b/inst-script/rhel6/pre-install @@ -34,12 +34,20 @@ if [ "$ALM_ENABLE_SSL" = "y" ]; then yum -y install mod_ssl fi -sed -i "s/log-error=\/var\/log\/mysqld/log-error=\/var\/log\/mysql\/mysqld/" /etc/my.cnf -mkdir -p /var/log/mysql -chkconfig --add mysqld -chkconfig mysqld on -service mysqld restart +# db +if [ "${ALM_DB_HOST}" = "localhost" ]; then + if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then + yum install -y mysql-server + fi + sed -i "s/log-error=\/var\/log\/mysqld/log-error=\/var\/log\/mysql\/mysqld/" \ + /etc/my.cnf + mkdir -p /var/log/mysql + chkconfig --add mysqld + chkconfig mysqld on + service mysqld restart +fi +# ruby if [[ `which ruby` == "" || ! `ruby --version` =~ 2.1. ]]; then rpm -Uvh "https://github.com/hansode/ruby-rpm/blob/master/6/x86_64/ruby-2.1.2-2.el6.x86_64.rpm?raw=true" fi diff --git a/inst-script/select-db b/inst-script/select-db index 2f14a9a8..9cd2558c 100755 --- a/inst-script/select-db +++ b/inst-script/select-db @@ -4,10 +4,10 @@ if [ "${ALM_UPGRADE}" != "y" -a "${ALM_DB_HOST}" = "" ]; then echo echo -n 既に設置済みのMySQLデータベースサービスを利用しますか?[y/N] - read USE_EXISTING_MYSQL; - if [ "${USE_EXISTING_MYSQL}" = "y" ]; then + read ALM_USE_EXISTING_DB; + if [ "${ALM_USE_EXISTING_DB}" = "y" ]; then # db client install - source inst-script/$OS/install_db + source inst-script/$OS/install_db_client # DBへのアクセスが成功するまでループしながらチェック while [ "${DB_TEST}" = "" ] do diff --git a/inst-script/ubuntu1604/install_db b/inst-script/ubuntu1604/install_db_client similarity index 100% rename from inst-script/ubuntu1604/install_db rename to inst-script/ubuntu1604/install_db_client diff --git a/inst-script/ubuntu1604/pre-install b/inst-script/ubuntu1604/pre-install index ba20dcf0..3bd6fba2 100755 --- a/inst-script/ubuntu1604/pre-install +++ b/inst-script/ubuntu1604/pre-install @@ -38,8 +38,8 @@ else fi # DB -if [ "${ALM_DB_HOST}" = "localhost" ]; then - apt-get -y install mysql-server +if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then + apt-get install -y mysql-server service mysql start fi diff --git a/uninstall b/uninstall index 485c8755..606c0e4c 100755 --- a/uninstall +++ b/uninstall @@ -25,11 +25,14 @@ read YN if [ "$YN" = "y" ]; then DBCMD="mysql `db_option`" - $DBCMD alminium -e "REVOKE ALL ON alminium.* FROM alminium@'%'" - $DBCMD alminium -e "DELETE FROM mysql.user WHERE User LIKE 'alminium'" - $DBCMD alminium -e "FLUSH PRIVILEGES" - $DBCMD alminium -e "DROP DATABASE alminium" - rm -fr $ALM_INSTALL_DIR/* $ALM_INSTALL_DIR/.[^.]* $ALM_VAR_DIR/* + ${DBCMD} alminium -e "REVOKE ALL ON alminium.* FROM alminium@%" \ + 2>/dev/null + ${DBCMD} alminium -e "REVOKE ALL ON alminium.* FROM alminium@localhost" \ + 2>/dev/null + ${DBCMD} alminium -e "DELETE FROM mysql.user WHERE User LIKE 'alminium'" + ${DBCMD} alminium -e "FLUSH PRIVILEGES" + ${DBCMD} alminium -e "DROP DATABASE alminium" + rm -fr ${ALM_INSTALL_DIR}/* ${ALM_INSTALL_DIR}/.[^.]* ${ALM_VAR_DIR}/* fi # remove apache2 config From 69272e8a141667951b3146b256d2feebf6c0c303 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 19 Nov 2016 22:48:25 +0900 Subject: [PATCH 07/34] to suppport external db(#93) --- inst-script/select-db | 2 +- jenkins/setup/config.sh | 3 ++- smelt | 4 ++-- upgrade | 34 ++++++++++++++++++---------------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/inst-script/select-db b/inst-script/select-db index 9cd2558c..10a98b2b 100755 --- a/inst-script/select-db +++ b/inst-script/select-db @@ -1,6 +1,6 @@ # select db -# アップグレード時でDBホスト名の指定が無い場合は、ここで指示待ち +# アップグレード時以外でDBホスト名の指定が無い場合は、ここで指示待ち if [ "${ALM_UPGRADE}" != "y" -a "${ALM_DB_HOST}" = "" ]; then echo echo -n 既に設置済みのMySQLデータベースサービスを利用しますか?[y/N] diff --git a/jenkins/setup/config.sh b/jenkins/setup/config.sh index a502b0dc..c6ea4408 100755 --- a/jenkins/setup/config.sh +++ b/jenkins/setup/config.sh @@ -10,8 +10,9 @@ sleep 10 RET=-1 until [ "$RET" -eq "0" ] do + echo "Jenkinsへの接続を試みます..." sleep 10 - wget --no-proxy -O $ALM_INSTALL_DIR/bin/jenkins-cli.jar http://localhost:8080/jenkins/jnlpJars/jenkins-cli.jar + wget --no-proxy -O $ALM_INSTALL_DIR/bin/jenkins-cli.jar http://localhost:8080/jenkins/jnlpJars/jenkins-cli.jar 2>/dev/null RET=$? done diff --git a/smelt b/smelt index 53b57ded..7273f135 100755 --- a/smelt +++ b/smelt @@ -11,8 +11,8 @@ ALM_GIT_VERSION=${ALM_GIT_VERSION:-2.9.0} ALM_GIT_AUTO_UPGRADE=${ALM_GIT_AUTO_UPGRADE:-N} ALM_LOG_DIR=${ALM_LOG_DIR:-/var/log/alminium} -ALM_DB_HOST= -ALM_DB_ROOT_PASS= +#ALM_DB_HOST= +#ALM_DB_ROOT_PASS= RAILS_ENV=production diff --git a/upgrade b/upgrade index 961eb561..c69753a0 100755 --- a/upgrade +++ b/upgrade @@ -9,12 +9,14 @@ ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} ALM_VAR_DIR=/var/opt/alminium ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} +ALM_DB_HOST=$2 +ALM_DB_ROOT_PASS=$3 # 実行ユーザーをチェック source inst-script/check-user # ALMiniumインストール状況をチェック -if [ ! -e $ALM_INSTALL_DIR/app ]; then +if [ ! -e ${ALM_INSTALL_DIR}/app ]; then echo "ALMiniumインストールディレクトリが見つかりませんでした。処理を中止します" exit 1 fi @@ -42,14 +44,14 @@ fi # ログをバックアップ mkdir -p /tmp/alminium-logs -if [ -d $ALM_INSTALL_DIR/log ]; then - cp -pr $ALM_INSTALL_DIR/log/ /tmp/alminium-logs +if [ -d ${ALM_INSTALL_DIR}/log ]; then + cp -pr ${ALM_INSTALL_DIR}/log/ /tmp/alminium-logs fi -if [ -d /var/log/$MYSQL_LOG_DIR ]; then - cp -pr /var/log/$MYSQL_LOG_DIR/ /tmp/alminium-logs +if [ -d /var/log/${MYSQL_LOG_DIR} ]; then + cp -pr /var/log/${MYSQL_LOG_DIR}/ /tmp/alminium-logs fi -if [ -d /var/log/$APACHE_LOG_DIR ]; then - cp -pr /var/log/$APACHE_LOG_DIR/ /tmp/alminium-logs +if [ -d /var/log/${APACHE_LOG_DIR} ]; then + cp -pr /var/log/${APACHE_LOG_DIR}/ /tmp/alminium-logs fi if [ -d /var/log/jenkins ]; then cp -pr /var/log/jenkins/ /tmp/alminium-logs @@ -70,12 +72,12 @@ echo "" echo "ALMiniumのアップグレードを開始・・・" # アップグレード対象を削除 -if [ -f $ALM_INSTALL_DIR/subdirname ]; then - rm -f /var/www/html`cat $ALM_INSTALL_DIR/subdirname` +if [ -f ${ALM_INSTALL_DIR}/subdirname ]; then + rm -f /var/www/html`cat ${ALM_INSTALL_DIR}/subdirname` fi -rm -fr $ALM_INSTALL_DIR/* $ALM_INSTALL_DIR/.[^.]* +rm -fr ${ALM_INSTALL_DIR}/* ${ALM_INSTALL_DIR}/.[^.]* rm -fr cache/* *.installed -rm -fr $ALM_ETC_DIR/passenger.* +rm -fr ${ALM_ETC_DIR}/passenger.* # install ALMinium by smelt source ./smelt -u @@ -88,15 +90,15 @@ source ./restore ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME} $2 $3 restore_log() { local LOG_DIR="/tmp/alminium-logs/$1" local TO_PATH=$2 - if [ "$TO_PATH" = "" ];then TO_PATH=$1; fi - if [ -d $LOG_DIR -a "`ls $LOG_DIR`" != "" ]; then - cp -pr $LOG_DIR/* $ALM_LOG_DIR/$TO_PATH/ + if [ "${TO_PATH}" = "" ];then TO_PATH=$1; fi + if [ -d ${LOG_DIR} -a "`ls ${LOG_DIR}`" != "" ]; then + cp -pr ${LOG_DIR}/* ${ALM_LOG_DIR}/${TO_PATH}/ fi } restore_log log redmine -restore_log $MYSQL_LOG_DIR -restore_log $APACHE_LOG_DIR +restore_log ${MYSQL_LOG_DIR} +restore_log ${APACHE_LOG_DIR} restore_log jenkins echo "" From 9c338b43e37f62cab6c1af9c10462f7ed1634e06 Mon Sep 17 00:00:00 2001 From: masa-onda Date: Sun, 20 Nov 2016 00:12:43 +0900 Subject: [PATCH 08/34] to suppport external db(#93) --- inst-script/rhel7/install_db_client | 4 ++++ inst-script/rhel7/packages.lst | 1 - inst-script/rhel7/pre-install | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100755 inst-script/rhel7/install_db_client diff --git a/inst-script/rhel7/install_db_client b/inst-script/rhel7/install_db_client new file mode 100755 index 00000000..4dff6335 --- /dev/null +++ b/inst-script/rhel7/install_db_client @@ -0,0 +1,4 @@ +#!/bin/bash + +yum install -y mariadb + diff --git a/inst-script/rhel7/packages.lst b/inst-script/rhel7/packages.lst index 00b66737..bc2e8af0 100644 --- a/inst-script/rhel7/packages.lst +++ b/inst-script/rhel7/packages.lst @@ -22,7 +22,6 @@ libyaml-devel make mariadb mariadb-devel -mariadb-server mercurial mod_dav_svn mod_passenger diff --git a/inst-script/rhel7/pre-install b/inst-script/rhel7/pre-install index e9106301..b6aaf5f7 100644 --- a/inst-script/rhel7/pre-install +++ b/inst-script/rhel7/pre-install @@ -31,8 +31,11 @@ if [ "$ALM_ENABLE_SSL" = "y" ]; then fi # データベース起動および自動起動設定 -service mariadb start -systemctl enable mariadb +if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then + yum install -y mariadb-server + service mariadb start + systemctl enable mariadb +fi # git update if [ "$GIT_UPDATE" = "y" ]; then From 6c67d34950f3daa3ca6c2d725c71cbeeee4019eb Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 21 Nov 2016 23:30:21 +0900 Subject: [PATCH 09/34] add ALM_DB_SETUP for ALMinium docker container to use external DB(#93) --- backup | 16 +- inst-script/.select-db.swp | Bin 0 -> 12288 bytes inst-script/config-alminium | 4 - inst-script/config-backup | 2 +- inst-script/install-redmine | 163 ++++++++++++------ inst-script/select-db | 2 +- .../{redmine-plugins1 => install-plugins} | 38 ---- redmine/setup/install-plugins-jenkins | 35 ++++ redmine/setup/redmine-plugins | 11 -- redmine/setup/redmine-plugins.lst | 2 +- redmine/setup/redmine-plugins2 | 31 ---- redmine/setup/setup-db | 65 +++++++ restore | 21 +-- smelt | 19 +- uninstall | 21 ++- upgrade | 13 +- 16 files changed, 269 insertions(+), 174 deletions(-) create mode 100644 inst-script/.select-db.swp rename redmine/setup/{redmine-plugins1 => install-plugins} (71%) create mode 100644 redmine/setup/install-plugins-jenkins delete mode 100644 redmine/setup/redmine-plugins delete mode 100644 redmine/setup/redmine-plugins2 create mode 100644 redmine/setup/setup-db diff --git a/backup b/backup index 68e67c05..255dfeef 100755 --- a/backup +++ b/backup @@ -5,12 +5,18 @@ # 第2引数:データベースホスト名 # 第3引数:データベース管理者パスワード ############################################################ +ALM_SRC_DIR=${ALM_SRC_DIR:-$(cd $(dirname $0);pwd)} +ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} +ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} -ALM_DB_HOST=${ALM_DB_HOST:-$2} +ALM_DB_HOST=${2:-${ALM_DB_HOST}} ALM_DB_HOST=${ALM_DB_HOST:-localhost} -ALM_DB_ROOT_PASS=${ALM_DB_ROOT_PASS:-$3} +ALM_DB_ROOT_PASS=${3:-${ALM_DB_ROOT_PASS}} -ALM_CURRENT_DIR=${ALM_CURRENT_DIR:-`pwd`} +ALM_CURRENT_DIR=`pwd` + +# move to sources directry +cd ${ALM_SRC_DIR} # include functions source inst-script/functions @@ -66,14 +72,14 @@ check_backup_result ${ALM_DBBACKUP_NAME} "データベースバックアップ" #redmineの添付ファイルをバックアップ echo "Redmineの添付ファイルをバックアップします。" -pushd /opt/alminium/files/ +pushd ${ALM_INSTALL_DIR}/files/ tar czf ${ALM_BACKUP_DIR}/${ALM_FILE_BACKUP} . check_backup_result ${ALM_FILE_BACKUP} "添付ファイルバックアップ" popd #ソースコードリポジトリ echo "ソースコードリポジトリをバックアップします。" -pushd /var/opt/alminium/ +pushd ${ALM_VAR_DIR}/ tar czf ${ALM_BACKUP_DIR}/${ALM_REPOS_BACKUP} . check_backup_result ${ALM_REPOS_BACKUP} "ソースコードリポジトリバックアップ" popd diff --git a/inst-script/.select-db.swp b/inst-script/.select-db.swp new file mode 100644 index 0000000000000000000000000000000000000000..e09b2f66c5b48fde87991e6bae4ba59b7f371fca GIT binary patch literal 12288 zcmeI2%WoT16o+qFAn_<5Sc1f@lZusb3Y9>uya-Atk(vj!0~Mt>wr4C4n$A@5SXIQM zxiblM+qAd@2x$>%s)oM6K?qPwL$XKxA6Oj5?yewMvEn!5M}y^1(FIbaGs)+Peeaw( z=ey@FB2T90wShtT!n4~2j>m-f;;){)tIza_%Z?DXrKN+9?{pM1MawB}+ujof*?9K* zLBN<}+h!q_HV+t<~18jf|umLu}2G{@_xCafSH6hj>#CQD{;&`?KnWZMMPPv>*a5o1)8HxaB=`+E z+yLK#&%h~g2#kXuKNGwS@*oE^kO5=hE$}9I1MtBH*Z><~18jf|umLu}2L3Mty}Jif zeJ`b68BXMk4nH|VNEyCJ8B85b^r!mw4kVHTL%VQYd;-I|SD_%o-A_NGd!G3jr1lG z@m3!HEyGrEnr-Pa4AK%Jap>8+Ey+7V-U_*ECueXWhLFtw=F zA-h^-u~z=z=HxVar^vlV-g1z&ca+?Z{OKkC*cnpD@k>%4k~&N36H-&RR!(=gCE6x= z$GegHeHgxsSHFDXUv9D^jHTJ(=}_J<^?G}>s|m-uAcfRbQWbK~k-JRp^`I6tQ!SPK zV+*9_$vqy5zd+uVFas2Y-^-Xo?osj-xft?rZ5Xg%7ss=@T>pS~_i!S7;5%)aDVWci zhHlk6x=U&qS$`j1ff)$WT+0qyrQWR*5qW!ITZ`A$*gFxaxp>vNbLgd;7r(CkRH3uw-=KJgMWiRu=Y6#D?}a<3}R@++QQR_Vo7k zBhxL|f=D%*-e7Y!Yv_`Jdnokg$o+=Auj+kNop*n|zT}_(6zz^h^3eHcvQn`4s#2Xf w;#aUQW@=N5Xe|HicYYalEz_hTg$)wy5zMKb|IuHaCbfuXe`Wnadngxw1Ll=6= 1.6.7.2\"/gem \"nokogiri\"#, \">= 1.6.7.2\"/" \ + Gemfile + + # redmineに必要なgemをインストール + bundle install --path vendor/bundle \ + --without development test postgresql sqlite xapian + popd +} + +# create secret token +create_redmine_token() { + pushd ${ALM_INSTALL_DIR} + bundle exec rake generate_secret_token + popd +} + +# setup DB +setup_db() { + if [ "${ALM_SETUP_DB}" = "y" ]; then + source redmine/setup/setup-db + fi +} + +## sctips ## -# download and put alminium's home dir -mkdir -p $ALM_INSTALL_DIR echo "*** install Redmine ***" -cd cache -wget $RM_ARC -if [ ! -f redmine-$RM_VER ]; then - tar zxf $RM_VER.tar.gz -fi -cd .. -cp -fr cache/redmine-$RM_VER/* $ALM_INSTALL_DIR/ -rm -fr cache/redmine-$RM_VER - -# put config files -cp -f redmine/Gemfile.local $ALM_INSTALL_DIR/ -cp -fr redmine/config/* $ALM_INSTALL_DIR/config/ -cp -fr redmine/public/themes/* $ALM_INSTALL_DIR/public/themes/ -cp ./{backup,restore} ./inst-script/config-backup \ - ./inst-script/$OS/service-restart $ALM_INSTALL_DIR/ - -# update db-config -sed -i "s/localhost/${ALM_DB_HOST}/" $ALM_INSTALL_DIR/config/database.yml - -# avoid bandle install error because of nokogiri version conflict -mv $ALM_INSTALL_DIR/Gemfile $ALM_INSTALL_DIR/Gemfile.org -sed "s/gem \"nokogiri\", \">= 1.6.7.2\"/gem \"nokogiri\"#, \">= 1.6.7.2\"/" $ALM_INSTALL_DIR/Gemfile.org > $ALM_INSTALL_DIR/Gemfile + +# download and put alminium's home dir +download_redmine + +# setup configurations +setup_configurations + +# create repositries' directories +create_repo_dir + +# install hooks +setup_hooks # install plugins echo "*** install plugins ***" -source redmine/setup/redmine-plugins +source redmine/setup/install-plugins -if [ "$ALM_UPGRADE" = "" ]; then - # Customize - echo "*** run initialize SQL ***" - mysql `db_option` alminium < redmine/setup/init.mysql -fi +# install gems +install_gems -# install hooks -mkdir -p $ALM_INSTALL_DIR/bin -cp -fr redmine/bin/* $ALM_INSTALL_DIR/bin/ -if [ "$ALM_SUBDIR" != "" ]; then - sed -i "s|localhost|localhost$ALM_SUBDIR|g" $ALM_INSTALL_DIR/bin/alm-sync-scm - chmod +x $ALM_INSTALL_DIR/bin/alm-sync-scm -fi -cp -fr redmine/hooks $ALM_INSTALL_DIR/ -chown -R $APACHE_USER:$APACHE_USER $ALM_INSTALL_DIR/* - -# config settings -db_update_setting 'host_name' ${ALM_HOSTNAME}$ALM_SUBDIR -db_update_setting 'protocol' `protocol` +# セッションストア秘密鍵を生成 +create_redmine_token + +# setup redmine db +setup_db + +# jenkins関連プラグイン +# この位置でインストールしないとエラーになる +source redmine/setup/install-plugins-jenkins + +# 権限設定 +chown -R ${APACHE_USER}:${APACHE_USER} ${ALM_INSTALL_DIR}/* diff --git a/inst-script/select-db b/inst-script/select-db index 10a98b2b..5cecd86d 100755 --- a/inst-script/select-db +++ b/inst-script/select-db @@ -2,7 +2,7 @@ # アップグレード時以外でDBホスト名の指定が無い場合は、ここで指示待ち if [ "${ALM_UPGRADE}" != "y" -a "${ALM_DB_HOST}" = "" ]; then - echo + echo "" echo -n 既に設置済みのMySQLデータベースサービスを利用しますか?[y/N] read ALM_USE_EXISTING_DB; if [ "${ALM_USE_EXISTING_DB}" = "y" ]; then diff --git a/redmine/setup/redmine-plugins1 b/redmine/setup/install-plugins similarity index 71% rename from redmine/setup/redmine-plugins1 rename to redmine/setup/install-plugins index 2940e729..2b57b353 100644 --- a/redmine/setup/redmine-plugins1 +++ b/redmine/setup/install-plugins @@ -73,12 +73,6 @@ done # ALMiniumインストールディレクトリへ移動 pushd $ALM_INSTALL_DIR -# passenger package -if [ "$ALM_PASSSENGER_PACKAGE_AVAILABLE" = "1" ]; then - mv Gemfile.local Gemfile.local.org - cat Gemfile.local.org | sed "s/gem 'passenger'/#gem 'passenger'/" > Gemfile.local -fi - # for Hudson if [ -f plugins/redmine_hudson/Gemfile ]; then mv plugins/redmine_hudson/Gemfile plugins/redmine_hudson/Gemfile.org @@ -108,38 +102,6 @@ azure) esac cd .. -# redmineに必要なgemをインストール -bundle install --path vendor/bundle --without development test xapian - -# セッションストア秘密鍵を生成 -bundle exec rake generate_secret_token - -# データベース上にテーブルを作成 -bundle exec rake db:migrate RAILS_ENV=production -bundle exec rake redmine:plugins:migrate RAILS_ENV=production - -# データベースにデフォルトデータを登録 -echo 'ja' |\ -bundle exec rake redmine:load_default_data RAILS_ENV=production - -# キャッシュクリア -bundle exec rake tmp:cache:clear RAILS_ENV=production -bundle exec rake tmp:sessions:clear RAILS_ENV=production - -# for XLS export -if [ -d plugins/redmine_xls_export ]; then - bundle exec rake redmine:plugins:process_version_change RAILS_ENV=production -fi - -# for backlogs -if [ -d plugins/redmine_backlogs ]; then - if [ "$ALM_UPGRADE" = "y" ]; then - bundle exec rake redmine:backlogs:install task_tracker=タスク story_trackers=機能 labels=false RAILS_ENV=production - else - bundle exec rake redmine:backlogs:install task_tracker=サポート story_trackers=機能 labels=false RAILS_ENV=production - fi -fi - # ディレクトリを元に戻す popd diff --git a/redmine/setup/install-plugins-jenkins b/redmine/setup/install-plugins-jenkins new file mode 100644 index 00000000..55a0951d --- /dev/null +++ b/redmine/setup/install-plugins-jenkins @@ -0,0 +1,35 @@ +#!/bin/bash +# Jenkinsプラグインをインストールする +# + +# DBセットアップをしない場合は、一時ディレクトリにダウンロードする +if [ "$ALM_SETUP_DB" = "y" ]; then + PLUGINS_DIR=${ALM_INSTALL_DIR}/plugins +else + PLUGINS_DIR=${ALM_INSTALL_DIR}/plugins-jenkins + mkdir -p PLUGINS_DIR +fi +# カレントディレクトリを退避 +pushd ${PLUGINS_DIR} + +# install redmine_bootstrap +git clone -b 0.2.3 https://github.com/jbox-web/redmine_bootstrap_kit.git + +# install redmine_jenkins +git clone -b 1.0.1 https://github.com/jbox-web/redmine_jenkins.git + +if [ "$ALM_SETUP_DB" = "y" ]; then + # install gems and migrate database + cd .. + bundle install --path vendor/bundle \ + --without development test postgresql sqlite xapian + bundle exec rake redmine:plugins:migrate \ + RAILS_ENV=production NAME=redmine_jenkins +fi + +# 権限を変更 +chown -R ${APACHE_USER}:${APACHE_USER} ${ALM_INSTALL_DIR}/* + +# ディレクトリを元に戻す +popd + diff --git a/redmine/setup/redmine-plugins b/redmine/setup/redmine-plugins deleted file mode 100644 index 64b88103..00000000 --- a/redmine/setup/redmine-plugins +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# -# プラグインをインストールすると同時にRedmineの初期設定を行う -# - -# 初期設定およびプラグインインストール -source redmine/setup/redmine-plugins1 - -# 初期設定後にインストールすべきプラグイン -source redmine/setup/redmine-plugins2 - diff --git a/redmine/setup/redmine-plugins.lst b/redmine/setup/redmine-plugins.lst index 440822a9..75594a68 100644 --- a/redmine/setup/redmine-plugins.lst +++ b/redmine/setup/redmine-plugins.lst @@ -13,7 +13,7 @@ redmine_importer,master,https://github.com/agileware-jp/redmine_importer.git #redmine_code_review,0.7.0,https://bitbucket.org/haru_iida/redmine_code_review redmine_code_review,master,https://github.com/ayapapa/redmine_code_review.git # jenkins関係をここでインストールすると失敗する(別途インストールするようにした) -#redmine_bootstrap,0.2.3,https://github.com/jbox-web/redmine_bootstrap_kit.git +#redmine_bootstrap,0.2.4,https://github.com/jbox-web/redmine_bootstrap_kit.git #redmine_jenkins,1.0.1,https://github.com/jbox-web/redmine_jenkins.git redmine_backlogs,redmine3,https://github.com/ayapapa/redmine_backlogs.git redmine_spent_time_column,backlogs-support,https://github.com/mikoto20000/redmine_spent_time_column.git diff --git a/redmine/setup/redmine-plugins2 b/redmine/setup/redmine-plugins2 deleted file mode 100644 index 6db2d0fe..00000000 --- a/redmine/setup/redmine-plugins2 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# 最後にインストールする必要があるプラグインをインストールする -# - -# カレントディレクトリを退避 -pushd . - -# install redmine_bootstrap -cd $ALM_INSTALL_DIR/plugins -git clone https://github.com/jbox-web/redmine_bootstrap_kit.git -cd redmine_bootstrap_kit/ -git checkout 0.2.3 - -# install redmine_jenkins -cd $ALM_INSTALL_DIR/plugins -git clone https://github.com/jbox-web/redmine_jenkins.git -cd redmine_jenkins/ -git checkout 1.0.1 - -#Install gems and migrate database -cd $ALM_INSTALL_DIR/ -bundle install --path vendor/bundle --without development test -bundle exec rake redmine:plugins:migrate RAILS_ENV=production NAME=redmine_jenkins - -# 権限を変更 -chown -R $APACHE_USER:$APACHE_USER $ALM_INSTALL_DIR/* - - -# ディレクトリを元に戻す -popd - diff --git a/redmine/setup/setup-db b/redmine/setup/setup-db new file mode 100644 index 00000000..1ae86e71 --- /dev/null +++ b/redmine/setup/setup-db @@ -0,0 +1,65 @@ +#!/bin/bash +# +# + +echo "*** run initialize DB ***" + +# ALMiniumインストールディレクトリへ移動 +pushd $ALM_INSTALL_DIR + +# create db +if [ "$ALM_UPGRADE" != "y" ]; then + # create DB + mysql `db_option` < ${ALM_SRC_DIR}/redmine/setup/createdb.sql +fi + +# データベースにテーブルを作成 +bundle exec rake db:migrate RAILS_ENV=production + +# データベースにデフォルトデータを登録 +echo 'ja' |\ +bundle exec rake redmine:load_default_data RAILS_ENV=production + +# プラグインをデータベースに登録 +bundle exec rake redmine:plugins:migrate RAILS_ENV=production + +# for XLS export +if [ -d plugins/redmine_xls_export ]; then + bundle exec rake redmine:plugins:process_version_change RAILS_ENV=production +fi + +# for backlogs +if [ -d plugins/redmine_backlogs ]; then + if [ "$ALM_UPGRADE" = "y" ]; then + bundle exec rake redmine:backlogs:install task_tracker=タスク story_trackers=機能 labels=false RAILS_ENV=production + else + bundle exec rake redmine:backlogs:install task_tracker=サポート story_trackers=機能 labels=false RAILS_ENV=production + fi +fi + +# キャッシュクリア +bundle exec rake tmp:cache:clear RAILS_ENV=production +bundle exec rake tmp:sessions:clear RAILS_ENV=production + +# Customize +if [ "$ALM_UPGRADE" != "y" ]; then + echo "*** run initialize SQL ***" + mysql `db_option` alminium < ${ALM_SRC_DIR}/redmine/setup/init.mysql +fi + +# config settings +# protocol +protocol() { + if [ "$ALM_ENABLE_SSL" = "y" ]; then + echo "https" + else + echo "http" + fi +} + +db_update_setting 'host_name' ${ALM_HOSTNAME}${ALM_SUBDIR} +db_update_setting 'protocol' `protocol` + +# ディレクトリを元に戻す +popd + diff --git a/restore b/restore index 196b908d..09225852 100755 --- a/restore +++ b/restore @@ -5,13 +5,14 @@ # 第2引数:データベースホスト名 # # 第3引数:データベース管理者パスワード # ######################################### +ALM_SRC_DIR=${ALM_SRC_DIR:-$(cd $(dirname $0);pwd)} +ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} +ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} ALM_DB_HOST=${ALM_DB_HOST:-$2} ALM_DB_HOST=${ALM_DB_HOST:-localhost} ALM_DB_ROOT_PASS=${ALM_DB_ROOT_PASS:-$3} -ALM_CURRENT_DIR=${ALM_CURRENT_DIR:-`pwd`} - # 実行ユーザーをチェック if [ "`whoami`" != 'root' ]; then echo "ALMiniumのインストールはルートユーザで行う必要があります。" @@ -34,6 +35,9 @@ ALM_DBBACKUP_NAME=/tmp/db.dump ALM_FILE_BACKUP=/tmp/files.tar.gz ALM_REPOS_BACKUP=/tmp/repo.tar.gz +# move to sources directry +cd ${ALM_SRC_DIR} + # include functions source inst-script/functions @@ -43,16 +47,16 @@ cd /tmp tar xzf ${ALM_BACKUP_NAME} echo "***リポジトリーデータを復元しています..." -cd /var/opt/alminium/ && tar xzf ${ALM_REPOS_BACKUP} +cd ${ALM_VAR_DIR} && tar xzf ${ALM_REPOS_BACKUP} echo "***Redmine添付ファイルを復元しています..." -cd /opt/alminium/files/ && tar xzf ${ALM_FILE_BACKUP} +cd ${ALM_INSTALL_DIR}/files/ && tar xzf ${ALM_FILE_BACKUP} if [ "${ALM_DB_RESTORE}" != "no" ]; then echo "***データベースを復元しています..." mysql `db_option` alminium < ${ALM_DBBACKUP_NAME} echo "データ復元が完了しました。" #データベースのマイグレーション echo "データベースのマイグレーションを実施します。" - cd /opt/alminium + cd ${ALM_INSTALL_DIR} bundle exec rake db:migrate RAILS_ENV=production bundle exec rake redmine:plugins:migrate RAILS_ENV=production bundle exec rake tmp:cache:clear RAILS_ENV=production @@ -60,11 +64,8 @@ if [ "${ALM_DB_RESTORE}" != "no" ]; then echo "データベースのマイグレーションが完了しました。" fi -cd ${ALM_CURRENT_DIR} -if [ -f service-restart ]; then - echo "サービスを再起動します。" - source ./service-restart -elif [ -f inst-script/service-restart ]; then +cd ${ALM_SRC_DIR} +if [ -f inst-script/service-restart ]; then echo "サービスを再起動します。" source ./inst-script/service-restart else diff --git a/smelt b/smelt index 7273f135..7138b870 100755 --- a/smelt +++ b/smelt @@ -2,20 +2,25 @@ ############################################################ # Smart installer for redmine/chiliproject. ############################################################ -ALM_SRC_DIR=$(cd $(dirname $0);pwd) -ALM_ETC_DIR=/etc/opt/alminium -ALM_VAR_DIR=/var/opt/alminium -ALM_INSTALL_DIR=/opt/alminium +ALM_SRC_DIR=${ALM_SRC_DIR:-$(cd $(dirname $0);pwd)} +ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} +ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} +ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} +ALM_LOG_DIR=${ALM_LOG_DIR:-/var/log/alminium} + ALM_ENABLE_AUTO_BACKUP=${ALM_ENABLE_AUTO_BACKUP:-y} ALM_GIT_VERSION=${ALM_GIT_VERSION:-2.9.0} ALM_GIT_AUTO_UPGRADE=${ALM_GIT_AUTO_UPGRADE:-N} -ALM_LOG_DIR=${ALM_LOG_DIR:-/var/log/alminium} - +ALM_SETUP_DB=${ALM_SETUP_DB:-y} #ALM_DB_HOST= #ALM_DB_ROOT_PASS= RAILS_ENV=production + +# move to sources directry +cd ${ALM_SRC_DIR} + RM_VER=${RM_VER:-`cat RM_VERSION`} RM_ARC=https://github.com/redmine/redmine/archive/${RM_VER}.tar.gz @@ -66,7 +71,7 @@ source inst-script/select-db source inst-script/pre-install # setup database -source inst-script/config-db +#source inst-script/config-db # setup apache source inst-script/config-apache diff --git a/uninstall b/uninstall index 606c0e4c..1be8bd80 100755 --- a/uninstall +++ b/uninstall @@ -1,16 +1,23 @@ #!/bin/bash +########################################## +# uninstaller for ALMinium # 第1引数:データベースホスト名 # 第2引数:データベース管理者パスワード +########################################## +ALM_SRC_DIR=$(cd $(dirname $0);pwd) +ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} +ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} +ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} -ALM_DB_HOST=${ALM_DB_HOST:-$1} +ALM_DB_HOST=${1:-${ALM_DB_HOST}} ALM_DB_HOST=${ALM_DB_HOST:-localhost} -ALM_DB_ROOT_PASS=${ALM_DB_ROOT_PASS:-$2} +ALM_DB_ROOT_PASS=${2:-${ALM_DB_ROOT_PASS}} GEM=`which gem2.0` GEM=${GEM:-gem} -ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} -ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} -ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} + +# move to sources directry +cd ${ALM_SRC_DIR} # include functions source inst-script/functions @@ -22,7 +29,6 @@ echo "" # remove db echo -n "データベース(全てのRedmineの情報)とリポジトリを削除しますか?(y/N)" read YN - if [ "$YN" = "y" ]; then DBCMD="mysql `db_option`" ${DBCMD} alminium -e "REVOKE ALL ON alminium.* FROM alminium@%" \ @@ -39,7 +45,6 @@ fi echo "" echo -n "Apacheの設定を削除しますか?(y/N)" read YN - if [ "$YN" = "y" ]; then rm -fr /etc/httpd/conf.d/{alminium}.conf rm -fr /etc/apache2/conf.d/{alminium}.conf @@ -51,7 +56,6 @@ fi echo "" echo -n "Jenkisとその設定を削除しますか?(y/N)" read YN - if [ "$YN" = "y" ]; then source jenkins/setup/uninstall.sh fi @@ -60,7 +64,6 @@ fi echo "" echo -n "キャッシュされたファイルを削除しますか?(y/N)" read YN - if [ "$YN" = "y" ]; then rm -fr cache *.installed fi diff --git a/upgrade b/upgrade index c69753a0..9b65e22a 100755 --- a/upgrade +++ b/upgrade @@ -5,12 +5,17 @@ # 第2引数:データベースホスト名 # 第3引数:データベース管理者パスワード ############################################################ - +ALM_SRC_DIR=$(cd $(dirname $0);pwd) ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} ALM_VAR_DIR=/var/opt/alminium ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} -ALM_DB_HOST=$2 -ALM_DB_ROOT_PASS=$3 + +ALM_DB_HOST=${2:-${ALM_DB_HOST}} +ALM_DB_HOST=${ALM_DB_HOST:-localhost} +ALM_DB_ROOT_PASS=${3:-${ALM_DB_ROOT_PASS}} + +# move to sources directry +cd ${ALM_SRC_DIR} # 実行ユーザーをチェック source inst-script/check-user @@ -91,7 +96,7 @@ restore_log() { local LOG_DIR="/tmp/alminium-logs/$1" local TO_PATH=$2 if [ "${TO_PATH}" = "" ];then TO_PATH=$1; fi - if [ -d ${LOG_DIR} -a "`ls ${LOG_DIR}`" != "" ]; then + if [ -d ${LOG_DIR} -a "`ls ${LOG_DIR} 2>/dev/null`" != "" ]; then cp -pr ${LOG_DIR}/* ${ALM_LOG_DIR}/${TO_PATH}/ fi } From 5e90071edc053af364c56e0d079d00ae663939c2 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Tue, 22 Nov 2016 22:11:36 +0900 Subject: [PATCH 10/34] add ALM_DB_SETUP for ALMinium docker container to use external DB(#93) --- inst-script/install-redmine | 2 +- inst-script/select-db | 1 + redmine/setup/install-plugins-jenkins | 6 +++--- smelt | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/inst-script/install-redmine b/inst-script/install-redmine index 73a34122..44b2ba00 100755 --- a/inst-script/install-redmine +++ b/inst-script/install-redmine @@ -84,7 +84,7 @@ create_redmine_token() { # setup DB setup_db() { - if [ "${ALM_SETUP_DB}" = "y" ]; then + if [ "${ALM_DB_SETUP}" = "y" ]; then source redmine/setup/setup-db fi } diff --git a/inst-script/select-db b/inst-script/select-db index 5cecd86d..6c35ee2d 100755 --- a/inst-script/select-db +++ b/inst-script/select-db @@ -11,6 +11,7 @@ if [ "${ALM_UPGRADE}" != "y" -a "${ALM_DB_HOST}" = "" ]; then # DBへのアクセスが成功するまでループしながらチェック while [ "${DB_TEST}" = "" ] do + echo "" echo -n データベースサーバー名を入力してください: read ALM_DB_HOST echo -n データベース管理者パスワードを入力してください: diff --git a/redmine/setup/install-plugins-jenkins b/redmine/setup/install-plugins-jenkins index 55a0951d..edb41d06 100644 --- a/redmine/setup/install-plugins-jenkins +++ b/redmine/setup/install-plugins-jenkins @@ -3,7 +3,7 @@ # # DBセットアップをしない場合は、一時ディレクトリにダウンロードする -if [ "$ALM_SETUP_DB" = "y" ]; then +if [ "${ALM_DB_SETUP}" = "y" ]; then PLUGINS_DIR=${ALM_INSTALL_DIR}/plugins else PLUGINS_DIR=${ALM_INSTALL_DIR}/plugins-jenkins @@ -13,12 +13,12 @@ fi pushd ${PLUGINS_DIR} # install redmine_bootstrap -git clone -b 0.2.3 https://github.com/jbox-web/redmine_bootstrap_kit.git +git clone -b 0.2.4 https://github.com/jbox-web/redmine_bootstrap_kit.git # install redmine_jenkins git clone -b 1.0.1 https://github.com/jbox-web/redmine_jenkins.git -if [ "$ALM_SETUP_DB" = "y" ]; then +if [ "$ALM_DB_SETUP" = "y" ]; then # install gems and migrate database cd .. bundle install --path vendor/bundle \ diff --git a/smelt b/smelt index 7138b870..260742fd 100755 --- a/smelt +++ b/smelt @@ -11,7 +11,7 @@ ALM_LOG_DIR=${ALM_LOG_DIR:-/var/log/alminium} ALM_ENABLE_AUTO_BACKUP=${ALM_ENABLE_AUTO_BACKUP:-y} ALM_GIT_VERSION=${ALM_GIT_VERSION:-2.9.0} ALM_GIT_AUTO_UPGRADE=${ALM_GIT_AUTO_UPGRADE:-N} -ALM_SETUP_DB=${ALM_SETUP_DB:-y} +ALM_DB_SETUP=${ALM_DB_SETUP:-y} #ALM_DB_HOST= #ALM_DB_ROOT_PASS= From 6f961d25f7169d925b867488d6908526131b927e Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 27 Nov 2016 15:28:39 +0900 Subject: [PATCH 11/34] update jenkins plugin and code_review plugin --- redmine/setup/install-plugins-jenkins | 2 +- redmine/setup/redmine-plugins.lst | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/redmine/setup/install-plugins-jenkins b/redmine/setup/install-plugins-jenkins index edb41d06..04b9bd92 100644 --- a/redmine/setup/install-plugins-jenkins +++ b/redmine/setup/install-plugins-jenkins @@ -16,7 +16,7 @@ pushd ${PLUGINS_DIR} git clone -b 0.2.4 https://github.com/jbox-web/redmine_bootstrap_kit.git # install redmine_jenkins -git clone -b 1.0.1 https://github.com/jbox-web/redmine_jenkins.git +git clone -b v1.x https://github.com/ayapapa/redmine_jenkins.git if [ "$ALM_DB_SETUP" = "y" ]; then # install gems and migrate database diff --git a/redmine/setup/redmine-plugins.lst b/redmine/setup/redmine-plugins.lst index 75594a68..0963acbe 100644 --- a/redmine/setup/redmine-plugins.lst +++ b/redmine/setup/redmine-plugins.lst @@ -10,11 +10,12 @@ redmine_xls_export,ALMinium,https://github.com/ayapapa/redmine_xls_export.git redmine_plugin_views_revisions,redmine_plugin_views_revisions,http://www.redmine.org/attachments/download/7705/redmine_plugin_views_revisions_v001.zip #redmine_importer,master,https://github.com/zh/redmine_importer.git redmine_importer,master,https://github.com/agileware-jp/redmine_importer.git -#redmine_code_review,0.7.0,https://bitbucket.org/haru_iida/redmine_code_review -redmine_code_review,master,https://github.com/ayapapa/redmine_code_review.git +redmine_code_review,0.8.0,https://bitbucket.org/haru_iida/redmine_code_review +#redmine_code_review,master,https://github.com/ayapapa/redmine_code_review.git # jenkins関係をここでインストールすると失敗する(別途インストールするようにした) #redmine_bootstrap,0.2.4,https://github.com/jbox-web/redmine_bootstrap_kit.git #redmine_jenkins,1.0.1,https://github.com/jbox-web/redmine_jenkins.git +#redmine_jenkins,v1.x,https://github.com/ayapapa/redmine_jenkins.git redmine_backlogs,redmine3,https://github.com/ayapapa/redmine_backlogs.git redmine_spent_time_column,backlogs-support,https://github.com/mikoto20000/redmine_spent_time_column.git redmine_scm,master,https://github.com/ayapapa/redmine_scm.git From 8d79e4082a54b73d4b1b339a35a045f56106abbb Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 27 Nov 2016 23:16:54 +0900 Subject: [PATCH 12/34] update for the case ALM_DB_SETUP != 'y' (#93) --- inst-script/check-os | 3 -- inst-script/config-db | 11 ----- inst-script/debian/packages.lst | 2 +- inst-script/debian/pre-install | 2 +- inst-script/install-jenkins | 6 +++ inst-script/rhel6/pre-install | 10 ++--- inst-script/rhel7/pre-install | 2 +- inst-script/select-db | 58 ++++++++++++++++----------- inst-script/ubuntu1604/packages.lst | 1 + inst-script/ubuntu1604/pre-install | 2 +- redmine/setup/install-plugins-jenkins | 2 +- smelt | 3 -- 12 files changed, 50 insertions(+), 52 deletions(-) delete mode 100755 inst-script/config-db diff --git a/inst-script/check-os b/inst-script/check-os index 08aae51b..4dde4d53 100755 --- a/inst-script/check-os +++ b/inst-script/check-os @@ -44,9 +44,6 @@ if [ "$OS" = "" ]; then MYSQLD='/etc/init.d/mysql' OS='ubuntu1604' ETH0=enp0s3 - if [ ! -f jenkins/setup/ubuntu1604 ]; then - ln -s debian jenkins/setup/ubuntu1604 - fi echo "Ubuntu 16.04 が検出されました。" else echo "サポートされていないOSです。" diff --git a/inst-script/config-db b/inst-script/config-db deleted file mode 100755 index 1d772478..00000000 --- a/inst-script/config-db +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# setup database - -if [ "$ALM_UPGRADE" = "" ]; then - # create DB - mysql `db_option` < redmine/setup/createdb.sql - # create directory for vcs - mkdir -p $ALM_VAR_DIR/{git,svn,hg,maven,github} - chown -R $APACHE_USER:$APACHE_USER $ALM_VAR_DIR/* -fi - diff --git a/inst-script/debian/packages.lst b/inst-script/debian/packages.lst index ac934e75..3702b23c 100644 --- a/inst-script/debian/packages.lst +++ b/inst-script/debian/packages.lst @@ -14,7 +14,7 @@ libsqlite3-dev libssl-dev make mercurial -#mysql-server +mysql-client ruby-switch ruby2.1 ruby2.1-dev diff --git a/inst-script/debian/pre-install b/inst-script/debian/pre-install index bfe584ed..7c5258c6 100755 --- a/inst-script/debian/pre-install +++ b/inst-script/debian/pre-install @@ -44,7 +44,7 @@ else fi # DB -if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then +if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then apt-get install -y mysql-server service mysql start fi diff --git a/inst-script/install-jenkins b/inst-script/install-jenkins index efb1ed3f..297a430c 100755 --- a/inst-script/install-jenkins +++ b/inst-script/install-jenkins @@ -1,6 +1,12 @@ #!/bin/bash # setup for jenkins + echo "*** install Jenkins ***" +if [ "${OS}" = "ubuntu1604" ]; then + JENKINS_SYS=debian +else + JENKINS_SYS=$OS +fi source jenkins/setup/$OS/install.sh source jenkins/setup/config.sh diff --git a/inst-script/rhel6/pre-install b/inst-script/rhel6/pre-install index 557b9eab..42f8d615 100644 --- a/inst-script/rhel6/pre-install +++ b/inst-script/rhel6/pre-install @@ -35,12 +35,10 @@ if [ "$ALM_ENABLE_SSL" = "y" ]; then fi # db -if [ "${ALM_DB_HOST}" = "localhost" ]; then - if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then - yum install -y mysql-server - fi - sed -i "s/log-error=\/var\/log\/mysqld/log-error=\/var\/log\/mysql\/mysqld/" \ - /etc/my.cnf +if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then + yum install -y mysql-server + sed -i "s|log-error=/var/log/mysqld|log-error=/var/log/mysql/mysqld|" \ + /etc/my.cnf mkdir -p /var/log/mysql chkconfig --add mysqld chkconfig mysqld on diff --git a/inst-script/rhel7/pre-install b/inst-script/rhel7/pre-install index b6aaf5f7..99711563 100644 --- a/inst-script/rhel7/pre-install +++ b/inst-script/rhel7/pre-install @@ -31,7 +31,7 @@ if [ "$ALM_ENABLE_SSL" = "y" ]; then fi # データベース起動および自動起動設定 -if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then +if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then yum install -y mariadb-server service mariadb start systemctl enable mariadb diff --git a/inst-script/select-db b/inst-script/select-db index 6c35ee2d..312d5133 100755 --- a/inst-script/select-db +++ b/inst-script/select-db @@ -1,31 +1,41 @@ # select db -# アップグレード時以外でDBホスト名の指定が無い場合は、ここで指示待ち -if [ "${ALM_UPGRADE}" != "y" -a "${ALM_DB_HOST}" = "" ]; then - echo "" - echo -n 既に設置済みのMySQLデータベースサービスを利用しますか?[y/N] - read ALM_USE_EXISTING_DB; - if [ "${ALM_USE_EXISTING_DB}" = "y" ]; then - # db client install - source inst-script/$OS/install_db_client - # DBへのアクセスが成功するまでループしながらチェック - while [ "${DB_TEST}" = "" ] - do +if [ "${ALM_DB_SETUP}" = "y" ]; then + if [ "${ALM_UPGRADE}" = "y" ]; then + if [ "${ALM_DB_HOST}" != "" ]; then + ALM_USE_EXISTING_DB=y + else + ALM_USE_EXISTING_DB=N + ALM_DB_HOST=localhost + ALM_DB_ROOT_PASS= + fi + else + if [ "${ALM_DB_HOST}" = "" ]; then echo "" - echo -n データベースサーバー名を入力してください: - read ALM_DB_HOST - echo -n データベース管理者パスワードを入力してください: - read ALM_DB_ROOT_PASS - DB_TEST=`db_test` - if [ "${DB_TEST}" = "" ]; then - echo データベースに接続できませんでした。 + echo -n 既に設置済みのMySQLデータベースサービスを利用しますか?[y/N] + read ALM_USE_EXISTING_DB; + if [ "${ALM_USE_EXISTING_DB}" = "y" ]; then + # db client install + source inst-script/$OS/install_db_client + # DBへのアクセスが成功するまでループしながらチェック + while [ "${DB_TEST}" = "" ]; do + echo "" + echo -n データベースサーバー名を入力してください: + read ALM_DB_HOST + echo -n データベース管理者パスワードを入力してください: + read ALM_DB_ROOT_PASS + DB_TEST=`db_test` + if [ "${DB_TEST}" = "" ]; then + echo データベースに接続できませんでした。 + fi + done + else + ALM_DB_HOST=localhost + ALM_DB_ROOT_PASS= fi - done - else - ALM_DB_HOST=localhost - ALM_DB_ROOT_PASS= + else + ALM_USE_EXISTING_DB=y + fi fi fi -ALM_DB_HOST=${ALM_DB_HOST:-localhost} - diff --git a/inst-script/ubuntu1604/packages.lst b/inst-script/ubuntu1604/packages.lst index f5f1397a..69ba2009 100644 --- a/inst-script/ubuntu1604/packages.lst +++ b/inst-script/ubuntu1604/packages.lst @@ -15,6 +15,7 @@ libsqlite3-dev libssl-dev make mercurial +mysql-client php-mysql ruby ruby-dev diff --git a/inst-script/ubuntu1604/pre-install b/inst-script/ubuntu1604/pre-install index 3bd6fba2..51ac907f 100755 --- a/inst-script/ubuntu1604/pre-install +++ b/inst-script/ubuntu1604/pre-install @@ -38,7 +38,7 @@ else fi # DB -if [ "${ALM_USE_EXISTING_DB}" != "y" ]; then +if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then apt-get install -y mysql-server service mysql start fi diff --git a/redmine/setup/install-plugins-jenkins b/redmine/setup/install-plugins-jenkins index 04b9bd92..eaeb4bca 100644 --- a/redmine/setup/install-plugins-jenkins +++ b/redmine/setup/install-plugins-jenkins @@ -7,7 +7,7 @@ if [ "${ALM_DB_SETUP}" = "y" ]; then PLUGINS_DIR=${ALM_INSTALL_DIR}/plugins else PLUGINS_DIR=${ALM_INSTALL_DIR}/plugins-jenkins - mkdir -p PLUGINS_DIR + mkdir -p ${PLUGINS_DIR} fi # カレントディレクトリを退避 pushd ${PLUGINS_DIR} diff --git a/smelt b/smelt index 260742fd..3f01f321 100755 --- a/smelt +++ b/smelt @@ -70,9 +70,6 @@ source inst-script/select-db # pre install source inst-script/pre-install -# setup database -#source inst-script/config-db - # setup apache source inst-script/config-apache From e56d9c42e46b936626abca6b6c5333f8ef21f370 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 18 Dec 2016 11:01:02 +0900 Subject: [PATCH 13/34] revert DB user in createdb.sql(#93) --- redmine/setup/createdb.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redmine/setup/createdb.sql b/redmine/setup/createdb.sql index 515a8144..78e23af7 100644 --- a/redmine/setup/createdb.sql +++ b/redmine/setup/createdb.sql @@ -1,2 +1,2 @@ CREATE DATABASE alminium DEFAULT CHARACTER SET utf8; -GRANT ALL PRIVILEGES ON alminium.* TO alminium@'%' IDENTIFIED BY 'alminium'; +GRANT ALL PRIVILEGES ON alminium.* TO alminium@localhost IDENTIFIED BY 'alminium'; From b4a3cbad62c1dc1c462064691c4d0a51032ce7bb Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 19 Dec 2016 23:27:29 +0900 Subject: [PATCH 14/34] added smelt options, those are db-host and it's root password. and added DB(alminium) user('alminium'@'%')(#93) --- .gitignore | 1 + inst-script/.select-db.swp | Bin 12288 -> 0 bytes redmine/setup/createdb.sql | 3 ++- smelt | 26 +++++++++++--------------- upgrade | 3 ++- 5 files changed, 16 insertions(+), 17 deletions(-) delete mode 100644 inst-script/.select-db.swp diff --git a/.gitignore b/.gitignore index 8a229f9e..775d5329 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ gems.installed packages.installed vendor/bundler/ test/.test +*.swp diff --git a/inst-script/.select-db.swp b/inst-script/.select-db.swp deleted file mode 100644 index e09b2f66c5b48fde87991e6bae4ba59b7f371fca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2%WoT16o+qFAn_<5Sc1f@lZusb3Y9>uya-Atk(vj!0~Mt>wr4C4n$A@5SXIQM zxiblM+qAd@2x$>%s)oM6K?qPwL$XKxA6Oj5?yewMvEn!5M}y^1(FIbaGs)+Peeaw( z=ey@FB2T90wShtT!n4~2j>m-f;;){)tIza_%Z?DXrKN+9?{pM1MawB}+ujof*?9K* zLBN<}+h!q_HV+t<~18jf|umLu}2G{@_xCafSH6hj>#CQD{;&`?KnWZMMPPv>*a5o1)8HxaB=`+E z+yLK#&%h~g2#kXuKNGwS@*oE^kO5=hE$}9I1MtBH*Z><~18jf|umLu}2L3Mty}Jif zeJ`b68BXMk4nH|VNEyCJ8B85b^r!mw4kVHTL%VQYd;-I|SD_%o-A_NGd!G3jr1lG z@m3!HEyGrEnr-Pa4AK%Jap>8+Ey+7V-U_*ECueXWhLFtw=F zA-h^-u~z=z=HxVar^vlV-g1z&ca+?Z{OKkC*cnpD@k>%4k~&N36H-&RR!(=gCE6x= z$GegHeHgxsSHFDXUv9D^jHTJ(=}_J<^?G}>s|m-uAcfRbQWbK~k-JRp^`I6tQ!SPK zV+*9_$vqy5zd+uVFas2Y-^-Xo?osj-xft?rZ5Xg%7ss=@T>pS~_i!S7;5%)aDVWci zhHlk6x=U&qS$`j1ff)$WT+0qyrQWR*5qW!ITZ`A$*gFxaxp>vNbLgd;7r(CkRH3uw-=KJgMWiRu=Y6#D?}a<3}R@++QQR_Vo7k zBhxL|f=D%*-e7Y!Yv_`Jdnokg$o+=Auj+kNop*n|zT}_(6zz^h^3eHcvQn`4s#2Xf w;#aUQW@=N5Xe|HicYYalEz_hTg$)wy5zMKb|IuHaCbfuXe`Wnadngxw1Ll=6= 1.9" | bc` = 0 ]; then + if [ ${ALM_GIT_AUTO_UPGRADE} = 'y' ]; then GIT_UPDATE=y else echo diff --git a/inst-script/check-mem b/inst-script/check-mem index 85fec0fb..3ac729ed 100755 --- a/inst-script/check-mem +++ b/inst-script/check-mem @@ -1,7 +1,7 @@ #!/bin/bash # check memory size MEM=`free -t | grep Total | awk '{print $2}'` -if [ $MEM -lt 1000000 ]; then +if [ ${MEM} -lt 1000000 ]; then echo "メモリが不足しています。" echo "ALMiniumのインストールは1GB以上のRAMが利用できるマシン及び仮想マシンに" echo "インストールしてください" diff --git a/inst-script/check-old-alm b/inst-script/check-old-alm index 4cfb73b5..fa7a58bf 100755 --- a/inst-script/check-old-alm +++ b/inst-script/check-old-alm @@ -1,6 +1,6 @@ #!/bin/bash # check old alminium existance -if [ -d $ALM_INSTALL_DIR/app ]; then +if [ -d ${ALM_INSTALL_DIR}/app ]; then echo "古いALMiniumが見つかりました。一度アンインストールするか、" echo "アップグレードコマンドを使ってインストールしてください。" exit 1 diff --git a/inst-script/check-os b/inst-script/check-os index 4dde4d53..e06ad4c4 100755 --- a/inst-script/check-os +++ b/inst-script/check-os @@ -2,7 +2,7 @@ # ネットワーク0のデバイス名 ETH0=${ETH0:-eth0} # check OS -if [ "$OS" = "" ]; then +if [ "${OS}" = "" ]; then if [ -f /etc/redhat-release ]; then APACHE_USER=apache APACHE_CONF_DIR=/etc/httpd/conf.d @@ -10,7 +10,7 @@ if [ "$OS" = "" ]; then MYSQL_LOG_DIR=mysql MYSQLD='/etc/init.d/mysqld' CHK=`egrep "CentOS release 5|Red Hat Enterprise Linux .* 5" /etc/redhat-release` - if [ "$CHK" != '' ]; then + if [ "${CHK}" != '' ]; then OS='rhel5' echo "RHEL 5.x / CentOS 5.x / OEL 5.xが検出されました。" echo "RHEL 5.x / CentOS 5.x / OEL 5.xは、サポートされていません。" @@ -18,7 +18,7 @@ if [ "$OS" = "" ]; then exit 1 fi CHK=`egrep "CentOS Linux release 7" /etc/redhat-release` - if [ "$CHK" != '' ]; then + if [ "${CHK}" != '' ]; then OS='rhel7' echo "CentOS 7.x が検出されました。" MYSQL_LOG_DIR=mariadb diff --git a/inst-script/config-alminium b/inst-script/config-alminium index 46b4fa2b..d8f7a7a8 100755 --- a/inst-script/config-alminium +++ b/inst-script/config-alminium @@ -7,21 +7,21 @@ echo "パスワードを設定したい場合は、ALMiniumのインストール echo "" # ホスト名設定 -if [ "$ALM_HOSTNAME" = "" ]; then +if [ "${ALM_HOSTNAME}" = "" ]; then echo "*******************************************************" echo " ホスト名の設定" echo "*******************************************************" echo "ホスト名(IPアドレスもしくはDNS名)を入力してください。ホスト名はApacheのバーチャルホストで利用されます。" echo "例えば、192.168.1.4をホスト名で入力すると、http://192.168.1.4/でアクセスすることになります。" - IP_ADDR="`ip -f inet -o addr show $ETH0 | cut -d\ -f 7 | cut -d/ -f 1`" - echo -n "ホスト名[$IP_ADDR]:" + IP_ADDR="`ip -f inet -o addr show ${ETH0} | cut -d\ -f 7 | cut -d/ -f 1`" + echo -n "ホスト名[${IP_ADDR}]:" read ALM_HOSTNAME - ALM_HOSTNAME=${ALM_HOSTNAME:-$IP_ADDR} + ALM_HOSTNAME=${ALM_HOSTNAME:-${IP_ADDR}} echo "" fi # SSL設定 -if [ "$ALM_ENABLE_SSL" = "" ]; then +if [ "${ALM_ENABLE_SSL}" = "" ]; then echo "*******************************************************" echo " SSLのサポート" echo "*******************************************************" @@ -44,7 +44,7 @@ fi # # サブディレクトリ指定 # -if [ "$ALM_RELATIVE_URL_ROOT" = "" ]; then +if [ "${ALM_RELATIVE_URL_ROOT}" = "" ]; then echo "*****************************" echo " サブディレクトリ指定 " echo "*****************************" @@ -57,19 +57,19 @@ if [ "$ALM_RELATIVE_URL_ROOT" = "" ]; then echo "" echo "" else - ALM_SUBDIR="$ALM_RELATIVE_URL_ROOT" + ALM_SUBDIR="${ALM_RELATIVE_URL_ROOT}" fi -if [ "$ALM_SUBDIR" != "" ]; then - if [ `echo $ALM_SUBDIR | cut -c 1` != '/' ]; then - ALM_SUBDIR="/$ALM_SUBDIR" +if [ "${ALM_SUBDIR}" != "" ]; then + if [ `echo ${ALM_SUBDIR} | cut -c 1` != '/' ]; then + ALM_SUBDIR="/${ALM_SUBDIR}" fi fi # source inst-script/config-email.sh # jenkins -if [ -e jenkins/setup/$OS/install.sh -a "$ALM_ENABLE_JENKINS" = "" ]; then +if [ -e jenkins/setup/${OS}/install.sh -a "${ALM_ENABLE_JENKINS}" = "" ]; then echo -n "継続的インテグレーションツールのJenkinsのインストール・設定を" echo -n "行うことができます。デフォルトはインストールしません。" echo -n "よく分からなければNを選択してください。" @@ -80,7 +80,7 @@ if [ -e jenkins/setup/$OS/install.sh -a "$ALM_ENABLE_JENKINS" = "" ]; then fi # OAuth2認証 -if [ "$ALM_OAUTH2_METHOD" = "" ]; then +if [ "${ALM_OAUTH2_METHOD}" = "" ]; then echo "### 本機能は実験中(動作確認が不十分)です ###" echo "OAuth2認証サービス(プロバイダ)を選択してください:" echo " 1: Google" @@ -90,11 +90,11 @@ if [ "$ALM_OAUTH2_METHOD" = "" ]; then echo " other: OAuth2認証を利用しない" echo -n "利用したいサービスの番号をお選びください: " read ALM_OAUTH2_METHOD - if [ "$ALM_OAUTH2_METHOD" = "" ] ; then + if [ "${ALM_OAUTH2_METHOD}" = "" ] ; then ALM_OAUTH2_METHOD="N" fi fi -case $ALM_OAUTH2_METHOD in +case ${ALM_OAUTH2_METHOD} in 1) ALM_OAUTH2_METHOD=google ;; diff --git a/inst-script/config-apache b/inst-script/config-apache index 37ab1a51..551fe631 100755 --- a/inst-script/config-apache +++ b/inst-script/config-apache @@ -3,6 +3,6 @@ mkdir -p $ALM_ETC_DIR for FILE in $(ls -F -I *.conf etc | grep -v /) do - cp "etc/$FILE" $ALM_ETC_DIR/ + cp "etc/${FILE}" ${ALM_ETC_DIR}/ done diff --git a/inst-script/config-backup b/inst-script/config-backup index a8151297..96394373 100755 --- a/inst-script/config-backup +++ b/inst-script/config-backup @@ -4,23 +4,23 @@ # ALM_VAR_DIR=${ALM_VAR_DIR:-/var/opt/alminium} ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} -ALM_BACKUP_DIR=${ALM_BACKUP_DIR:-$ALM_VAR_DIR-backup} +ALM_BACKUP_DIR=${ALM_BACKUP_DIR:-${ALM_VAR_DIR}-backup} ALM_BACKUP_LOG=${ALM_BACKUP_LOG:-/opt/alminium/log/backup.log} ALM_BACKUP_MINUTE=${ALM_BACKUP_MINUTE:-0} ALM_BACKUP_HOUR=${ALM_BACKUP_HOUR:-3} ALM_BACKUP_DAY=${ALM_BACKUP_DAY:-*/2} ALM_BACKUP_EXPIRY=${ALM_BACKUP_EXPIRY:-14} -cd $ALM_SRC_DIR -mkdir -p $ALM_BACKUP_DIR -if [ -f $ALM_ETC_DIR/alminium-backup-cron ]; then - sed -e "s|#ALM_BACKUP_DIR#|$ALM_BACKUP_DIR|" \ - -e "s|#ALM_BACKUP_LOG#|$ALM_BACKUP_LOG|" \ - -e "s|#ALM_BACKUP_MINUTE#|$ALM_BACKUP_MINUTE|" \ - -e "s|#ALM_BACKUP_HOUR#|$ALM_BACKUP_HOUR|" \ - -e "s|#ALM_BACKUP_DAY#|$ALM_BACKUP_DAY|" \ - -e "s|#ALM_BACKUP_EXPIRY#|$ALM_BACKUP_EXPIRY|" \ - $ALM_ETC_DIR/alminium-backup-cron > /etc/cron.d/alminium-backup-cron +cd ${ALM_SRC_DIR} +mkdir -p ${ALM_BACKUP_DIR} +if [ -f ${ALM_ETC_DIR}/alminium-backup-cron ]; then + sed -e "s|#ALM_BACKUP_DIR#|${ALM_BACKUP_DIR}|" \ + -e "s|#ALM_BACKUP_LOG#|${ALM_BACKUP_LOG}|" \ + -e "s|#ALM_BACKUP_MINUTE#|${ALM_BACKUP_MINUTE}|" \ + -e "s|#ALM_BACKUP_HOUR#|${ALM_BACKUP_HOUR}|" \ + -e "s|#ALM_BACKUP_DAY#|${ALM_BACKUP_DAY}|" \ + -e "s|#ALM_BACKUP_EXPIRY#|${ALM_BACKUP_EXPIRY}|" \ + ${ALM_ETC_DIR}/alminium-backup-cron > /etc/cron.d/alminium-backup-cron chown root:root /etc/cron.d/alminium-backup-cron else echo -n バックアップ設定ファイルが見つかりません。 diff --git a/inst-script/config-email.sh b/inst-script/config-email.sh index 90c84e41..a75b08e1 100755 --- a/inst-script/config-email.sh +++ b/inst-script/config-email.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ "$SMTPSET" == "" ] +if [ "${SMTPSET}" == "" ] then echo "*******************************************************" echo " メール設定" @@ -28,13 +28,13 @@ echo "" echo "" fi -case "$SMTPSET" in +case "${SMTPSET}" in "0" ) echo "*******************************************************" echo " メールサーバー設定" echo "*******************************************************" - if [ "$SMTPSERVER" == "" ] + if [ "${SMTPSERVER}" == "" ] then echo "SMTPサーバー名を入力してください" echo "" @@ -44,7 +44,7 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPTLS" == "" ] + if [ "${SMTPTLS}" == "" ] then echo "" echo "暗号化が必要なメールサーバーですか?" @@ -56,7 +56,7 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPPORT" == "" ] + if [ "${SMTPPORT}" == "" ] then echo "" echo "メール送信に使用するポート番号を入力してください。" @@ -69,7 +69,7 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPLOGIN" == "" ] + if [ "${SMTPLOGIN}" == "" ] then echo "" echo "メール送信時、サーバーで認証(ログイン)する必要はありますか?" @@ -81,10 +81,10 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPLOGIN" == "Y" ] + if [ "${SMTPLOGIN}" == "Y" ] then - if [ "$SMTPUser" == "" ] + if [ "${SMTPUser}" == "" ] then echo "" echo "SMTPユーザー名を入力してください。" @@ -95,7 +95,7 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPPass" == "" ] + if [ "${SMTPPass}" == "" ] then echo "" echo "SMTPパスワードを入力してください。" @@ -116,7 +116,7 @@ case "$SMTPSET" in echo " G-Mail/Google Apps設定" echo "*******************************************************" - if [ "$SMTPUser" == "" ] + if [ "${SMTPUser}" == "" ] then echo "G-Mailのユーザー名を入力してください。" echo "" @@ -126,7 +126,7 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPPass" == "" ] + if [ "${SMTPPass}" == "" ] then echo "" echo "G-Mailのパスワードを入力してください。" @@ -148,7 +148,7 @@ case "$SMTPSET" in echo " Windows Live Hotmail設定" echo "*******************************************************" - if [ "$SMTPUser" == "" ] + if [ "${SMTPUser}" == "" ] then echo "HotmailのMicrosoftアカウントを入力してください。" echo "" @@ -158,7 +158,7 @@ case "$SMTPSET" in echo "" fi - if [ "$SMTPPass" == "" ] + if [ "${SMTPPass}" == "" ] then echo "" echo "Hotmailのパスワードを入力してください。" diff --git a/inst-script/config-logs b/inst-script/config-logs index 0de7fb8a..01dd9997 100755 --- a/inst-script/config-logs +++ b/inst-script/config-logs @@ -10,37 +10,37 @@ backup_and_new_logdir() { local group=$5 pushd $parent_dir - if [ -d $old_log_dir -a "`readlink -f $old_log_dir`" != "$ALM_LOG_DIR/$new_log_dir" ]; then - if [ "`ls $old_log_dir`" != "" ]; then - mkdir -p $old_log_dir.backup - tar cvfz $old_log_dir.backup/"`date +%F-%H-%M-%S`".tar.gz $old_log_dir - cp -p $old_log_dir/* $ALM_LOG_DIR/$new_log_dir/ + if [ -d ${old_log_dir} -a "`readlink -f ${old_log_dir}`" != "${ALM_LOG_DIR}/${new_log_dir}" ]; then + if [ "`ls ${old_log_dir}`" != "" ]; then + mkdir -p ${old_log_dir}.backup + tar cvfz ${old_log_dir}.backup/"`date +%F-%H-%M-%S`".tar.gz ${old_log_dir} + cp -p ${old_log_dir}/* ${ALM_LOG_DIR}/${new_log_dir}/ fi - rm -r $old_log_dir - ln -s $ALM_LOG_DIR/$new_log_dir $parent_dir/$old_log_dir + rm -r ${old_log_dir} + ln -s ${ALM_LOG_DIR}/${new_log_dir} ${parent_dir}/${old_log_dir} fi - chown -R $owner:$group $ALM_LOG_DIR/$new_log_dir + chown -R ${owner}:${group} ${ALM_LOG_DIR}/${new_log_dir} popd } # make log's directories -mkdir -p $ALM_LOG_DIR -mkdir -p $ALM_LOG_DIR/redmine -mkdir -p $ALM_LOG_DIR/$MYSQL_LOG_DIR -mkdir -p $ALM_LOG_DIR/$APACHE_LOG_DIR -mkdir -p $ALM_LOG_DIR/jenkins +mkdir -p ${ALM_LOG_DIR} +mkdir -p ${ALM_LOG_DIR}/redmine +mkdir -p ${ALM_LOG_DIR}/${MYSQL_LOG_DIR} +mkdir -p ${ALM_LOG_DIR}/${APACHE_LOG_DIR} +mkdir -p ${ALM_LOG_DIR}/jenkins # # each log's configuration # -backup_and_new_logdir "$ALM_INSTALL_DIR" "log" "redmine" "$APACHE_USER" "$APACHE_USER" -backup_and_new_logdir "/var/log" "$MYSQL_LOG_DIR" "$MYSQL_LOG_DIR" "mysql" "adm" -backup_and_new_logdir "/var/log" "$APACHE_LOG_DIR" "$APACHE_LOG_DIR" "root" "root" -if [ "$ALM_ENABLE_JENKINS" = "y" ]; then +backup_and_new_logdir "${ALM_INSTALL_DIR}" "log" "redmine" "${APACHE_USER}" "${APACHE_USER}" +backup_and_new_logdir "/var/log" "${MYSQL_LOG_DIR}" "${MYSQL_LOG_DIR}" "mysql" "adm" +backup_and_new_logdir "/var/log" "${APACHE_LOG_DIR}" "${APACHE_LOG_DIR}" "root" "root" +if [ "${ALM_ENABLE_JENKINS}" = "y" ]; then backup_and_new_logdir "/var/log" "jenkins" "jenkins" "jenkins" "jenkins" fi # ubuntu1604 apparmor setting -if [ "$OS" = "ubuntu1604" ]; then +if [ "${OS}" = "ubuntu1604" ]; then sed -i "s|/var/log/mysql/|/var/log/alminium/mysql/|" /etc/apparmor.d/usr.sbin.mysqld fi diff --git a/inst-script/debian/post-install b/inst-script/debian/post-install index d7a280d5..5f26bb1e 100755 --- a/inst-script/debian/post-install +++ b/inst-script/debian/post-install @@ -3,10 +3,10 @@ # set Redmine.pm mkdir -p /etc/perl/Apache/Authn rm -f /etc/perl/Apache/Authn/Redmine.pm -ln -s $ALM_INSTALL_DIR/extra/svn/Redmine.pm /etc/perl/Apache/Authn/Redmine.pm +ln -s ${ALM_INSTALL_DIR}/extra/svn/Redmine.pm /etc/perl/Apache/Authn/Redmine.pm # set Apache configs -ln -sf "$ALM_ETC_DIR/alminium.conf" "/etc/apache2/sites-available/alminium.conf" +ln -sf "${ALM_ETC_DIR}/alminium.conf" "/etc/apache2/sites-available/alminium.conf" a2enmod expires a2enmod dav_fs diff --git a/inst-script/debian/pre-install b/inst-script/debian/pre-install index 7c5258c6..61960f2d 100755 --- a/inst-script/debian/pre-install +++ b/inst-script/debian/pre-install @@ -25,18 +25,18 @@ apt-get install -y --force-yes software-properties-common add-apt-repository -y ppa:brightbox/ruby-ng # install APT packages -if [ "$GIT_UPDATE" = "y" ]; then +if [ "${GIT_UPDATE}" = "y" ]; then add-apt-repository -y ppa:git-core/ppa fi apt-get -qq update -apt-get -y install `grep -v "^#" inst-script/$OS/packages.lst` +apt-get -y install `grep -v "^#" inst-script/${OS}/packages.lst` # switch to ruby2.1 ruby-switch --set ruby2.1 REALLY_GEM_UPDATE_SYSTEM=1 gem update --system # SSL -if [ "$ALM_ENABLE_SSL" = "y" ]; then +if [ "${ALM_ENABLE_SSL}" = "y" ]; then apt-get -y install ssl-cert a2enmod ssl rewrite else diff --git a/inst-script/functions b/inst-script/functions index 22db319d..a49d90ce 100644 --- a/inst-script/functions +++ b/inst-script/functions @@ -1,6 +1,5 @@ - -# DB操作コマンドオプション -db_option() { +# DB操作コマンドオプション(for root) +db_option_root() { local db_host=${ALM_DB_HOST:-localhost} local root_pass=${ALM_DB_ROOT_PASS} @@ -11,6 +10,12 @@ db_option() { fi } +# DB操作コマンドオプション(for alminium) +db_option() { + local db_host=${ALM_DB_HOST:-localhost} + echo "-ualminium -h${db_host} -palminium" +} + # DBのsettingsテーブルのレコード有無チェック db_exist_record() { echo "SELECT * FROM settings WHERE name = '$1';" | mysql `db_option` alminium @@ -30,7 +35,7 @@ db_update_setting() { # データベース接続テスト # 戻り値が非nullなら接続成功 db_test() { - DBCMD="mysql `db_option`" + DBCMD="mysql `db_option_root`" echo `${DBCMD} -e "select user from user;" mysql 2>/dev/null` } diff --git a/inst-script/gems b/inst-script/gems index 9c420d83..ca9cf70a 100755 --- a/inst-script/gems +++ b/inst-script/gems @@ -3,7 +3,7 @@ GEM=`which gem2.0` -if [ "$GEM" = "" ] +if [ "${GEM}" = "" ] then GEM=gem fi @@ -16,10 +16,10 @@ for (( i = 0; i < ${#NAME[@]}; ++i )) do NAME=${NAME[$i]} VER=${VER[$i]} - if [ "$VER" = "-" ] + if [ "${VER}" = "-" ] then - $GEM install -f $NAME --no-rdoc --no-ri + ${GEM} install -f ${NAME} --no-rdoc --no-ri else - $GEM install -f $NAME -v=$VER --no-rdoc --no-ri + ${GEM} install -f ${NAME} -v=${VER} --no-rdoc --no-ri fi done diff --git a/inst-script/gen-email-config.sh b/inst-script/gen-email-config.sh index 2b45257e..df886ca1 100755 --- a/inst-script/gen-email-config.sh +++ b/inst-script/gen-email-config.sh @@ -1,10 +1,10 @@ #!/bin/bash -case "$SMTPSET" in +case "${SMTPSET}" in "1" ) echo "default: email_delivery: - delivery_method: :sendmail" > $ALM_INSTALL_DIR/config/configuration.yml + delivery_method: :sendmail" > ${ALM_INSTALL_DIR}/config/configuration.yml ;; "0" | "2" | "3" ) @@ -12,20 +12,20 @@ case "$SMTPSET" in email_delivery: delivery_method: :smtp smtp_settings: - address: $SMTPSERVER - port: $SMTPPORT - domain: $ALM_HOSTNAME" > $ALM_INSTALL_DIR/config/configuration.yml + address: ${SMTPSERVER} + port: ${SMTPPORT} + domain: ${ALM_HOSTNAME}" > ${ALM_INSTALL_DIR}/config/configuration.yml - if [ "$SMTPTLS" == "Y" ] + if [ "${SMTPTLS}" == "Y" ] then - echo " enable_starttls_auto: true" >> $ALM_INSTALL_DIR/config/configuration.yml + echo " enable_starttls_auto: true" >> ${ALM_INSTALL_DIR}/config/configuration.yml fi - if [ "$SMTPLOGIN" == "Y" ] + if [ "${SMTPLOGIN}" == "Y" ] then echo " authentication: :login - user_name: $SMTPUser - password: $SMTPPass" >> $ALM_INSTALL_DIR/config/configuration.yml + user_name: ${SMTPUser} + password: ${SMTPPass}" >> ${ALM_INSTALL_DIR}/config/configuration.yml fi ;; diff --git a/inst-script/git_build_install b/inst-script/git_build_install index cd9d3550..98d5bdad 100755 --- a/inst-script/git_build_install +++ b/inst-script/git_build_install @@ -1,10 +1,10 @@ #!/bin/bash # gitのソースコードをダウンロードしインストールする -pushd $ALM_SRC_DIR/cache -wget https://www.kernel.org/pub/software/scm/git/git-$ALM_GIT_VERSION.tar.gz -tar xzvf git-$ALM_GIT_VERSION.tar.gz -cd git-$ALM_GIT_VERSION +pushd ${ALM_SRC_DIR}/cache +wget https://www.kernel.org/pub/software/scm/git/git-${ALM_GIT_VERSION}.tar.gz +tar xzvf git-${ALM_GIT_VERSION}.tar.gz +cd git-${ALM_GIT_VERSION} make prefix=/usr all make prefix=/usr install echo git has been updated to `git --version | cut -c 5-` diff --git a/inst-script/install-jenkins b/inst-script/install-jenkins index 297a430c..8dfebc54 100755 --- a/inst-script/install-jenkins +++ b/inst-script/install-jenkins @@ -5,8 +5,8 @@ echo "*** install Jenkins ***" if [ "${OS}" = "ubuntu1604" ]; then JENKINS_SYS=debian else - JENKINS_SYS=$OS + JENKINS_SYS=${OS} fi -source jenkins/setup/$OS/install.sh +source jenkins/setup/${OS}/install.sh source jenkins/setup/config.sh diff --git a/inst-script/install-redmine b/inst-script/install-redmine index 44b2ba00..19911f5f 100755 --- a/inst-script/install-redmine +++ b/inst-script/install-redmine @@ -91,6 +91,10 @@ setup_db() { ## sctips ## + +# create ALMinium DB +source redmine/setup/create-db + echo "*** install Redmine ***" # download and put alminium's home dir diff --git a/inst-script/post-install b/inst-script/post-install index 15dc3b94..5e466ddf 100755 --- a/inst-script/post-install +++ b/inst-script/post-install @@ -1,34 +1,34 @@ #!/bin/bash # Apache configs -if [ "$ALM_ENABLE_SSL" = "y" ]; then REPLACE_SSL="#SSL# *"; fi -if [ "$ALM_ENABLE_JENKINS" = "y" ]; then REPLACE_JENKINS="#JENKINS# *"; fi -if [ "$ALM_SUBDIR" = "" ]; then +if [ "${ALM_ENABLE_SSL}" = "y" ]; then REPLACE_SSL="#SSL# *"; fi +if [ "${ALM_ENABLE_JENKINS}" = "y" ]; then REPLACE_JENKINS="#JENKINS# *"; fi +if [ "${ALM_SUBDIR}" = "" ]; then DOCMENT_ROOT="/opt/alminium/public" else - DOCMENT_ROOT="/var/www/html\nRailsBaseURI $ALM_SUBDIR" + DOCMENT_ROOT="/var/www/html\nRailsBaseURI ${ALM_SUBDIR}" fi -OS_TYPE=$OS -if [ "`echo $OS_TYPE | grep ubuntu`" != "" ]; then OS_TYPE=debian -elif [ "`echo $OS_TYPE | grep rhel`" != "" ]; then OS_TYPE=rhel; fi +OS_TYPE=${OS} +if [ "`echo ${OS_TYPE} | grep ubuntu`" != "" ]; then OS_TYPE=debian +elif [ "`echo ${OS_TYPE} | grep rhel`" != "" ]; then OS_TYPE=rhel; fi for FILE in $(ls etc/ | grep '.conf$') do - sed -e "s|#HOSTNAME#|$ALM_HOSTNAME|" \ - -e "s|#$OS_TYPE# *||" \ - -e "s|$REPLACE_SSL||" \ - -e "s|$REPLACE_JENKINS||" \ - -e "s|#SUBDIR#|$ALM_SUBDIR|" \ - -e "s|#DOCUMENTROOT#|$DOCMENT_ROOT|" \ - -e "s|#DB_HOST#|$ALM_DB_HOST|" \ - "etc/$FILE" > "$ALM_ETC_DIR/$FILE" + sed -e "s|#HOSTNAME#|${ALM_HOSTNAME}|" \ + -e "s|#${OS_TYPE}# *||" \ + -e "s|${REPLACE_SSL}||" \ + -e "s|${REPLACE_JENKINS}||" \ + -e "s|#SUBDIR#|${ALM_SUBDIR}|" \ + -e "s|#DOCUMENTROOT#|${DOCMENT_ROOT}|" \ + -e "s|#DB_HOST#|${ALM_DB_HOST}|" \ + "etc/${FILE}" > "${ALM_ETC_DIR}/${FILE}" done # log rotate -cp $ALM_ETC_DIR/alminium-logrotate /etc/logrotate.d/alminium +cp ${ALM_ETC_DIR}/alminium-logrotate /etc/logrotate.d/alminium # OS depend installing -source inst-script/$OS/post-install +source inst-script/${OS}/post-install # restart service source inst-script/service-restart diff --git a/inst-script/pre-install b/inst-script/pre-install index d5b9cff1..722635fa 100755 --- a/inst-script/pre-install +++ b/inst-script/pre-install @@ -2,8 +2,8 @@ # install packages if [ ! -f packages.installed ]; then - echo "*** run $OS's pre-install script ***" - source inst-script/$OS/pre-install + echo "*** run ${OS}'s pre-install script ***" + source inst-script/${OS}/pre-install touch packages.installed fi diff --git a/inst-script/rhel6/post-install b/inst-script/rhel6/post-install old mode 100644 new mode 100755 index 0c23875e..11f48aed --- a/inst-script/rhel6/post-install +++ b/inst-script/rhel6/post-install @@ -4,42 +4,42 @@ if [ ! -f /etc/httpd/Apache/Authn/Redmine.pm ]; then mkdir -p /etc/httpd/Apache/Authn rm /etc/httpd/Apache/Authn/Redmine.pm - ln -s $ALM_INSTALL_DIR/extra/svn/Redmine.pm /etc/httpd/Apache/Authn/Redmine.pm + ln -s ${ALM_INSTALL_DIR}/extra/svn/Redmine.pm /etc/httpd/Apache/Authn/Redmine.pm fi # # set Apache # # mod_passenger -pushd $ALM_INSTALL_DIR -bundle exec passenger-install-apache2-module --snippet > $ALM_ETC_DIR/passenger.conf +pushd ${ALM_INSTALL_DIR} +bundle exec passenger-install-apache2-module --snippet > ${ALM_ETC_DIR}/passenger.conf bundle exec passenger-install-apache2-module --auto popd -ln -sf "$ALM_ETC_DIR/passenger.conf" "$APACHE_CONF_DIR/" +ln -sf "${ALM_ETC_DIR}/passenger.conf" "${APACHE_CONF_DIR}/" #set alminium config -ln -sf "$ALM_ETC_DIR/alminium.conf" "$APACHE_CONF_DIR/" +ln -sf "${ALM_ETC_DIR}/alminium.conf" "${APACHE_CONF_DIR}/" # セキュリティ無効化の設定 -if [ ! "$USE_DISABLE_SECURITY" = "n" ]; then +if [ ! "${USE_DISABLE_SECURITY}" = "n" ]; then # SELinuxを無効化 echo 0 > /selinux/enforce CHK=`grep SELINUX=enforcing /etc/selinux/config` - if [ ! "$CHK" = '' ]; then + if [ ! "${CHK}" = '' ]; then sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config echo "SELinuxが無効化されました" fi # ファイアウォールの設定で80番(http)を許可 CHK=`grep "dport 80" /etc/sysconfig/iptables` - if [ "$CHK" = '' ]; then + if [ "${CHK}" = '' ]; then RULENUM=`iptables-save |grep INPUT |grep -n "dport 22"|awk -F : '{print $1}'` iptables -I INPUT ${RULENUM} -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables-save > /etc/sysconfig/iptables echo "tcp 80番ポートのアクセスを許可しました" fi CHK=`grep "dport 443" /etc/sysconfig/iptables` - if [ "$CHK" = '' ]; then + if [ "${CHK}" = '' ]; then RULENUM=`iptables-save |grep INPUT |grep -n "dport 22"|awk -F : '{print $1}'` iptables -I INPUT ${RULENUM} -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables-save > /etc/sysconfig/iptables diff --git a/inst-script/rhel6/pre-install b/inst-script/rhel6/pre-install old mode 100644 new mode 100755 index 42f8d615..a61150d1 --- a/inst-script/rhel6/pre-install +++ b/inst-script/rhel6/pre-install @@ -1,6 +1,6 @@ #!/bin/bash -if [ "$USE_DISABLE_SECURITY" = "" ]; then +if [ "${USE_DISABLE_SECURITY}" = "" ]; then echo "*******************************************************" echo " セキュリティの設定" echo "*******************************************************" @@ -13,7 +13,7 @@ fi yum update -y ca-certificates if [ -f /etc/yum.repos.d/epel.repo ]; then CHK=`grep "enabled=1" /etc/yum.repos.d/epel.repo` - if [ "$CHK" = "" ]; then + if [ "${CHK}" = "" ]; then sed '1,/enabled=0/s/enabled=0/enabled=1/' /etc/yum.repos.d/epel.repo >/tmp/epel.repo mv -f /tmp/epel.repo /etc/yum.repos.d/epel.repo fi @@ -25,12 +25,12 @@ fi yum -y --nogpgcheck install `grep -v "^#" inst-script/$OS/packages.lst` CHK=`grep Amazon /etc/system-release` -if [ "$CHK" != '' ]; then +if [ "${CHK}" != '' ]; then rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm yum --enablerepo=remi -y --nogpgcheck install mysqlclient16 fi -if [ "$ALM_ENABLE_SSL" = "y" ]; then +if [ "${ALM_ENABLE_SSL}" = "y" ]; then yum -y install mod_ssl fi @@ -51,6 +51,6 @@ if [[ `which ruby` == "" || ! `ruby --version` =~ 2.1. ]]; then fi # git update -if [ "$GIT_UPDATE" = "y" ]; then +if [ "${GIT_UPDATE}" = "y" ]; then source inst-script/git_build_install fi diff --git a/inst-script/rhel6/ruby2.1-install b/inst-script/rhel6/ruby2.1-install old mode 100644 new mode 100755 index 918414ee..c99502e4 --- a/inst-script/rhel6/ruby2.1-install +++ b/inst-script/rhel6/ruby2.1-install @@ -4,7 +4,7 @@ CHKRUBY=`rpm -qa|grep ^ruby-2.1` RET=-1 -if [ "$CHKRUBY" = "" ] +if [ "${CHKRUBY}" = "" ] then pushd . @@ -14,7 +14,7 @@ then # wget's bug, certificate Server Common Name curl -k -L -O https://raw.github.com/hansode/ruby-2.1.x-rpm/master/ruby21x.spec RET=$? - if [ "$RET" -ne "0" ] + if [ "${RET}" -ne "0" ] then echo "download error. 'ruby21x.spec'" exit 1 diff --git a/inst-script/rhel6/service-restart b/inst-script/rhel6/service-restart old mode 100644 new mode 100755 diff --git a/inst-script/rhel7/post-install b/inst-script/rhel7/post-install old mode 100644 new mode 100755 index 37872b54..7f492f13 --- a/inst-script/rhel7/post-install +++ b/inst-script/rhel7/post-install @@ -3,7 +3,7 @@ # Redmine Perlモジュール(リポジトリ認証連携)設定 mkdir -p /etc/httpd/Apache/Authn rm -f /etc/httpd/Apache/Authn/Redmine.pm -ln -s $ALM_INSTALL_DIR/extra/svn/Redmine.pm /etc/httpd/Apache/Authn/Redmine.pm +ln -s ${ALM_INSTALL_DIR}/extra/svn/Redmine.pm /etc/httpd/Apache/Authn/Redmine.pm # # Apache configs @@ -11,14 +11,14 @@ ln -s $ALM_INSTALL_DIR/extra/svn/Redmine.pm /etc/httpd/Apache/Authn/Redmine.pm # passenger check passenger-config validate-install --auto --validate-apache2 #set alminium config -ln -sf "$ALM_ETC_DIR/alminium.conf" "$APACHE_CONF_DIR/" +ln -sf "${ALM_ETC_DIR}/alminium.conf" "${APACHE_CONF_DIR}/" # セキュリティ無効化の設定 -if [ ! "$USE_DISABLE_SECURITY" = "n" ]; then +if [ ! "${USE_DISABLE_SECURITY}" = "n" ]; then echo "SELinuxを無効化します" setenforce 0 CHK=`grep SELINUX=enforcing /etc/selinux/config` - if [ ! "$CHK" = '' ]; then + if [ ! "${CHK}" = '' ]; then sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config echo "SELinuxが無効化されました" fi @@ -31,7 +31,7 @@ fi # MariaDB設定 CHK=`grep "character-set-server=utf8" /etc/my.cnf` -if [ "$CHK" = "" ]; then +if [ "${CHK}" = "" ]; then mv /etc/my.cnf /etc/my.cnf.org cat /etc/my.cnf.org | sed -e "s/\[mysqld_safe\]/character-set-server=utf8\n\n\[mysqld_safe\]/g" > /etc/my.cnf echo -e "\n[mysql]\ndefault-character-set=utf8\n" >> /etc/my.cnf diff --git a/inst-script/rhel7/pre-install b/inst-script/rhel7/pre-install old mode 100644 new mode 100755 index 99711563..8b784143 --- a/inst-script/rhel7/pre-install +++ b/inst-script/rhel7/pre-install @@ -1,6 +1,6 @@ #!/bin/bash -if [ "$USE_DISABLE_SECURITY" = "" ]; then +if [ "${USE_DISABLE_SECURITY}" = "" ]; then echo "*******************************************************" echo " セキュリティの設定" echo "*******************************************************" @@ -21,12 +21,12 @@ fi # 必要なパッケージをインストール yum install -y epel-release yum-utils curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo -yum install -y --nogpgcheck `grep -v "^#" inst-script/$OS/packages.lst` +yum install -y --nogpgcheck `grep -v "^#" inst-script/${OS}/packages.lst` # set passenger-package available ALM_PASSSENGER_PACKAGE_AVAILABLE=1 # install ssl module -if [ "$ALM_ENABLE_SSL" = "y" ]; then +if [ "${ALM_ENABLE_SSL}" = "y" ]; then yum -y install mod_ssl fi @@ -38,7 +38,7 @@ if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then fi # git update -if [ "$GIT_UPDATE" = "y" ]; then +if [ "${GIT_UPDATE}" = "y" ]; then source inst-script/git_build_install fi diff --git a/inst-script/rhel7/service-restart b/inst-script/rhel7/service-restart old mode 100644 new mode 100755 diff --git a/inst-script/select-db b/inst-script/select-db index 312d5133..bd3042bf 100755 --- a/inst-script/select-db +++ b/inst-script/select-db @@ -16,7 +16,7 @@ if [ "${ALM_DB_SETUP}" = "y" ]; then read ALM_USE_EXISTING_DB; if [ "${ALM_USE_EXISTING_DB}" = "y" ]; then # db client install - source inst-script/$OS/install_db_client + source inst-script/${OS}/install_db_client # DBへのアクセスが成功するまでループしながらチェック while [ "${DB_TEST}" = "" ]; do echo "" diff --git a/inst-script/service-restart b/inst-script/service-restart index 3ec7adab..cdd6d8e5 100755 --- a/inst-script/service-restart +++ b/inst-script/service-restart @@ -4,5 +4,5 @@ source ./inst-script/check-os # restart apache -source ./inst-script/$OS/service-restart +source ./inst-script/${OS}/service-restart diff --git a/inst-script/ubuntu1604/post-install b/inst-script/ubuntu1604/post-install index 17dbce73..f405d5de 100755 --- a/inst-script/ubuntu1604/post-install +++ b/inst-script/ubuntu1604/post-install @@ -3,10 +3,10 @@ # set Redmine.pm mkdir -p /etc/perl/Apache/Authn rm -f /etc/perl/Apache/Authn/Redmine.pm -ln -s $ALM_INSTALL_DIR/extra/svn/Redmine.pm /etc/perl/Apache/Authn/Redmine.pm +ln -s ${ALM_INSTALL_DIR}/extra/svn/Redmine.pm /etc/perl/Apache/Authn/Redmine.pm # set Apache configs -ln -sf "$ALM_ETC_DIR/alminium.conf" "/etc/apache2/sites-available/alminium.conf" +ln -sf "${ALM_ETC_DIR}/alminium.conf" "/etc/apache2/sites-available/alminium.conf" a2enmod expires a2enmod dav_fs diff --git a/inst-script/ubuntu1604/pre-install b/inst-script/ubuntu1604/pre-install index 51ac907f..823f148a 100755 --- a/inst-script/ubuntu1604/pre-install +++ b/inst-script/ubuntu1604/pre-install @@ -21,16 +21,16 @@ fi ALM_PASSSENGER_PACKAGE_AVAILABLE=1 # install APT packages -if [ "$GIT_UPDATE" = "y" ]; then +if [ "${GIT_UPDATE}" = "y" ]; then add-apt-repository -y ppa:git-core/ppa fi apt-get -qq update -apt-get -y install `grep -v "^#" inst-script/$OS/packages.lst` +apt-get -y install `grep -v "^#" inst-script/${OS}/packages.lst` REALLY_GEM_UPDATE_SYSTEM=1 gem update --system # SSL -if [ "$ALM_ENABLE_SSL" = "y" ]; then +if [ "${ALM_ENABLE_SSL}" = "y" ]; then apt-get -y install ssl-cert a2enmod ssl rewrite else diff --git a/redmine/setup/create-db b/redmine/setup/create-db new file mode 100755 index 00000000..ba5cfa5d --- /dev/null +++ b/redmine/setup/create-db @@ -0,0 +1,30 @@ +#!/bin/bash +# +# + +echo "*** create ALMinium DB ***" + +# ALMiniumインストールディレクトリへ移動 +pushd ${ALM_INSTALL_DIR} + +# create db +if [ "${ALM_UPGRADE}" != "y" ]; then + DB_OPTION="`db_option`" + EXIT_ALM_DB="`mysql ${DB_OPTION} -e \"status\" alminium`" + if [ "${EXIT_ALM_DB}" = "" ]; then + DB_OPTION_ROOT="`db_option_root`" +# ACCESS_MYSQL="`mysql ${DB_OPTION_ROOT} -e \"status\" mysql`" +# if [ "${ACCESS_MYSQL}" != "" ]; then + if [ "`db_test`" != "" ]; then + # create DB + mysql `db_option_root` < ${ALM_SRC_DIR}/redmine/setup/createdb.sql + else + echo "データベースを作成作成することが出来ません。データベースへのアクセス +権の設定を確認してください。" + exit 1 + fi + fi +fi + +popd + diff --git a/redmine/setup/install-plugins b/redmine/setup/install-plugins old mode 100644 new mode 100755 index 2b57b353..749ea1ff --- a/redmine/setup/install-plugins +++ b/redmine/setup/install-plugins @@ -16,25 +16,25 @@ for (( i = 0; i < ${#DIR_NAME[@]}; ++i )) do FILE_NAME=`echo ${URL_NAME[$i]} | sed -e "s/.*\/\(.*$\)/\1/"` EXT=`echo ${URL_NAME[$i]} | sed -e "s/.*\.\(.*$\)/\1/"` - case $EXT in + case ${EXT} in zip) - if [ ! -f cache/$FILE_NAME ]; then + if [ ! -f cache/${FILE_NAME} ]; then wget -P cache ${URL_NAME[$i]} fi - yes | unzip -q cache/$FILE_NAME - rm -fr $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} - mv ${DIR_NAME[$i]} $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} - rm -f $FILE_NAME + yes | unzip -q cache/${FILE_NAME} + rm -fr ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} + mv ${DIR_NAME[$i]} ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} + rm -f ${FILE_NAME} ;; tgz|gz) - if [ ! -f cache/$FILE_NAME ]; then + if [ ! -f cache/${FILE_NAME} ]; then wget -P cache ${URL_NAME[$i]} fi - tar zxf cache/$FILE_NAME - rm -fr $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} - mv ${DIR_NAME[$i]} $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} - rm -f $FILE_NAME + tar zxf cache/${FILE_NAME} + rm -fr ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} + mv ${DIR_NAME[$i]} ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} + rm -f ${FILE_NAME} ;; git) if [ ! -d cache/${DEST_NAME[$i]} ]; then @@ -44,8 +44,8 @@ do cd cache/${DEST_NAME[$i]} git checkout ${DIR_NAME[$i]} cd ../.. - rm -fr $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} - cp -fra cache/${DEST_NAME[$i]} $ALM_INSTALL_DIR/plugins/ + rm -fr ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} + cp -fra cache/${DEST_NAME[$i]} ${ALM_INSTALL_DIR}/plugins/ fi ;; *) @@ -64,14 +64,14 @@ do fi fi fi - rm -fr $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} - cp -fra cache/${DEST_NAME[$i]} $ALM_INSTALL_DIR/plugins/${DEST_NAME[$i]} + rm -fr ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} + cp -fra cache/${DEST_NAME[$i]} ${ALM_INSTALL_DIR}/plugins/${DEST_NAME[$i]} ;; esac done # ALMiniumインストールディレクトリへ移動 -pushd $ALM_INSTALL_DIR +pushd ${ALM_INSTALL_DIR} # for Hudson if [ -f plugins/redmine_hudson/Gemfile ]; then @@ -80,13 +80,13 @@ fi # for DMSF # avoid bandle install error because of rubyzip version conflict -if [ -f $ALM_INSTALL_DIR/plugins/redmine_dmsf/Gemfile ]; then - sed -i.org "s/gem 'rubyzip',/gem 'rubyzip'#,/" $ALM_INSTALL_DIR/plugins/redmine_dmsf/Gemfile +if [ -f ${ALM_INSTALL_DIR}/plugins/redmine_dmsf/Gemfile ]; then + sed -i.org "s/gem 'rubyzip',/gem 'rubyzip'#,/" ${ALM_INSTALL_DIR}/plugins/redmine_dmsf/Gemfile fi # for OAuth2認証 cd ./plugins -case $ALM_OAUTH2_METHOD in +case ${ALM_OAUTH2_METHOD} in google) git clone -b master https://github.com/twinslash/redmine_omniauth_google.git ;; diff --git a/redmine/setup/install-plugins-jenkins b/redmine/setup/install-plugins-jenkins old mode 100644 new mode 100755 index eaeb4bca..c75bb02e --- a/redmine/setup/install-plugins-jenkins +++ b/redmine/setup/install-plugins-jenkins @@ -18,7 +18,7 @@ git clone -b 0.2.4 https://github.com/jbox-web/redmine_bootstrap_kit.git # install redmine_jenkins git clone -b v1.x https://github.com/ayapapa/redmine_jenkins.git -if [ "$ALM_DB_SETUP" = "y" ]; then +if [ "${ALM_DB_SETUP}" = "y" ]; then # install gems and migrate database cd .. bundle install --path vendor/bundle \ diff --git a/redmine/setup/setup-db b/redmine/setup/setup-db old mode 100644 new mode 100755 index c12aed80..6fb93e06 --- a/redmine/setup/setup-db +++ b/redmine/setup/setup-db @@ -5,17 +5,9 @@ echo "*** run initialize DB ***" # ALMiniumインストールディレクトリへ移動 -pushd $ALM_INSTALL_DIR - -# create db -if [ "$ALM_UPGRADE" != "y" ]; then - # create DB -echo create DB ... - mysql `db_option` < ${ALM_SRC_DIR}/redmine/setup/createdb.sql -fi +pushd ${ALM_INSTALL_DIR} # データベースにテーブルを作成 -echo "bundle exec rake db:migrate RAILS_ENV=production" bundle exec rake db:migrate RAILS_ENV=production # データベースにデフォルトデータを登録 @@ -32,7 +24,7 @@ fi # for backlogs if [ -d plugins/redmine_backlogs ]; then - if [ "$ALM_UPGRADE" = "y" ]; then + if [ "${ALM_UPGRADE}" = "y" ]; then bundle exec rake redmine:backlogs:install task_tracker=タスク story_trackers=機能 labels=false RAILS_ENV=production else bundle exec rake redmine:backlogs:install task_tracker=サポート story_trackers=機能 labels=false RAILS_ENV=production @@ -44,7 +36,7 @@ bundle exec rake tmp:cache:clear RAILS_ENV=production bundle exec rake tmp:sessions:clear RAILS_ENV=production # Customize -if [ "$ALM_UPGRADE" != "y" ]; then +if [ "${ALM_UPGRADE}" != "y" ]; then echo "*** run initialize SQL ***" mysql `db_option` alminium < ${ALM_SRC_DIR}/redmine/setup/init.mysql fi @@ -52,7 +44,7 @@ fi # config settings # protocol protocol() { - if [ "$ALM_ENABLE_SSL" = "y" ]; then + if [ "${ALM_ENABLE_SSL}" = "y" ]; then echo "https" else echo "http" diff --git a/uninstall b/uninstall index 1be8bd80..cabfc1fc 100755 --- a/uninstall +++ b/uninstall @@ -30,7 +30,7 @@ echo "" echo -n "データベース(全てのRedmineの情報)とリポジトリを削除しますか?(y/N)" read YN if [ "$YN" = "y" ]; then - DBCMD="mysql `db_option`" + DBCMD="mysql `db_option_root`" ${DBCMD} alminium -e "REVOKE ALL ON alminium.* FROM alminium@%" \ 2>/dev/null ${DBCMD} alminium -e "REVOKE ALL ON alminium.* FROM alminium@localhost" \ diff --git a/upgrade b/upgrade index 33310f2f..937eb2ee 100755 --- a/upgrade +++ b/upgrade @@ -1,7 +1,9 @@ #!/bin/bash ############################################################ # upgrader for ALMinium. -# 第1引数:バックアップディレクトリ(defaultは/var/opt/alminium-backup) +# 第1引数:バックアップディレクトリ +# defaultは/var/opt/alminium-backup +# "-"を指定したときはdeaultディレクトリを利用 # 第2引数:データベースホスト名 # 第3引数:データベース管理者パスワード ############################################################ @@ -10,6 +12,7 @@ ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} ALM_VAR_DIR=/var/opt/alminium ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} +ALM_BACKUP_DIR=$1 ALM_DB_HOST=${2:-${ALM_DB_HOST}} ALM_DB_HOST=${ALM_DB_HOST:-localhost} ALM_DB_ROOT_PASS=${3:-${ALM_DB_ROOT_PASS}} @@ -41,7 +44,7 @@ echo "#####################################################################" read DO_CONTINUE # バックアップ実行 -source backup $1 $2 $3 +source backup ${ALM_BACKUP_DIR} ${ALM_DB_HOST} ${ALM_DB_ROOT_PASS} if [ $? -gt 0 ]; then echo "バックアップに失敗したため、処理を中止します" exit 1 @@ -86,7 +89,7 @@ rm -fr ${ALM_ETC_DIR}/passenger.* # install ALMinium by smelt ALM_UPGRADE=y -source ./smelt +source ./smelt ${ALM_DB_HOST} ${ALM_DB_ROOT_PASS} #バックアップの復元 ALM_DB_RESTORE=no From 38d0456bc3f6fecd5424fd8cf6f64bd48c354de9 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 28 Jan 2017 21:32:42 +0900 Subject: [PATCH 17/34] update scripts for #93 --- inst-script/rhel6/pre-install | 2 +- restore | 2 +- smelt | 6 ------ upgrade | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/inst-script/rhel6/pre-install b/inst-script/rhel6/pre-install index a61150d1..1f431266 100755 --- a/inst-script/rhel6/pre-install +++ b/inst-script/rhel6/pre-install @@ -19,7 +19,7 @@ if [ -f /etc/yum.repos.d/epel.repo ]; then fi else yum -y --nogpgcheck install wget - EPEL_RPM_NAME=`wget -O /dev/stdout http://download.fedoraproject.org/pub/epel/6/x86_64/repoview/epel-release.html | grep -o 'epel-release-[0-9]*-[0-9]*.noarch.rpm'` + EPEL_RPM_NAME="epel-release-6-8.noarch.rpm" rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/${EPEL_RPM_NAME} fi yum -y --nogpgcheck install `grep -v "^#" inst-script/$OS/packages.lst` diff --git a/restore b/restore index 09225852..4c5939b3 100755 --- a/restore +++ b/restore @@ -52,7 +52,7 @@ echo "***Redmine添付ファイルを復元しています..." cd ${ALM_INSTALL_DIR}/files/ && tar xzf ${ALM_FILE_BACKUP} if [ "${ALM_DB_RESTORE}" != "no" ]; then echo "***データベースを復元しています..." - mysql `db_option` alminium < ${ALM_DBBACKUP_NAME} + mysql `db_option_root` alminium < ${ALM_DBBACKUP_NAME} echo "データ復元が完了しました。" #データベースのマイグレーション echo "データベースのマイグレーションを実施します。" diff --git a/smelt b/smelt index f47009e9..9d8b7e03 100755 --- a/smelt +++ b/smelt @@ -27,12 +27,6 @@ RM_ARC=https://github.com/redmine/redmine/archive/${RM_VER}.tar.gz PATH=/usr/local/bin:${PATH} -if [ "$1" = "-u" ]; then - ALM_UPGRADE=y -else - ALM_UPGRADE="" -fi - # include functions source inst-script/functions diff --git a/upgrade b/upgrade index 937eb2ee..f5c7dc8c 100755 --- a/upgrade +++ b/upgrade @@ -93,7 +93,7 @@ source ./smelt ${ALM_DB_HOST} ${ALM_DB_ROOT_PASS} #バックアップの復元 ALM_DB_RESTORE=no -source ./restore ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME} $2 $3 +source ./restore ${ALM_BACKUP_DIR}/${ALM_BACKUP_NAME} ${ALM_DB_HOST} ${ALM_DB_ROOT_PASS} # log復元 restore_log() { From 106900cac6fcba230d20d77d60da6d59ee458b2e Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 28 Jan 2017 23:29:10 +0900 Subject: [PATCH 18/34] update scripts for #93 --- redmine/setup/create-db | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/redmine/setup/create-db b/redmine/setup/create-db index ba5cfa5d..e097fe80 100755 --- a/redmine/setup/create-db +++ b/redmine/setup/create-db @@ -10,11 +10,9 @@ pushd ${ALM_INSTALL_DIR} # create db if [ "${ALM_UPGRADE}" != "y" ]; then DB_OPTION="`db_option`" - EXIT_ALM_DB="`mysql ${DB_OPTION} -e \"status\" alminium`" + EXIT_ALM_DB="`mysql ${DB_OPTION} -e \"status\" alminium 2>/dev/null`" if [ "${EXIT_ALM_DB}" = "" ]; then DB_OPTION_ROOT="`db_option_root`" -# ACCESS_MYSQL="`mysql ${DB_OPTION_ROOT} -e \"status\" mysql`" -# if [ "${ACCESS_MYSQL}" != "" ]; then if [ "`db_test`" != "" ]; then # create DB mysql `db_option_root` < ${ALM_SRC_DIR}/redmine/setup/createdb.sql From 62d54ef980e7b4be4f0e672f755fbc206ac7e25d Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 29 Jan 2017 10:51:54 +0900 Subject: [PATCH 19/34] upgrade ruby2.1 on ContOS7(#94) --- inst-script/rhel6/pre-install | 2 +- inst-script/rhel7/packages.lst | 16 ++++++++-------- inst-script/rhel7/post-install | 10 +++++++++- inst-script/rhel7/pre-install | 19 ++++++++++++++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/inst-script/rhel6/pre-install b/inst-script/rhel6/pre-install index 1f431266..933a3195 100755 --- a/inst-script/rhel6/pre-install +++ b/inst-script/rhel6/pre-install @@ -46,7 +46,7 @@ if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then fi # ruby -if [[ `which ruby` == "" || ! `ruby --version` =~ 2.1. ]]; then +if [[ `which ruby` == "" || ! `ruby --version` =~ 2\.1\. ]]; then rpm -Uvh "https://github.com/hansode/ruby-rpm/blob/master/6/x86_64/ruby-2.1.2-2.el6.x86_64.rpm?raw=true" fi diff --git a/inst-script/rhel7/packages.lst b/inst-script/rhel7/packages.lst index bc2e8af0..fec95e78 100644 --- a/inst-script/rhel7/packages.lst +++ b/inst-script/rhel7/packages.lst @@ -24,12 +24,12 @@ mariadb mariadb-devel mercurial mod_dav_svn -mod_passenger +#mod_passenger mod_perl mod_wsgi ncurses-devel openssl-devel -passenger +#passenger patch perl-Digest-SHA perl-ExtUtils-MakeMaker @@ -38,12 +38,12 @@ python-docutils readline-devel rpm-build rpmdevtools -ruby -ruby-devel -rubygem-nokogiri -rubygem-rack -rubygem-rake -rubygem-rake-compiler +#ruby +#ruby-devel +#rubygem-nokogiri +#rubygem-rack +#rubygem-rake +#rubygem-rake-compiler sqlite-devel subversion sudo diff --git a/inst-script/rhel7/post-install b/inst-script/rhel7/post-install index 7f492f13..399f5a83 100755 --- a/inst-script/rhel7/post-install +++ b/inst-script/rhel7/post-install @@ -9,7 +9,15 @@ ln -s ${ALM_INSTALL_DIR}/extra/svn/Redmine.pm /etc/httpd/Apache/Authn/Redmine.pm # Apache configs # # passenger check -passenger-config validate-install --auto --validate-apache2 +# nokogiri 1.7に対応するためruby2.1を個別インストールするように変更(#94対応)。 +# このためpassengerも個別インストールに戻す(ContOS6と同様) +#passenger-config validate-install --auto --validate-apache2 +pushd ${ALM_INSTALL_DIR} +bundle exec passenger-install-apache2-module --snippet > ${ALM_ETC_DIR}/passenger.conf +bundle exec passenger-install-apache2-module --auto +popd +ln -sf "${ALM_ETC_DIR}/passenger.conf" "${APACHE_CONF_DIR}/" + #set alminium config ln -sf "${ALM_ETC_DIR}/alminium.conf" "${APACHE_CONF_DIR}/" diff --git a/inst-script/rhel7/pre-install b/inst-script/rhel7/pre-install index 8b784143..c6e7918c 100755 --- a/inst-script/rhel7/pre-install +++ b/inst-script/rhel7/pre-install @@ -20,11 +20,15 @@ fi # 必要なパッケージをインストール yum install -y epel-release yum-utils -curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo +#curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo +rm -f /etc/yum.repos.d/passenger.repo yum install -y --nogpgcheck `grep -v "^#" inst-script/${OS}/packages.lst` -# set passenger-package available -ALM_PASSSENGER_PACKAGE_AVAILABLE=1 +# set passenger-package available +# nokogiri 1.7に対応するためruby2.1を個別インストールするように変更(#94対応)。 +# このためpassengerも個別インストールに戻す(ContOS6と同様) +#ALM_PASSSENGER_PACKAGE_AVAILABLE=1 + # install ssl module if [ "${ALM_ENABLE_SSL}" = "y" ]; then yum -y install mod_ssl @@ -37,6 +41,15 @@ if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then systemctl enable mariadb fi +# ruby +# nokogiri 1.7に対応するためruby2.1を個別インストールするように変更。 +if [[ `which ruby` == "" || ! `ruby --version` =~ 2\.1\. ]]; then + # remove old packages + yum remove ruby ruby-devel rubygem-nokogiri rubygem-rack \ + rubygem-rake rubygem-rake-compiler passenger mod_passenger + inst-script/${OS}/ruby2.1-install +fi + # git update if [ "${GIT_UPDATE}" = "y" ]; then source inst-script/git_build_install From 63707ff6ff4c98ace7017350513284f14d308909 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 29 Jan 2017 14:31:23 +0900 Subject: [PATCH 20/34] update for #94 --- inst-script/rhel7/pre-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst-script/rhel7/pre-install b/inst-script/rhel7/pre-install index c6e7918c..b120a433 100755 --- a/inst-script/rhel7/pre-install +++ b/inst-script/rhel7/pre-install @@ -45,7 +45,7 @@ fi # nokogiri 1.7に対応するためruby2.1を個別インストールするように変更。 if [[ `which ruby` == "" || ! `ruby --version` =~ 2\.1\. ]]; then # remove old packages - yum remove ruby ruby-devel rubygem-nokogiri rubygem-rack \ + yum remove -y ruby ruby-devel rubygem-nokogiri rubygem-rack \ rubygem-rake rubygem-rake-compiler passenger mod_passenger inst-script/${OS}/ruby2.1-install fi From e206dea5b56d9766e2555ec511878fe6c9417872 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 30 Jan 2017 20:54:13 +0900 Subject: [PATCH 21/34] v3.3.2(#95) --- RM_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RM_VERSION b/RM_VERSION index bea438e9..47725433 100644 --- a/RM_VERSION +++ b/RM_VERSION @@ -1 +1 @@ -3.3.1 +3.3.2 From 88ee3575c002713bfef93f2c4aa48f8af446acbd Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 30 Jan 2017 21:45:40 +0900 Subject: [PATCH 22/34] update scripts for #93 --- inst-script/install-redmine | 11 +++++++++-- redmine/setup/create-db | 6 ------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/inst-script/install-redmine b/inst-script/install-redmine index 19911f5f..a88a1703 100755 --- a/inst-script/install-redmine +++ b/inst-script/install-redmine @@ -82,6 +82,13 @@ create_redmine_token() { popd } +# create DB +create_db() { + if [ "${ALM_DB_SETUP}" = "y" ]; then + source redmine/setup/create-db + fi +} + # setup DB setup_db() { if [ "${ALM_DB_SETUP}" = "y" ]; then @@ -90,10 +97,10 @@ setup_db() { } ## sctips ## - +echo "*** install Redmine ***" # create ALMinium DB -source redmine/setup/create-db +create-db echo "*** install Redmine ***" diff --git a/redmine/setup/create-db b/redmine/setup/create-db index e097fe80..2de8dad8 100755 --- a/redmine/setup/create-db +++ b/redmine/setup/create-db @@ -4,9 +4,6 @@ echo "*** create ALMinium DB ***" -# ALMiniumインストールディレクトリへ移動 -pushd ${ALM_INSTALL_DIR} - # create db if [ "${ALM_UPGRADE}" != "y" ]; then DB_OPTION="`db_option`" @@ -23,6 +20,3 @@ if [ "${ALM_UPGRADE}" != "y" ]; then fi fi fi - -popd - From 28f94d156d643c95a6231011bfbf4540c12faf08 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 30 Jan 2017 22:00:36 +0900 Subject: [PATCH 23/34] update scripts for #93 --- inst-script/install-redmine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst-script/install-redmine b/inst-script/install-redmine index a88a1703..2316ea60 100755 --- a/inst-script/install-redmine +++ b/inst-script/install-redmine @@ -100,7 +100,7 @@ setup_db() { echo "*** install Redmine ***" # create ALMinium DB -create-db +create_db echo "*** install Redmine ***" From 553d69da686fbe1d424695d2c735361855dd643c Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 4 Feb 2017 13:11:22 +0900 Subject: [PATCH 24/34] update scripts for #93 --- inst-script/functions | 5 +++++ redmine/setup/setup-db | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/inst-script/functions b/inst-script/functions index a49d90ce..98a20423 100644 --- a/inst-script/functions +++ b/inst-script/functions @@ -16,6 +16,11 @@ db_option() { echo "-ualminium -h${db_host} -palminium" } +# DBにALMinium設定有無チェック +db_setupped() { + echo "SELECT * FROM settings;" | mysql `db_option` alminium +} + # DBのsettingsテーブルのレコード有無チェック db_exist_record() { echo "SELECT * FROM settings WHERE name = '$1';" | mysql `db_option` alminium diff --git a/redmine/setup/setup-db b/redmine/setup/setup-db index 6fb93e06..093df5b1 100755 --- a/redmine/setup/setup-db +++ b/redmine/setup/setup-db @@ -35,8 +35,12 @@ fi bundle exec rake tmp:cache:clear RAILS_ENV=production bundle exec rake tmp:sessions:clear RAILS_ENV=production -# Customize -if [ "${ALM_UPGRADE}" != "y" ]; then +# DB Customize +db_setupped() { + echo "SELECT * FROM settings;" | mysql `db_option` alminium +} + +if [ "${ALM_UPGRADE}" != "y" -a ! "`db_setupped`" = "" ]; then echo "*** run initialize SQL ***" mysql `db_option` alminium < ${ALM_SRC_DIR}/redmine/setup/init.mysql fi From 8915d1fef44b8d4c61d7e1ca4589990b573e1193 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 4 Feb 2017 13:12:50 +0900 Subject: [PATCH 25/34] update scripts for #93 --- redmine/setup/setup-db | 4 ---- 1 file changed, 4 deletions(-) diff --git a/redmine/setup/setup-db b/redmine/setup/setup-db index 093df5b1..b27f3bd3 100755 --- a/redmine/setup/setup-db +++ b/redmine/setup/setup-db @@ -36,10 +36,6 @@ bundle exec rake tmp:cache:clear RAILS_ENV=production bundle exec rake tmp:sessions:clear RAILS_ENV=production # DB Customize -db_setupped() { - echo "SELECT * FROM settings;" | mysql `db_option` alminium -} - if [ "${ALM_UPGRADE}" != "y" -a ! "`db_setupped`" = "" ]; then echo "*** run initialize SQL ***" mysql `db_option` alminium < ${ALM_SRC_DIR}/redmine/setup/init.mysql From fdbf0cf338a7bc5033976911bf2cc7474ab1a385 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 4 Feb 2017 21:17:26 +0900 Subject: [PATCH 26/34] update scripts for #93 --- inst-script/functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst-script/functions b/inst-script/functions index 98a20423..1db86e54 100644 --- a/inst-script/functions +++ b/inst-script/functions @@ -40,7 +40,7 @@ db_update_setting() { # データベース接続テスト # 戻り値が非nullなら接続成功 db_test() { - DBCMD="mysql `db_option_root`" - echo `${DBCMD} -e "select user from user;" mysql 2>/dev/null` + echo `mysql `db_option_root` -e "select user from user" mysql 2>/dev/null` + echo `mysql `db_option` -e "show databases" alminium 2>/dev/null` } From 93c1f5cf2fcdc757e65453593453f3c29e12fc06 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 4 Feb 2017 22:15:55 +0900 Subject: [PATCH 27/34] update scripts for #93 --- inst-script/functions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inst-script/functions b/inst-script/functions index 1db86e54..8565508d 100644 --- a/inst-script/functions +++ b/inst-script/functions @@ -40,7 +40,9 @@ db_update_setting() { # データベース接続テスト # 戻り値が非nullなら接続成功 db_test() { - echo `mysql `db_option_root` -e "select user from user" mysql 2>/dev/null` - echo `mysql `db_option` -e "show databases" alminium 2>/dev/null` + local OPT=`db_option_root` + echo `mysql ${OPT} -e "select user from user" mysql 2>/dev/null` + OPT=`db_option` + echo `mysql ${OPT} -e "show databases" alminium 2>/dev/null` } From eda9c2af3fa429ea0091cdd976f04b3fe13da3ef Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sun, 5 Feb 2017 14:46:51 +0900 Subject: [PATCH 28/34] apply markdown to code-review's textfield --- redmine/setup/redmine-plugins.lst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redmine/setup/redmine-plugins.lst b/redmine/setup/redmine-plugins.lst index 0963acbe..b3fc0d62 100644 --- a/redmine/setup/redmine-plugins.lst +++ b/redmine/setup/redmine-plugins.lst @@ -10,8 +10,8 @@ redmine_xls_export,ALMinium,https://github.com/ayapapa/redmine_xls_export.git redmine_plugin_views_revisions,redmine_plugin_views_revisions,http://www.redmine.org/attachments/download/7705/redmine_plugin_views_revisions_v001.zip #redmine_importer,master,https://github.com/zh/redmine_importer.git redmine_importer,master,https://github.com/agileware-jp/redmine_importer.git -redmine_code_review,0.8.0,https://bitbucket.org/haru_iida/redmine_code_review -#redmine_code_review,master,https://github.com/ayapapa/redmine_code_review.git +#redmine_code_review,0.8.0,https://bitbucket.org/haru_iida/redmine_code_review +redmine_code_review,master,https://github.com/ayapapa/redmine_code_review.git # jenkins関係をここでインストールすると失敗する(別途インストールするようにした) #redmine_bootstrap,0.2.4,https://github.com/jbox-web/redmine_bootstrap_kit.git #redmine_jenkins,1.0.1,https://github.com/jbox-web/redmine_jenkins.git From 4645b2db0153fe76ff0451e006c017a2458560ad Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 6 Feb 2017 22:56:31 +0900 Subject: [PATCH 29/34] fixed initialize-db condition bug --- redmine/setup/setup-db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redmine/setup/setup-db b/redmine/setup/setup-db index b27f3bd3..1bd3ed2f 100755 --- a/redmine/setup/setup-db +++ b/redmine/setup/setup-db @@ -36,7 +36,7 @@ bundle exec rake tmp:cache:clear RAILS_ENV=production bundle exec rake tmp:sessions:clear RAILS_ENV=production # DB Customize -if [ "${ALM_UPGRADE}" != "y" -a ! "`db_setupped`" = "" ]; then +if [ "${ALM_UPGRADE}" != "y" -a "`db_setupped`" = "" ]; then echo "*** run initialize SQL ***" mysql `db_option` alminium < ${ALM_SRC_DIR}/redmine/setup/init.mysql fi From c8491e7026a6ce6c87410aafb255902be1ffc426 Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 6 Feb 2017 23:53:10 +0900 Subject: [PATCH 30/34] Update config-logs --- inst-script/config-logs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/inst-script/config-logs b/inst-script/config-logs index 01dd9997..bafc0c13 100755 --- a/inst-script/config-logs +++ b/inst-script/config-logs @@ -23,24 +23,25 @@ backup_and_new_logdir() { popd } -# make log's directories +# each log's configuration mkdir -p ${ALM_LOG_DIR} mkdir -p ${ALM_LOG_DIR}/redmine -mkdir -p ${ALM_LOG_DIR}/${MYSQL_LOG_DIR} mkdir -p ${ALM_LOG_DIR}/${APACHE_LOG_DIR} -mkdir -p ${ALM_LOG_DIR}/jenkins - -# -# each log's configuration -# backup_and_new_logdir "${ALM_INSTALL_DIR}" "log" "redmine" "${APACHE_USER}" "${APACHE_USER}" -backup_and_new_logdir "/var/log" "${MYSQL_LOG_DIR}" "${MYSQL_LOG_DIR}" "mysql" "adm" backup_and_new_logdir "/var/log" "${APACHE_LOG_DIR}" "${APACHE_LOG_DIR}" "root" "root" + +# jenkins log configuration if [ "${ALM_ENABLE_JENKINS}" = "y" ]; then + mkdir -p ${ALM_LOG_DIR}/jenkins backup_and_new_logdir "/var/log" "jenkins" "jenkins" "jenkins" "jenkins" fi -# ubuntu1604 apparmor setting -if [ "${OS}" = "ubuntu1604" ]; then - sed -i "s|/var/log/mysql/|/var/log/alminium/mysql/|" /etc/apparmor.d/usr.sbin.mysqld +# db log configuration +if [ "${ALM_DB_SETUP}" = "y" -a "${ALM_USE_EXISTING_DB}" != "y" ]; then + mkdir -p ${ALM_LOG_DIR}/${MYSQL_LOG_DIR} + backup_and_new_logdir "/var/log" "${MYSQL_LOG_DIR}" "${MYSQL_LOG_DIR}" "mysql" "adm" + # ubuntu1604 apparmor setting + if [ "${OS}" = "ubuntu1604" ]; then + sed -i "s|/var/log/mysql/|/var/log/alminium/mysql/|" /etc/apparmor.d/usr.sbin.mysqld + fi fi From 59ce960d5bd5a434388c83ec7d21f63fd44ea90f Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 11 Feb 2017 10:41:12 +0900 Subject: [PATCH 31/34] update upgrade-script to fix default backup directory --- upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade b/upgrade index f5c7dc8c..7eeae1f8 100755 --- a/upgrade +++ b/upgrade @@ -12,7 +12,7 @@ ALM_ETC_DIR=${ALM_ETC_DIR:-/etc/opt/alminium} ALM_VAR_DIR=/var/opt/alminium ALM_INSTALL_DIR=${ALM_INSTALL_DIR:-/opt/alminium} -ALM_BACKUP_DIR=$1 +ALM_BACKUP_DIR=${1:--} ALM_DB_HOST=${2:-${ALM_DB_HOST}} ALM_DB_HOST=${ALM_DB_HOST:-localhost} ALM_DB_ROOT_PASS=${3:-${ALM_DB_ROOT_PASS}} From c1107f5e881c2c3ecba05fbdd1d29af4bd56ef7e Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 13 Feb 2017 22:34:58 +0900 Subject: [PATCH 32/34] update for #99 --- inst-script/install-redmine | 5 ----- 1 file changed, 5 deletions(-) diff --git a/inst-script/install-redmine b/inst-script/install-redmine index 2316ea60..bf1365aa 100755 --- a/inst-script/install-redmine +++ b/inst-script/install-redmine @@ -64,11 +64,6 @@ install_gems() { sed -i.org "s/gem 'passenger'/#gem 'passenger'/" Gemfile.local fi - # avoid bandle install error because of nokogiri version conflict - sed -i.org \ - "s/gem \"nokogiri\", \">= 1.6.7.2\"/gem \"nokogiri\"#, \">= 1.6.7.2\"/" \ - Gemfile - # redmineに必要なgemをインストール bundle install --path vendor/bundle \ --without development test postgresql sqlite xapian From 64bcb9363e07c9cd7f42ea5eeb202412fb70512d Mon Sep 17 00:00:00 2001 From: ayapapa Date: Mon, 13 Feb 2017 22:44:12 +0900 Subject: [PATCH 33/34] update for #99 --- redmine/setup/install-plugins-jenkins | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redmine/setup/install-plugins-jenkins b/redmine/setup/install-plugins-jenkins index c75bb02e..9a49a3da 100755 --- a/redmine/setup/install-plugins-jenkins +++ b/redmine/setup/install-plugins-jenkins @@ -19,6 +19,9 @@ git clone -b 0.2.4 https://github.com/jbox-web/redmine_bootstrap_kit.git git clone -b v1.x https://github.com/ayapapa/redmine_jenkins.git if [ "${ALM_DB_SETUP}" = "y" ]; then + # avoid gems' version mismatch + rm $ALM_INSTALL_DIR/Gemfile.lock + # install gems and migrate database cd .. bundle install --path vendor/bundle \ From e713856f49f2ba42961bcd7a1ecf28098210630f Mon Sep 17 00:00:00 2001 From: ayapapa Date: Sat, 18 Feb 2017 13:21:23 +0900 Subject: [PATCH 34/34] fixed db_setupped() --- inst-script/functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inst-script/functions b/inst-script/functions index 8565508d..4a839617 100644 --- a/inst-script/functions +++ b/inst-script/functions @@ -18,7 +18,8 @@ db_option() { # DBにALMinium設定有無チェック db_setupped() { - echo "SELECT * FROM settings;" | mysql `db_option` alminium + mysql `db_option` -e "SELECT name FROM settings;" \ + alminium | grep welcome_text } # DBのsettingsテーブルのレコード有無チェック