-
Notifications
You must be signed in to change notification settings - Fork 5
/
install_on_ubuntu_1104
executable file
·95 lines (73 loc) · 2.95 KB
/
install_on_ubuntu_1104
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# To use this script:
# Update the default values below with any changes you want.
# If you are cloning a read-write copy of the og database, make sure that
# you have given github your ssh key before starting the script.
#
# Then run this script, as root, from the script's directory, as "./run_as_root"
#
# when the script is done, you will need to set config/database.yml and config/api_keys.yml.
# Then import data, and you should be good to go.
ROOT_UID=0
E_NOREPODIR=65
E_WRONG_USER=66
E_NOREPO=67
E_NOARGS=68
if [ -z $1 ]
then
echo "Usage: sudo ./install_on_ubuntu_1104 username [git repo] [postgres password]"
echo ""
echo "This script installs OpenGovernment in a regular user's directory."
echo "You need to supply at least that user's username."
echo "By default, the script will clone a read-only copy of the site from github."
echo "If you've forked a copy of the repo, and want to clone your forked copy instead,"
echo "then you need to provide that read-write git repository."
echo "The script creates a user in the Postgres database, opengovernment. The "
echo "password for that user is, by default, 'foobar'. Pretty secure, huh?"
echo "If you want to use a different password, pass that to the script, too."
exit $E_NOARGS
fi
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "This script must be run as root."
exit $E_WRONG_USER
fi
# This is the account you will run opengovernment from
# This account must already exist before the script is run
USERNAME=$1
# This defaults to the read-only main repository on github.
# If you use a read-write git repository on github, you need to exchange ssh keys
# with github before you run this.
if [ -z $2 ]
then
GITREPO="http://github.com/opengovernment/opengovernment.git"
else
GITREPO=$2
fi
# This is the password that will be used for the postgres user 'opengovernment'
if [ -z $3 ]
then
POSTGRESUSERPWORD='foobar'
else
POSTGRESUSERPWORD=$3
fi
# Mongo DB's Debian packages are here. Change this according to your Linux distribution.
MONGOAPT="deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen"
# I use apt-cacher on a local machine called 'nut' to cach apt's package files. So my apt line looks like this:
# MONGOAPT="deb http://nut/apt-cacher/downloads.mongodb.org/distros/ubuntu 10.10 10gen"
# The home directory for the user
USERHOMEDIR="/home/$USERNAME"
# opengovernment will be installed under this directory
OPENGOVPARENTDIR=$USERHOMEDIR
export MONGOAPT
export POSTGRESUSERPWORD
export USERHOMEDIR
cd ubuntu
SCRIPTDIR=`pwd`
$SCRIPTDIR/as-root_setup_og
$SCRIPTDIR/as-root_setup_pg
sudo USERHOMEDIR=$USERHOMEDIR -iu $USERNAME $SCRIPTDIR/as-user_install_rvm_on_debian_or_ubuntu
sudo USERHOMEDIR=$USERHOMEDIR OPENGOVPARENTDIR=$OPENGOVPARENTDIR GITREPO=$GITREPO -iu $USERNAME $SCRIPTDIR/as-user_clone_site
echo ""
echo "Opengovernment has been set up; now you need to set rvm's environment variables."
echo "The easiest way to do that is to just log out and then back in."