Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorAlec Leamas <leamas.alec@gmail.com>2010-11-01 07:20:33 +0300
committerAlec Leamas <leamas.alec@gmail.com>2010-11-01 07:20:33 +0300
commitd8376b5a8401f510129fe05a55af6c2a3018c5a0 (patch)
tree32ccee69baf0455df2946b80ff98abb00cf10562 /pkg
parentc07771b390ccbd3f3faba574a81bc23bae92450c (diff)
bugfix, refactor funcs
Diffstat (limited to 'pkg')
-rwxr-xr-xpkg/bootstrap-fedora-diaspora.sh122
-rw-r--r--pkg/source/funcs.sh31
2 files changed, 118 insertions, 35 deletions
diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh
index 84352f12d..67ba40fc2 100755
--- a/pkg/bootstrap-fedora-diaspora.sh
+++ b/pkg/bootstrap-fedora-diaspora.sh
@@ -1,48 +1,102 @@
#!/bin/bash
+#
+# Install diaspora, its dependencies and start.
+#
+# Usage: bootstrap-fedora-diaspora.sh [external hostname]
+#
+# Must run as root
-export DIASPORADIR=`pwd`
+arg_hostname="$1"
-echo "####"
-echo "Installing build deps ..."
-echo "####"
-sleep 3
-su -c "yum install git bison svn autoconf sqlite-devel gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel ImageMagick git rubygems libxslt libxslt-devel libxml2 libxml2-devel openssl-devel"
+. source/funcs.sh
-echo "####"
-echo "Installing RVM ..."
-echo "####"
-sleep 3
+test $UID = "0" || {
+ echo "You need to be root to do this, giving up"
+ exit 2
+}
-mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
+yum install -y git bison svn autoconf sqlite-devel gcc-c++ patch \
+ readline-devel zlib-devel libyaml-devel libffi-devel \
+ ImageMagick git rubygems libxslt-devel libxml2-devel \
+ openssl-devel mongodb-server wget openssh-clients
-echo "####"
-echo "Installing RVM into bashrc and sourcing bash ..."
-echo "####"
-sleep 3
+getent group diaspora >/dev/null || groupadd diaspora
+getent passwd diaspora >/dev/null || {
+ useradd -g diaspora -s /bin/bash -m diaspora
+ echo "Created user diaspora"
+}
-if [[ `grep -l "rvm/scripts/rvm" $HOME/.bashrc | wc -l` -eq 0 ]]; then
- echo 'if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi' >> $HOME/.bashrc
+su - diaspora <<EOF
+
+set -x
+ [ -e "\$HOME/.rvm/scripts/rvm" ] || {
+ echo '#### Installing rvm ####'
+ wget http://rvm.beginrescueend.com/releases/rvm-install-head
+ bash < rvm-install-head && rm rvm-install-head
+ if [[ -s "\$HOME/.rvm/scripts/rvm" ]]; then
+ . "\$HOME/.rvm/scripts/rvm"
+ else
+ echo "Error: rvm installation failed";
+ exit 1;
+ fi
+ touch \$HOME/.bashrc
+ grep -q "rvm/scripts/rvm" \$HOME/.bashrc || {
+ echo '[[ -s "\$HOME/.rvm/scripts/rvm" ]] && \
+ source "\$HOME/.rvm/scripts/rvm"' \
+ >> \$HOME/.bashrc
+ }
+}
+
+source \$HOME/.bashrc
+
+[ -d .ssh ] || {
+ ssh-keygen -q
+ echo "StrictHostKeyChecking no" > .ssh/config
+ chmod 600 .ssh/config
+}
+
+ruby=\$(which ruby) || ruby=""
+
+if [[ -z "\$ruby" || ("\${ruby:0:4}" == "/usr") ]]; then
+ echo '#### Installing ruby (will take forever) ... ####'
+ rvm install ruby-1.8.7-p302
+ rvm --default ruby-1.8.7
+
+ echo "#### Installing bundler ... ####"
+ gem install bundler
fi
-source $HOME/.bashrc
-echo "####"
-echo "Installing ruby (will take forever) ..."
-echo "####"
-sleep 3
+echo '### Clone diapora, install bundle. ###'
+git clone git@github.com:diaspora/diaspora.git
+cd diaspora
+bundle install
+
+#Configure diaspora
-rvm install ruby-1.8.7-p302
-rvm --default ruby-1.8.7
+source pkg/source/funcs.sh
+init_appconfig config/app_config.yml "\$arg_hostname"
+
+# Install DB setup
+echo "Setting up DB..."
+if bundle exec rake db:seed:dev ; then
+ cat <<- EOM
+ DB ready. Login -> tom and password -> evankorth.
+ More details ./diaspora/db/seeds/tom.rb. and ./diaspora/db/seeds/dev.rb.
+ EOM
+else
+ cat <<- EOM
+ 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
+ e. g., by running 'service mongodb status'.
+ EOM
+fi
-echo "####"
-echo "Installing bundler ..."
-echo "####"
-sleep 3
+# Run appserver
+echo "Starting server"
+script/server
-gem install bundler
+EOF
-echo "####"
-echo "Installing deps with bundle ..."
-echo "####"
-sleep 3
-pushd $DIASPORADIR && bundle install && popd
diff --git a/pkg/source/funcs.sh b/pkg/source/funcs.sh
index bc9edd862..8fb0ee937 100644
--- a/pkg/source/funcs.sh
+++ b/pkg/source/funcs.sh
@@ -59,7 +59,7 @@ function checkout()
git clone --quiet $GIT_REPO;
(
cd diaspora;
- git checkout Gemfile
+ git checkout Gemfile Gemfile.lock
git remote add upstream \
git://github.com/diaspora/diaspora.git
for p in ../../*.patch; do
@@ -77,3 +77,32 @@ function checkout()
)
}
+function init_appconfig
+# Edit pod_url in hostname
+# Silently uses argumetn if present, else run dialog.
+# Usage: init_appconfig <app_config.yml> [hostname]
+{
+ config=$1
+ arg_hostanme="$2"
+ hostname=$( awk '/pod_url:/ { print $2; exit }' <$config )
+
+ if [ -n "$arg_hostname" ]; then
+ sed -i "/pod_url:/s|$hostname|$arg_hostname|g" $config && \
+ echo "config/app_config.yml updated."
+ return 0
+ 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 &&
+ echo "config/app_config.yml updated."
+ break
+ }
+ done
+ fi
+}
+