-
Notifications
You must be signed in to change notification settings - Fork 6
/
ubuntu-setup.bash
executable file
·207 lines (180 loc) · 6.39 KB
/
ubuntu-setup.bash
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
# Author : [email protected]
# Site : www.h3manth.com
# Contributions from: Mackenzie Morgan (maco) and Daniel Thomas (drt24)
# This script helps to setup diaspora.
#
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
# USAGE: ./pkg/ubun/tu-setup.bash [external hostname]
# Do NOT run this script as root.
#
# Synopsis:
# git clone http://github.com/diaspora/diaspora.git
# cd diaspora
# git submodule update --init pkg
# pkg/ubuntu-setup.bash
# ./script/server
GIT_REPO=${GIT_REPO:-'http://github.com/leamas/diaspora.git'}
arg_hostname="$1"
# Set extented globbing
shopt -s extglob
# fail on error
set -e
[[ "$(whoami)" == "root" ]] && echo "Please do not run this script as root/sudo
We need to do some actions as an ordinary user. We use sudo where necessary." && exit 1
# Check if the user has sudo privileges.
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }
# Check if universal repository is enabled
grep -ie '^deb .*universe' /etc/apt/sources.list > /dev/null || \
{ echo "Please enable universe repository" ; exit 1 ; }
# Make sure that we only install the latest version of packages
sudo apt-get update
# Check if wget is installed
test wget || { echo "Installing wget.." && sudo apt-get install wget \
&& echo "Installed wget.." ; }
# Install build tools
echo "Installing build tools.."
sudo apt-get -y --no-install-recommends install \
build-essential libxslt1.1 libxslt1-dev libxml2
echo "..Done installing build tools"
# Install Ruby 1.8.7
echo "Installing ruby-full Ruby 1.8.7.."
sudo apt-get -y --no-install-recommends install ruby-full
echo "..Done installing Ruby"
# Install Rake
echo "Installing rake.."
sudo apt-get -y --no-install-recommends install rake
echo "..Done installing rake"
#Store the release name so we can use it here and later
RELEASE=$(lsb_release -c | cut -f2)
# Get the current release and install mongodb
if [ $RELEASE == "maverick" ]
then
#mongodb does not supply a repository for maverick yet so install
# an older version from the ubuntu repositories
if [ ! -f /usr/lib/libmozjs.so ]
then
echo "Lanchpad bug https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/557024
has not been fixed using workaround:"
echo "sudo ln -sf /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so"
sudo ln -sf /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so
fi
sudo apt-get -y --no-install-recommends install mongodb
else
lsb=$(lsb_release -rs)
ver=${lsb//.+(0)/.}
repo="deb http://downloads.mongodb.org/distros/ubuntu ${ver} 10gen"
echo "Setting up MongoDB.."
echo "."
echo ${repo} | sudo tee -a /etc/apt/sources.list
echo "."
echo "Fetching keys.."
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "."
sudo apt-get update
echo "."
sudo apt-get -y --no-install-recommends install mongodb-stable
echo "Done installing monngodb-stable.."
fi
# Install imagemagick
echo "Installing imagemagick.."
sudo apt-get -y --no-install-recommends install imagemagick libmagick9-dev
echo "Installed imagemagick.."
# Install git-core
echo "Installing git-core.."
sudo apt-get -y --no-install-recommends install git-core
echo "Installed git-core.."
# Setting up ruby gems
echo "Fetching and installing ruby gems.."
(
if [ $RELEASE == "maverick" ]
then
sudo apt-get install --no-install-recommends -y rubygems
sudo ln -sf /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
elif [ $RELEASE == "lucid" ]
then
sudo add-apt-repository ppa:maco.m/ruby
sudo apt-get update
sudo apt-get install --no-install-recommends -y rubygems
sudo ln -sf /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
else
# Old version
echo "."
cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
echo "."
tar -xf rubygems-1.3.7.tgz
echo "."
cd rubygems-1.3.7
echo "."
sudo ruby setup.rb
echo "."
sudo ln -sf /usr/bin/gem1.8 /usr/bin/gem
echo "."
fi
)
echo "Done installing the gems.."
# Install bundler
echo "Installing bundler.."
sudo gem install bundler
echo "Installed bundler.."
# Take a clone of Diaspora
# Check if the user is already in a cloned source if not clone the source
[[ $( basename $PWD ) == "diaspora" ]] && \
echo "Already in diaspora directory" || {
git clone $GIT_REPO && {
cd diaspora
git submodule update --init pkg
echo "Cloned the source.."
}
}
# Install extra gems
echo "Installing more gems.."
bundle install || {
echo "OOPS: bundle install crashed. Let's try once again!"
bundle install
}
# bundle exec jasmine init
[ -e lib/tasks/jasmine.rake ] && \
mv lib/tasks/jasmine.rake lib/tasks/jasmine.no-rake
echo "Installed."
#Configure diaspora
cp config/app_config.yml.example config/app_config.yml
hostname=$( awk '/pod_url:/ { print $2; exit }' <config/app_config.yml)
if [ -n "$arg_hostname" ]; then
sed -i "/pod_url:/s|$hostname|$arg_hostname|g" config/app_config.yml &&
echo "config/app_config.yml updated."
else
while : ; do
echo "Current hostname is \"$hostname\""
echo -n "Enter new hostname [$hostname] :"
read new_hostname garbage
echo -n "Use \"$new_hostname\" as pod_url (Yes/No) [Yes]? :"
read yesno garbage
[ "${yesno:0:1}" = 'y' -o "${yesno:0:1}" = 'Y' -o -z "$yesno" ] && {
sed -i "/pod_url:/s|$hostname|$new_hostname|g" \
config/app_config.yml &&
echo "config/app_config.yml updated."
break
}
done
fi
# Install DB setup
echo "Setting up DB..."
if rake db:seed:dev ; then
cat <<- EOF
DB ready. Logins -> tom or korth, password -> evankorth.
More details ./diaspora/db/seeds/tom.rb. and ./diaspora/db/seeds/dev.rb.
EOF
else
cat <<- EOF
Database config failed. You might want to remove all db files with
'rm -rf /var/lib/mongodb/*' and/or reset the config file by
'cp config/app_config.yml.example config/app_config.yml' before
making a new try. Also, make sure the mongodb server is running
EOF
fi
echo 'To start server: sudo su - diaspora -c "diaspora/script/server -d"'
echo " To stop server: pkill thin; kill \$(cat $pidfile)"