From 5986b1d3087566d7bb9bb4717ed6fe2a7964782e Mon Sep 17 00:00:00 2001 From: Charles Oliveira <18oliveira.charles@gmail.com> Date: Fri, 15 Aug 2014 13:06:31 -0300 Subject: [PATCH] Added redmine on supervisor and added comments --- scripts/redmine.sh | 99 +++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------ scripts/rvm.sh | 9 +++++---- scripts/supervisor.sh | 5 +++++ scripts/users.sh | 22 +++++++++++++++++++--- 4 files changed, 74 insertions(+), 61 deletions(-) create mode 100755 scripts/supervisor.sh diff --git a/scripts/redmine.sh b/scripts/redmine.sh index 96dbc0b..5315b1a 100755 --- a/scripts/redmine.sh +++ b/scripts/redmine.sh @@ -1,84 +1,75 @@ #!/bin/bash -set -x - -if [ ! "$1" ] - then - echo "Por favor, passe como parĂ¢metro o ip do banco de dados" - echo "./redmine.sh 127.0.0.1" - exit -1 +LOCAL_HOST=$1 +if [ -e $LOCAL_HOST ]; then + echo "Please, inform the IP address Redmine will be listening" + echo "ex: ./redmine.sh 127.0.0.1" + exit -1 fi +echo "Installing a lot of system dependencies also making use of EPEL repository" sudo rpm -iUvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm - sudo yum -y install zlib-devel curl-devel httpd-devel apr-devel apr-util-devel subversion git postgresql-devel gcc gcc-c++.x86_64 make automake autoconf curl-devel openssl-devel httpd-devel apr-devel apr-util-devel sqlite-devel libxslt-devel libxml2-devel.x86_64 php-pear ImageMagick ImageMagick-devel ImageMagick-perl vim patch readline readline-devel zlib libffi-devel make bzip2 libtool bison wget libyaml-devel +echo "Making sure $USER can access /opt" +sudo chown $USER /opt && cd /opt -curl -L get.rvm.io | bash -s stable - -source /etc/profile.d/rvm.sh - - -rvm install 2.0.0 -rvm use 2.0.0 --default +echo "Downloading Redmine 2.3" +git clone https://github.com/redmine/redmine.git --branch 2.3-stable && cd /opt/redmine +ln -s /opt/redmine/public /opt/redmine/public/redmine -rvm gemset create redmine +echo "Installing Ruby/Redmine dependencies, this will take a VERY LONG TIME, grab a cup of coffee..." rvm gemset use redmine - -sudo chown -R $USER: /opt - -cd /opt -git clone https://github.com/redmine/redmine.git --branch 2.3-stable - -cd /opt/redmine bundle install --verbose --without mysql sqlite -gem install unicorn --no-ri --no-rdoc -gem install pg -v '0.17.1' --no-ri --no-rdoc +gem --verbose install unicorn --no-ri --no-rdoc +gem --verbose install pg -v '0.17.1' --no-ri --no-rdoc -cd config/ - -echo "production: +echo "Setting Redmine database file" +cd config/ && echo "production: adapter: postgresql database: redmine - host: $1 + host: $LOCAL_HOST username: redmine password: redmine encoding: utf8" > database.yml - +echo "Initializing Redmine database" +export RAILS_ENV=production rake generate_secret_token +rake db:migrate +echo "pt-BR" | rake redmine:load_default_data -RAILS_ENV=production rake db:migrate - -echo "pt-BR" | RAILS_ENV=production rake redmine:load_default_data - - -cd /opt/redmine -mkdir pids -wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/unicorn.rb -O config/unicorn.rb - -wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/routes.rb -O config/routes.rb - -ln -s /opt/redmine/public /opt/redmine/public/redmine - -cd /opt/redmine/plugins -git clone https://github.com/backlogs/redmine_backlogs.git - -cd redmine_backlogs -git checkout v1.0.6 +echo "Downloading Redmine plugins" +cd /opt/redmine/plugins && git clone https://github.com/colab-community/single_auth.git +cd /opt/redmine/plugins && git clone https://github.com/backlogs/redmine_backlogs.git -RAILS_ENV=production -export RAILS_ENV +echo "Installing backlogs plugin" +cd redmine_backlogs && git checkout v1.0.6 bundle install --verbose - gem uninstall rack -v '1.5.2' +echo "Finishing Redmine settings" cd /opt/redmine bundle install --verbose --without mysql sqlite bundle exec rake db:migrate bundle exec rake redmine:backlogs:install story_trackers=2 task_tracker=1 -cd /opt/redmine/plugins -git clone https://github.com/colab-community/single_auth.git +echo "Downloading server configuration files" +cd /opt/redmine && mkdir pids +wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/unicorn.rb -O config/unicorn.rb +wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/routes.rb -O config/routes.rb + +echo "Setting up initialization on supervisor" +if [ -e `cat /etc/supervisord.conf | grep redmine` ]; then + CMD="source /usr/local/rvm/scripts/rvm &&"; + CMD="$CMD rvm gemset use redmine &&"; + CMD="$CMD unicorn_rails -c /opt/redmine/config/unicorn.rb -E $RAILS_ENV -p 9080 -D"; + + echo "[program:redmine]" >> /etc/supervisord.conf; + echo "command=$CMD" >> /etc/supervisord.conf; + echo "user=$USER" >> /etc/supervisord.conf; +fi + +echo "Finished installing, starting Redmine service" +supervisorctl start redmine -unicorn_rails -c /opt/redmine/config/unicorn.rb -E production -p 9080 -D diff --git a/scripts/rvm.sh b/scripts/rvm.sh index f4354e9..316521c 100755 --- a/scripts/rvm.sh +++ b/scripts/rvm.sh @@ -1,12 +1,13 @@ #! /bin/bash -# Make sure rvm is installed under sudo user +echo "Make sure rvm is installed at /user/local/rvm" sudo bash -c "curl -L get.rvm.io | bash -s stable" -# Set rvm on the PATH and install ruby 2.0.0 +echo "Set rvm on the PATH and install ruby 2.0.0" sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm install ruby-2.0.0" +sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm use 2.0.0 --default" + +echo "Create gemsets for gitlab and redmine" sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm gemset create gitlab" sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm gemset create redmine" -sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm use 2.0.0@gitlab --default" -sudo bash -c "source /usr/local/rvm/scripts/rvm && gem install bundler --no-ri --no-rdoc" diff --git a/scripts/supervisor.sh b/scripts/supervisor.sh new file mode 100755 index 0000000..adaea7f --- /dev/null +++ b/scripts/supervisor.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Make sure supervisor is installed" +sudo yum install -y supervisor + diff --git a/scripts/users.sh b/scripts/users.sh index e9e8408..09c402f 100755 --- a/scripts/users.sh +++ b/scripts/users.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Make sure the current user is in sudoers file + # Make sure to create user colab and colabdev group COLAB_USER=colab COLAB_GROUP=colabdev @@ -11,27 +13,41 @@ COLAB_GROUP_EXISTS=`cat /etc/group | grep $COLAB_GROUP:` # Errors ERROR_NOT_ALLOWED=126 ERROR_ALREADY_EXIST=9 +ERROR_OK=0 + +echo "Making sure there is $COLAB_USER user and $COLAB_GROUP group in the system" # Make sure colab user exist if [ -e $COLAB_USER_EXISTS ]; then sudo adduser $COLAB_USER; LAST_CMD=`echo $?` - if [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then + if [ $LAST_CMD == $ERROR_OK ]; then + echo "User $COLAB_USER was created successfully!"; + elif [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then echo "You don't have permission to create users" echo "Aborting installation" exit -1 + else + echo "Something went weird, please check for files from $COLAB_USER"; fi +else + echo "User $COLAB_USER already exist, skipping creation..." fi # Make sure colab group exist if [ -e $COLAB_GROUP_EXISTS ]; then sudo groupadd $COLAB_GROUP; LAST_CMD=`echo $?` - if [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then + if [ $LAST_CMD == $ERROR_OK ]; then + echo "Group $COLAB_GROUP was created successfully!"; + elif [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then echo "You don't have permission to create groups" echo "Aborting installation" exit -1 + else + echo "Something went weird, please check $COLAB_GROUP group" fi +else + echo "Group $COLAB_GROUP already exist, skipping creation..." fi - -- libgit2 0.21.2