Skip to content

Instantly share code, notes, and snippets.

@hilotech
Created August 4, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hilotech/5a16955c6978d3984330 to your computer and use it in GitHub Desktop.
Save hilotech/5a16955c6978d3984330 to your computer and use it in GitHub Desktop.
Redmine 3.0.2のインストールスクリプト(CentOS 6.x w/ bash)
#!/bin/bash
set -e
set -u
# must replace with your own configuration
FQDN='redmine.your.domain'
MYSQL_ROOT_PASSWORD='root_password'
DB_APP_PASSWORD='redmine_database_password'
MYSQL_HOST='localhost'
MYSQL_ROOT_USER='root'
MYSQL_NEWDBNAME='redmine'
SMTP_HOST="localhost"
DIST_RUBY='http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz'
DIST_REDMINE='http://www.redmine.org/releases/redmine-3.0.3.tar.gz'
yum -y update
yum -y install \
rsyslog cronie w3m which telnet unzip tar expect \
postfix mysql mysql-server
yum -y install epel-release
yum -y erase libyaml
yum -y install --disablerepo=epel libyaml libyaml-devel
yum -y install \
gd gd-devel freetype freetype-devel ncurses-devel \
mysql-devel mysql-libs \
zlib-devel tk-devel readline-devel \
libffi-devel gdbm-devel db4-devel curl-devel \
ImageMagick-devel ImageMagick \
libxml2-devel libxslt-devel \
graphviz graphviz-gd ipa-gothic-fonts.noarch \
subversion mercurial \
git wget \
httpd httpd-devel apr apr-devel apr-util apr-util-devel \
gcc make openssl-devel gcc-c++
# Postfix
chkconfig postfix on
service postfix start
echo "redmineman: \"|/opt/redmine/extra/mail_handler/rdm-mailhandler.rb --url http://${FQDN-}/ --key \`/bin/mysql -h${MYSQL_HOST-} -u${MYSQL_NEWDBNAME-} -p${DB_APP_PASSWORD-} -e 'SELECT value FROM redmine.settings WHERE name=\\\"mail_handler_api_key\\\";' -sN\` --allow-override tracker,category,priority,status\"" >> /etc/aliases
newaliases
# MySQL
chkconfig mysqld on
service mysqld start
expect <<_EOF
set timeout 10
spawn /usr/bin/mysql_secure_installation
expect "Enter current password for root (enter for none):"
send "\n"
expect "Set root password? \[Y/n\]"
send "\n"
expect "New password:"
send "$MYSQL_ROOT_PASSWORD\n"
expect "Re-enter new password:"
send "$MYSQL_ROOT_PASSWORD\n"
expect "Remove anonymous users? \[Y/n\]"
send "\n"
expect "Disallow root login remotely? \[Y/n\]"
send "\n"
expect "Remove test database and access to it? \[Y/n\]"
send "\n"
expect "Reload privilege tables now? \[Y/n\]"
send "\n"
expect eof
_EOF
/usr/bin/mysql \
--host=${MYSQL_HOST-} \
--user=${MYSQL_ROOT_USER-} \
--password=${MYSQL_ROOT_PASSWORD-} \
<<_EOF_
CREATE
DATABASE ${MYSQL_NEWDBNAME-}
DEFAULT CHARACTER SET utf8
;
GRANT
ALL PRIVILEGES
ON ${MYSQL_NEWDBNAME-}.*
TO ${MYSQL_NEWDBNAME-}@localhost
IDENTIFIED BY '${DB_APP_PASSWORD-}'
;
GRANT
ALL PRIVILEGES
ON ${MYSQL_NEWDBNAME-}.*
TO ${MYSQL_NEWDBNAME-}@'127.0.0.1'
IDENTIFIED BY '${DB_APP_PASSWORD-}'
;
_EOF_
# Ruby
yum -y erase ruby*
DIR_TEMP=`mktemp -d`
DIST_RUBY="$DIST_RUBY"
cd $DIR_TEMP
wget $DIST_RUBY
FN=$(basename $DIST_RUBY)
tar xvzf $FN
BN=${FN%.tar.gz}
cd $BN
./configure --prefix=/usr
make && make install
echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc
gem install haml
cd /tmp
/bin/rm -r $DIR_TEMP
# Passenger + Apache
gem install passenger
passenger-install-apache2-module --auto --language ruby
passenger-install-apache2-module --snippet \
> /etc/httpd/conf.d/passenger.conf
[ ! -d /etc/httpd/vhosts ] \
&& mkdir -p /etc/httpd/vhosts
cat <<'_EOF_' >/etc/httpd/conf.d/vhosts.conf
NameVirtualHost *:80
Include vhosts/*.conf
_EOF_
[ -r /etc/httpd/conf.d/welcome.conf ] \
&& mv /etc/httpd/conf.d/welcome.conf{,.org}
cat <<_EOF_ >/etc/httpd/vhosts/$FQDN.conf
<VirtualHost *:80>
ServerName $FQDN
DocumentRoot /opt/redmine/public
<Directory /opt/redmine/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
_EOF_
echo 'ServerName localhost:80' > /etc/httpd/conf.d/servername.conf
echo 'LimitRequestBody 2147483647' > /etc/httpd/conf.d/uploadsize_conf
# Redmine
DIR_TEMP=`mktemp -d`
DIST_REDMINE="$DIST_REDMINE"
cd $DIR_TEMP
wget $DIST_REDMINE
FN=$(basename $DIST_REDMINE)
tar xvzf $FN
BN=${FN%.tar.gz}
mv $BN /opt/redmine
cd /opt/redmine
/bin/rm -r $DIR_TEMP
gem install nokogiri -- --use-system-libraries
gem install bundler --no-rdoc --no-ri
cat <<_EOF_database-yml > /opt/redmine/config/database.yml
production:
adapter: mysql2
database: $MYSQL_NEWDBNAME
host: $MYSQL_HOST
username: $MYSQL_NEWDBNAME
password: $DB_APP_PASSWORD
encoding: utf8
_EOF_database-yml
cat <<_EOF_configuration-yml > /opt/redmine/config/configuration.yml
default:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: $SMTP_HOST
port: 25
scm_subversion_path_regexp:
scm_mercurial_path_regexp:
scm_git_path_regexp:
scm_cvs_path_regexp:
scm_bazaar_path_regexp:
scm_darcs_path_regexp:
scm_filesystem_path_regexp:
attachments_storage_path: /opt/files-redmine
imagemagick_convert_command: /usr/bin/convert
rmagick_font_path: /usr/share/fonts/ipa-gothic/ipag.ttf
_EOF_configuration-yml
echo "gem 'mail-iso-2022-jp'" > Gemfile.local
bundle install
gem install activerecord-mysql-adapter
RAILS_ENV=production bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
mkdir /opt/files-redmine
# Redmine themes
cd /opt/redmine/public/themes
git clone https://github.com/farend/redmine_theme_farend_basic.git
git clone https://github.com/farend/redmine_theme_farend_fancy.git
git clone https://github.com/makotokw/redmine-theme-gitmike.git
# Redmine plugins
cd /opt/redmine/plugins
hg clone https://bitbucket.org/tkusukawa/redmine_work_time
git clone https://github.com/zh/redmine_importer.git
svn co https://github.com/teleological/redmine_stealth
hg clone https://bitbucket.org/haru_iida/redmine_logs
git clone git://github.com/splendeo/redmine-environment-css.git
hg clone https://bitbucket.org/haru_iida/redmine_theme_changer
git clone https://github.com/danmunn/redmine_dmsf.git
sed -i \
-e "s|\(gem 'rubyzip', '>=\) 1.0.0\('\)|\1 1.1.3\2|;" \
redmine_dmsf/Gemfile
git clone https://github.com/alminium/redmine_drafts.git
ARCFN=`mktemp`
wget -O $ARCFN http://www.redmine.org/attachments/download/7705/redmine_plugin_views_revisions_v001.zip
unzip $ARCFN
/bin/rm $ARCFN
git clone https://github.com/zipme/redmine_lightbox.git
git clone https://github.com/pullmonkey/open_flash_chart.git
git clone https://github.com/mikoto20000/redmine_git_branch_hook.git
hg clone https://bitbucket.org/haru_iida/redmine_code_review
git clone https://github.com/ameya86/redmine_maintenance.git
git clone https://github.com/suer/redmine_absolute_dates.git
git clone https://github.com/peclik/clipboard_image_paste.git
git clone https://github.com/akiko-pusu/redmine_banner.git
git clone https://github.com/suer/redmine_enter_cancel.git
hg clone https://bitbucket.org/akiko_pusu/redmine_issue_templates
git clone https://github.com/two-pack/redmine_xls_export.git
sed -i \
-e "s|\(gem \"nokogiri\"\)|\1, '>= 1.5.10'|;" \
redmine_xls_export/Gemfile
git clone https://github.com/two-pack/redmine_xlsx_format_issue_exporter.git
git clone https://github.com/JohnBat26/redmine_issue_icons.git
git clone git://github.com/luismaia/redmine_email_fetcher.git
git clone https://github.com/a-ono/redmine_per_project_formatting
git clone https://github.com/darioo/redmine_documents.git
git clone https://github.com/ngyuki/redmine_redcarpet_viewer.git
git clone https://github.com/stpl/redmine_wysiwyg.git
hg clone https://bitbucket.org/haru_iida/redmine_wiki_extensions
hg clone https://bitbucket.org/tkusukawa/redmine_wiki_lists
git clone https://github.com/jgraichen/redmine_dashboard.git
(
cd redmine_dashboard
git checkout v2.6.1
)
git clone https://github.com/HarryHoliday/gallery_board.git
git clone https://github.com/paginagmbh/redmine_silencer.git
git clone https://github.com/basyura/redmine_wiki_index_tree_view.git
git clone https://github.com/Hopebaytech/redmine_issue_reminder.git
sed -i \
-e "s|\(gem 'nokogiri'\)|\1, '>= 1.5.10'|;" \
redmine_issue_reminder/Gemfile
git clone https://github.com/thorin/redmine_ldap_sync.git
rake -T redmine:plugins:ldap_sync RAILS_ENV=production
#35 * * * * apache /usr/bin/rake -f /opt/redmine/Rakefile --silent redmine:plugins:ldap_sync:sync_all RAILS_ENV=production |& logger
# zipped plugins
DIR_TEMP=`mktemp -d`
cd $DIR_TEMP
BASE_URL='https://github.com/hilotech/Reckerfiles/raw/master/Reckerfiles/redmine/src/'
for i in \
redmine_agile-1_3_8-light \
redmine_checklists-3_1_1-light \
redmine_journal_folder \
redmine_zenedit-0_0_2-light \
;
do
wget "$BASE_URL$i.zip"
done
for fn in $( find $DIR_TEMP -type f -name '*.zip' );
do
DIR_UNZIP=`mktemp -d`
cd $DIR_UNZIP
unzip $fn
DIR_TO_MOVE="$(find . -maxdepth 1 -type d ! -name . )"
mv $DIR_TO_MOVE /opt/redmine/plugins
cd /tmp
/bin/rm -r "$DIR_UNZIP"
done
cd /tmp
/bin/rm -r "${DIR_TEMP-}"
cd /opt/redmine
bundle install --without xapian
bundle update
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
chmod +x /opt/redmine/extra/mail_handler/rdm-mailhandler.rb
chown -R apache.apache /opt/redmine /opt/files-redmine
chmod a+w /opt/redmine/files /opt/files-redmine
chkconfig httpd on
service httpd start
iptables -I INPUT -p tcp --dport http -j ACCEPT
service iptables save
service iptables reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment