1 GITDIR="/usr/share/webapps/gitorious"
2 BUNDLE="/opt/ruby-enterprise/bin/bundle"
5 SECRET=$(dd if=/dev/random count=1 2>/dev/null | sha256sum | awk '{print $1}')
6 sed -i "s|CHANGEME_SECRET|$SECRET|" /etc/webapps/gitorious/gitorious.yml
8 echo "Creating git user"
9 useradd git -MUd "$GITDIR" -s /bin/bash > /dev/null 2>&1
10 echo "* * * * * cd \"$GITDIR\" && bin/rake ultrasphinx:index RAILS_ENV=production" | crontab - -u git
11 cd "$GITDIR" || return 1
12 mkdir -p tmp tarballs repositories pids site/tmp/pids .ssh site/data/hooks/pre site/data/hooks/post
13 touch .ssh/authorized_keys
16 chmod 600 .ssh/authorized_keys
17 chmod 744 site/data/hooks/pre site/data/hooks/post
18 chown -R git:git "$GITDIR"
20 echo "Configuring mysql & sphinx:"
21 echo -n " - Creating database gitorious: "
22 echo 'CREATE DATABASE gitorious; GRANT ALL ON gitorious.* TO gitorious@localhost IDENTIFIED BY "G170r!oUs";' | mysql > /dev/null 2>&1 && echo ok || echo FAIL
23 echo -n " - db:setup "
24 su - git -c "bin/rake db:setup RAILS_ENV=production" > /dev/null 2>&1 && echo ok || echo FAIL
25 echo -n " - ultrasphinx:configure "
26 su - git -c "bin/rake ultrasphinx:configure RAILS_ENV=production" > /dev/null 2>&1 && echo ok || echo FAIL
27 echo -n " - ultrasphinx:bootstrap "
28 su - git -c "bin/rake ultrasphinx:bootstrap RAILS_ENV=production" > /dev/null 2>&1 && echo ok || echo FAIL
29 echo -n " - ultrasphinx:spelling:build "
30 cd $GITDIR && bin/rake ultrasphinx:spelling:build RAILS_ENV=production > /dev/null 2>&1 && echo ok || echo FAIL
34 echo "If mysql was not running during install (or any of the previous steps failed)"
35 echo "you will need to create the database and run rake manually."
36 echo "# echo 'CREATE DATABASE gitorious; GRANT ALL ON gitorious.* TO gitorious@localhost IDENTIFIED BY \"G170r!oUs\";' | mysql"
37 echo "# su - git -c \"bin/rake db:setup RAILS_ENV=production\""
38 echo "# su - git -c \"bin/rake ultrasphinx:configure RAILS_ENV=production\""
39 echo "# su - git -c \"bin/rake ultrasphinx:bootstrap RAILS_ENV=production\""
40 echo "# cd $GITDIR && bin/rake ultrasphinx:spelling:build RAILS_ENV=production"
43 echo "To create the admin user, issue the following command"
44 echo "# su - git -c \"env RAILS_ENV=production $BUNDLE exec script/create_admin\""
47 echo "Gitorious is a ruby application and depends on the following daemons that must be running:"
48 echo "# /etc/rc.d/stompserver start"
49 echo "# /etc/rc.d/gitorious-daemon start"
50 echo "# /etc/rc.d/gitorious-poller start"
51 echo "# /etc/rc.d/gitorious-ultrasphinx start"
53 echo "To run the application itself you can issue the following command:"
54 echo "# su - git -c \"$BUNDLE exec script/server -e production\""
55 echo "and visit http://localhost.localdomain:3000"
56 echo "or deploy it like any other ruby application (Ex: apache+passenger)"
60 chown -R git:git "$GITDIR"
62 echo "The database may need to be migrated to reflect the latest changes in the application"
63 echo "To migrate run the following command:"
64 echo "# su - git -c \"bin/rake db:migrate RAILS_ENV=production\""
69 rm -f /var/spool/cron/git