Skip to content

Instantly share code, notes, and snippets.

@tessi
Last active February 17, 2018 02:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tessi/c429a4c34cefb6c69ee7 to your computer and use it in GitHub Desktop.
Save tessi/c429a4c34cefb6c69ee7 to your computer and use it in GitHub Desktop.
NOT MAINTAINED: OpenProject Install Script for a fresh uberspace
#!/bin/sh
set -e
echo "this script installs openproject"
echo "things might take a while, please be patient"
echo ""
echo "setup environment..."
echo "gem: --user-install --no-rdoc --no-ri" > ~/.gemrc
cat <<'__EOF__' >> ~/.bash_profile
export PATH=/package/host/localhost/ruby-2.1.2/bin:$PATH
export PATH=$HOME/.gem/ruby/2.1.0/bin:$PATH
export PATH=/package/host/localhost/nodejs-0.10.33/bin:$PATH
export LANG=en_US.UTF-8
__EOF__
cat > ~/.npmrc <<__EOF__
prefix = $HOME
umask = 077
__EOF__
cat > ~/.bowerrc <<__EOF__
{
"interactive": false
}
__EOF__
source ~/.bash_profile
echo "seeding openproject directory..."
mkdir apps; cd apps
git clone https://github.com/opf/openproject.git > /dev/null 2>&1
cd openproject
git checkout stable > /dev/null 2>&1
cat > config/configuration.yml <<__EOF__
production:
email_delivery:
delivery_method: :sendmail
sendmail_settings:
location: /usr/sbin/sendmail
arguments: -i
rails_cache_store: :memcache
__EOF__
export OPENPROJECT_DB=${USER}_openproject
export OPENPROJECT_DB_PASS=`grep -Po "(?<=password=).*(?= # )" ~/.my.cnf`
cat > config/database.yml <<__EOF__
production:
adapter: mysql2
database: $OPENPROJECT_DB
host: localhost
username: $USER
password: $OPENPROJECT_DB_PASS
encoding: utf8
development:
adapter: mysql2
database: $OPENPROJECT_DB
host: localhost
username: $USER
password: $OPENPROJECT_DB_PASS
encoding: utf8
__EOF__
cat > Gemfile.local <<__EOF__
gem 'rails_12factor'
gem 'openproject-translations', :git => 'https://github.com/opf/openproject-translations.git', :branch => 'stable'
gem 'openproject-meeting', :git => 'https://github.com/finnlabs/openproject-meeting.git', :branch => 'stable'
gem 'openproject-pdf_export', :git => 'https://github.com/finnlabs/openproject-pdf_export.git', :branch => 'stable'
gem "openproject-backlogs", :git => "https://github.com/finnlabs/openproject-backlogs.git", :branch => 'stable'
gem 'openproject-documents', :git => 'https://github.com/opf/openproject-documents.git', :branch => 'stable'
__EOF__
echo "installing ruby dependencies..."
gem install bundler > /dev/null 2>&1
bundle install --quiet --path ~/.gem --without postgres:sqlite:test > /dev/null 2>&1
echo "setting up database..."
RAILS_ENV=production bundle exec rake generate_secret_token db:create db:migrate db:seed > /dev/null 2>&1
echo "installing bower dependencies..."
npm install -g bower > /dev/null 2>&1
npm install > /dev/null 2>&1
echo "precomiling assets..."
RAILS_ENV=production bundle exec rake assets:precompile > /dev/null 2>&1
echo "searching a free port..."
export port=61000
export port_max=65535
export netstat_output=`netstat -atwn`
export server_port=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
echo "initiating openproject services..."
test -d ~/service || uberspace-setup-svscan
cat <<__EOF__ > ~/bin/openproject-web
#!/bin/sh
# This is needed to find gems installed with --user-install
export HOME=$HOME
# Include our profile to get Ruby 2.1.2 included in our PATH
. \$HOME/.bash_profile
# Get into the project directory and start the Rails server
cd \$HOME/apps/openproject
exec bundle exec unicorn --port $server_port --env production
__EOF__
chmod +x ~/bin/openproject-web
uberspace-setup-service openproject-web ~/bin/openproject-web
cat <<__EOF__ > ~/bin/openproject-worker
#!/bin/sh
# This is needed to find gems installed with --user-install
export HOME=$HOME
# we're faster and use the right database in production
export RAILS_ENV=production
# Include our profile to get Ruby 2.1.2 included in our PATH
. \$HOME/.bash_profile
# Get into the project directory and start the Rails server
cd \$HOME/apps/openproject
exec bundle exec rake jobs:work
__EOF__
chmod +x ~/bin/openproject-worker
uberspace-setup-service openproject-worker ~/bin/openproject-worker
echo "setting up apache rewrite rules..."
cat > ~/html/.htaccess <<__EOF__
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteRule (.*) http://localhost:$server_port/\$1 [P]
__EOF__
@Webmasterei
Copy link

Thanks for this Guide Tessi.
I'd like to Upgrade my 3.0.14 install to 4.
How do I do that with this git installation?

@snorreflorre
Copy link

I'm getting: /usr/bin/curl: /usr/bin/curl: cannot execute binary file

@mactree
Copy link

mactree commented Mar 18, 2016

Hi Tessi,
when i ssh into uberspace an run the above command i get: /usr/bin/curl: /usr/bin/curl: cannot execute binary file
When i put the op_install.sh file in my uberspace directory and run it with ./op_install.sh it stops after creating the apps directory
this is the complete output:
[xxx@xxx ~]$ ./op_install.sh
this script installs openproject
things might take a while, please be patient
setup environment...
seeding openproject directory...
[xxx@xxx ~]$

@janstieler
Copy link

janstieler commented May 22, 2016

Same problem here. it stops after creating the apps directory.

@biolauri
Copy link

As this script is not maintained anymore, I did a new How To for OpenProject on Uberspace; including support for the latest version and Memcached: Install OpenProject (latest) with Memcached on Uberspace. I hope, this helps! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment