bugfix, refactor funcs
This commit is contained in:
parent
c07771b390
commit
d8376b5a84
2 changed files with 118 additions and 35 deletions
|
|
@ -1,48 +1,102 @@
|
||||||
#!/bin/bash
|
#!/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 "####"
|
. source/funcs.sh
|
||||||
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"
|
|
||||||
|
|
||||||
echo "####"
|
test $UID = "0" || {
|
||||||
echo "Installing RVM ..."
|
echo "You need to be root to do this, giving up"
|
||||||
echo "####"
|
exit 2
|
||||||
sleep 3
|
}
|
||||||
|
|
||||||
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 "####"
|
getent group diaspora >/dev/null || groupadd diaspora
|
||||||
echo "Installing RVM into bashrc and sourcing bash ..."
|
getent passwd diaspora >/dev/null || {
|
||||||
echo "####"
|
useradd -g diaspora -s /bin/bash -m diaspora
|
||||||
sleep 3
|
echo "Created user diaspora"
|
||||||
|
}
|
||||||
|
|
||||||
if [[ `grep -l "rvm/scripts/rvm" $HOME/.bashrc | wc -l` -eq 0 ]]; then
|
su - diaspora <<EOF
|
||||||
echo 'if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi' >> $HOME/.bashrc
|
|
||||||
|
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
|
fi
|
||||||
source $HOME/.bashrc
|
touch \$HOME/.bashrc
|
||||||
|
grep -q "rvm/scripts/rvm" \$HOME/.bashrc || {
|
||||||
|
echo '[[ -s "\$HOME/.rvm/scripts/rvm" ]] && \
|
||||||
|
source "\$HOME/.rvm/scripts/rvm"' \
|
||||||
|
>> \$HOME/.bashrc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
echo "####"
|
source \$HOME/.bashrc
|
||||||
echo "Installing ruby (will take forever) ..."
|
|
||||||
echo "####"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
|
[ -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 install ruby-1.8.7-p302
|
||||||
rvm --default ruby-1.8.7
|
rvm --default ruby-1.8.7
|
||||||
|
|
||||||
echo "####"
|
echo "#### Installing bundler ... ####"
|
||||||
echo "Installing bundler ..."
|
|
||||||
echo "####"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
gem install bundler
|
gem install bundler
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '### Clone diapora, install bundle. ###'
|
||||||
|
git clone git@github.com:diaspora/diaspora.git
|
||||||
|
cd diaspora
|
||||||
|
bundle install
|
||||||
|
|
||||||
|
#Configure diaspora
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Run appserver
|
||||||
|
echo "Starting server"
|
||||||
|
script/server
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
echo "####"
|
|
||||||
echo "Installing deps with bundle ..."
|
|
||||||
echo "####"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
pushd $DIASPORADIR && bundle install && popd
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ function checkout()
|
||||||
git clone --quiet $GIT_REPO;
|
git clone --quiet $GIT_REPO;
|
||||||
(
|
(
|
||||||
cd diaspora;
|
cd diaspora;
|
||||||
git checkout Gemfile
|
git checkout Gemfile Gemfile.lock
|
||||||
git remote add upstream \
|
git remote add upstream \
|
||||||
git://github.com/diaspora/diaspora.git
|
git://github.com/diaspora/diaspora.git
|
||||||
for p in ../../*.patch; do
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue