Commit 5986b1d3087566d7bb9bb4717ed6fe2a7964782e
Committed by
Sergio Oliveira
1 parent
c1e6c319
Exists in
master
and in
39 other branches
Added redmine on supervisor and added comments
Showing
4 changed files
with
74 additions
and
61 deletions
Show diff stats
scripts/redmine.sh
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | -set -x | ||
| 4 | - | ||
| 5 | -if [ ! "$1" ] | ||
| 6 | - then | ||
| 7 | - echo "Por favor, passe como parâmetro o ip do banco de dados" | ||
| 8 | - echo "./redmine.sh 127.0.0.1" | ||
| 9 | - exit -1 | 3 | +LOCAL_HOST=$1 |
| 4 | +if [ -e $LOCAL_HOST ]; then | ||
| 5 | + echo "Please, inform the IP address Redmine will be listening" | ||
| 6 | + echo "ex: ./redmine.sh 127.0.0.1" | ||
| 7 | + exit -1 | ||
| 10 | fi | 8 | fi |
| 11 | 9 | ||
| 10 | +echo "Installing a lot of system dependencies also making use of EPEL repository" | ||
| 12 | sudo rpm -iUvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | 11 | sudo rpm -iUvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm |
| 13 | - | ||
| 14 | 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 | 12 | 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 |
| 15 | 13 | ||
| 14 | +echo "Making sure $USER can access /opt" | ||
| 15 | +sudo chown $USER /opt && cd /opt | ||
| 16 | 16 | ||
| 17 | -curl -L get.rvm.io | bash -s stable | ||
| 18 | - | ||
| 19 | -source /etc/profile.d/rvm.sh | ||
| 20 | - | ||
| 21 | - | ||
| 22 | -rvm install 2.0.0 | ||
| 23 | -rvm use 2.0.0 --default | 17 | +echo "Downloading Redmine 2.3" |
| 18 | +git clone https://github.com/redmine/redmine.git --branch 2.3-stable && cd /opt/redmine | ||
| 19 | +ln -s /opt/redmine/public /opt/redmine/public/redmine | ||
| 24 | 20 | ||
| 25 | -rvm gemset create redmine | 21 | +echo "Installing Ruby/Redmine dependencies, this will take a VERY LONG TIME, grab a cup of coffee..." |
| 26 | rvm gemset use redmine | 22 | rvm gemset use redmine |
| 27 | - | ||
| 28 | -sudo chown -R $USER: /opt | ||
| 29 | - | ||
| 30 | -cd /opt | ||
| 31 | -git clone https://github.com/redmine/redmine.git --branch 2.3-stable | ||
| 32 | - | ||
| 33 | -cd /opt/redmine | ||
| 34 | bundle install --verbose --without mysql sqlite | 23 | bundle install --verbose --without mysql sqlite |
| 35 | -gem install unicorn --no-ri --no-rdoc | ||
| 36 | -gem install pg -v '0.17.1' --no-ri --no-rdoc | 24 | +gem --verbose install unicorn --no-ri --no-rdoc |
| 25 | +gem --verbose install pg -v '0.17.1' --no-ri --no-rdoc | ||
| 37 | 26 | ||
| 38 | -cd config/ | ||
| 39 | - | ||
| 40 | -echo "production: | 27 | +echo "Setting Redmine database file" |
| 28 | +cd config/ && echo "production: | ||
| 41 | adapter: postgresql | 29 | adapter: postgresql |
| 42 | database: redmine | 30 | database: redmine |
| 43 | - host: $1 | 31 | + host: $LOCAL_HOST |
| 44 | username: redmine | 32 | username: redmine |
| 45 | password: redmine | 33 | password: redmine |
| 46 | encoding: utf8" > database.yml | 34 | encoding: utf8" > database.yml |
| 47 | 35 | ||
| 48 | - | 36 | +echo "Initializing Redmine database" |
| 37 | +export RAILS_ENV=production | ||
| 49 | rake generate_secret_token | 38 | rake generate_secret_token |
| 39 | +rake db:migrate | ||
| 40 | +echo "pt-BR" | rake redmine:load_default_data | ||
| 50 | 41 | ||
| 51 | -RAILS_ENV=production rake db:migrate | ||
| 52 | - | ||
| 53 | -echo "pt-BR" | RAILS_ENV=production rake redmine:load_default_data | ||
| 54 | - | ||
| 55 | - | ||
| 56 | -cd /opt/redmine | ||
| 57 | -mkdir pids | ||
| 58 | -wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/unicorn.rb -O config/unicorn.rb | ||
| 59 | - | ||
| 60 | -wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/routes.rb -O config/routes.rb | ||
| 61 | - | ||
| 62 | -ln -s /opt/redmine/public /opt/redmine/public/redmine | ||
| 63 | - | ||
| 64 | -cd /opt/redmine/plugins | ||
| 65 | -git clone https://github.com/backlogs/redmine_backlogs.git | ||
| 66 | - | ||
| 67 | -cd redmine_backlogs | ||
| 68 | -git checkout v1.0.6 | 42 | +echo "Downloading Redmine plugins" |
| 43 | +cd /opt/redmine/plugins && git clone https://github.com/colab-community/single_auth.git | ||
| 44 | +cd /opt/redmine/plugins && git clone https://github.com/backlogs/redmine_backlogs.git | ||
| 69 | 45 | ||
| 70 | -RAILS_ENV=production | ||
| 71 | -export RAILS_ENV | 46 | +echo "Installing backlogs plugin" |
| 47 | +cd redmine_backlogs && git checkout v1.0.6 | ||
| 72 | bundle install --verbose | 48 | bundle install --verbose |
| 73 | - | ||
| 74 | gem uninstall rack -v '1.5.2' | 49 | gem uninstall rack -v '1.5.2' |
| 75 | 50 | ||
| 51 | +echo "Finishing Redmine settings" | ||
| 76 | cd /opt/redmine | 52 | cd /opt/redmine |
| 77 | bundle install --verbose --without mysql sqlite | 53 | bundle install --verbose --without mysql sqlite |
| 78 | bundle exec rake db:migrate | 54 | bundle exec rake db:migrate |
| 79 | bundle exec rake redmine:backlogs:install story_trackers=2 task_tracker=1 | 55 | bundle exec rake redmine:backlogs:install story_trackers=2 task_tracker=1 |
| 80 | 56 | ||
| 81 | -cd /opt/redmine/plugins | ||
| 82 | -git clone https://github.com/colab-community/single_auth.git | 57 | +echo "Downloading server configuration files" |
| 58 | +cd /opt/redmine && mkdir pids | ||
| 59 | +wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/unicorn.rb -O config/unicorn.rb | ||
| 60 | +wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/redmine/routes.rb -O config/routes.rb | ||
| 61 | + | ||
| 62 | +echo "Setting up initialization on supervisor" | ||
| 63 | +if [ -e `cat /etc/supervisord.conf | grep redmine` ]; then | ||
| 64 | + CMD="source /usr/local/rvm/scripts/rvm &&"; | ||
| 65 | + CMD="$CMD rvm gemset use redmine &&"; | ||
| 66 | + CMD="$CMD unicorn_rails -c /opt/redmine/config/unicorn.rb -E $RAILS_ENV -p 9080 -D"; | ||
| 67 | + | ||
| 68 | + echo "[program:redmine]" >> /etc/supervisord.conf; | ||
| 69 | + echo "command=$CMD" >> /etc/supervisord.conf; | ||
| 70 | + echo "user=$USER" >> /etc/supervisord.conf; | ||
| 71 | +fi | ||
| 72 | + | ||
| 73 | +echo "Finished installing, starting Redmine service" | ||
| 74 | +supervisorctl start redmine | ||
| 83 | 75 | ||
| 84 | -unicorn_rails -c /opt/redmine/config/unicorn.rb -E production -p 9080 -D |
scripts/rvm.sh
| 1 | #! /bin/bash | 1 | #! /bin/bash |
| 2 | 2 | ||
| 3 | -# Make sure rvm is installed under sudo user | 3 | +echo "Make sure rvm is installed at /user/local/rvm" |
| 4 | sudo bash -c "curl -L get.rvm.io | bash -s stable" | 4 | sudo bash -c "curl -L get.rvm.io | bash -s stable" |
| 5 | 5 | ||
| 6 | -# Set rvm on the PATH and install ruby 2.0.0 | 6 | +echo "Set rvm on the PATH and install ruby 2.0.0" |
| 7 | sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm install ruby-2.0.0" | 7 | sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm install ruby-2.0.0" |
| 8 | +sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm use 2.0.0 --default" | ||
| 9 | + | ||
| 10 | +echo "Create gemsets for gitlab and redmine" | ||
| 8 | sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm gemset create gitlab" | 11 | sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm gemset create gitlab" |
| 9 | sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm gemset create redmine" | 12 | sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm gemset create redmine" |
| 10 | 13 | ||
| 11 | -sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm use 2.0.0@gitlab --default" | ||
| 12 | -sudo bash -c "source /usr/local/rvm/scripts/rvm && gem install bundler --no-ri --no-rdoc" |
scripts/users.sh
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | +# Make sure the current user is in sudoers file | ||
| 4 | + | ||
| 3 | # Make sure to create user colab and colabdev group | 5 | # Make sure to create user colab and colabdev group |
| 4 | COLAB_USER=colab | 6 | COLAB_USER=colab |
| 5 | COLAB_GROUP=colabdev | 7 | COLAB_GROUP=colabdev |
| @@ -11,27 +13,41 @@ COLAB_GROUP_EXISTS=`cat /etc/group | grep $COLAB_GROUP:` | @@ -11,27 +13,41 @@ COLAB_GROUP_EXISTS=`cat /etc/group | grep $COLAB_GROUP:` | ||
| 11 | # Errors | 13 | # Errors |
| 12 | ERROR_NOT_ALLOWED=126 | 14 | ERROR_NOT_ALLOWED=126 |
| 13 | ERROR_ALREADY_EXIST=9 | 15 | ERROR_ALREADY_EXIST=9 |
| 16 | +ERROR_OK=0 | ||
| 17 | + | ||
| 18 | +echo "Making sure there is $COLAB_USER user and $COLAB_GROUP group in the system" | ||
| 14 | 19 | ||
| 15 | # Make sure colab user exist | 20 | # Make sure colab user exist |
| 16 | if [ -e $COLAB_USER_EXISTS ]; then | 21 | if [ -e $COLAB_USER_EXISTS ]; then |
| 17 | sudo adduser $COLAB_USER; | 22 | sudo adduser $COLAB_USER; |
| 18 | LAST_CMD=`echo $?` | 23 | LAST_CMD=`echo $?` |
| 19 | - if [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then | 24 | + if [ $LAST_CMD == $ERROR_OK ]; then |
| 25 | + echo "User $COLAB_USER was created successfully!"; | ||
| 26 | + elif [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then | ||
| 20 | echo "You don't have permission to create users" | 27 | echo "You don't have permission to create users" |
| 21 | echo "Aborting installation" | 28 | echo "Aborting installation" |
| 22 | exit -1 | 29 | exit -1 |
| 30 | + else | ||
| 31 | + echo "Something went weird, please check for files from $COLAB_USER"; | ||
| 23 | fi | 32 | fi |
| 33 | +else | ||
| 34 | + echo "User $COLAB_USER already exist, skipping creation..." | ||
| 24 | fi | 35 | fi |
| 25 | 36 | ||
| 26 | # Make sure colab group exist | 37 | # Make sure colab group exist |
| 27 | if [ -e $COLAB_GROUP_EXISTS ]; then | 38 | if [ -e $COLAB_GROUP_EXISTS ]; then |
| 28 | sudo groupadd $COLAB_GROUP; | 39 | sudo groupadd $COLAB_GROUP; |
| 29 | LAST_CMD=`echo $?` | 40 | LAST_CMD=`echo $?` |
| 30 | - if [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then | 41 | + if [ $LAST_CMD == $ERROR_OK ]; then |
| 42 | + echo "Group $COLAB_GROUP was created successfully!"; | ||
| 43 | + elif [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then | ||
| 31 | echo "You don't have permission to create groups" | 44 | echo "You don't have permission to create groups" |
| 32 | echo "Aborting installation" | 45 | echo "Aborting installation" |
| 33 | exit -1 | 46 | exit -1 |
| 47 | + else | ||
| 48 | + echo "Something went weird, please check $COLAB_GROUP group" | ||
| 34 | fi | 49 | fi |
| 50 | +else | ||
| 51 | + echo "Group $COLAB_GROUP already exist, skipping creation..." | ||
| 35 | fi | 52 | fi |
| 36 | 53 | ||
| 37 | - |