[DRE-commits] [diaspora-installer] 03/13: add preinst for backup and sidekiq
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Tue May 19 13:29:48 UTC 2015
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch 04x-05x_update
in repository diaspora-installer.
commit 764276a7b6399c47c394697c5d8c1571a79512e4
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Tue May 19 18:51:50 2015 +0530
add preinst for backup and sidekiq
---
debian/preinst | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/debian/preinst b/debian/preinst
new file mode 100755
index 0000000..205bede
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,81 @@
+#! /bin/sh
+set -e
+
+# Read variables
+. /etc/diaspora/diaspora-common.conf
+. ${diaspora_conf}
+
+# Check if PostgreSQL database diaspora_production exist
+if su diaspora -s /bin/sh -c "psql diaspora_production -c ''"
+then
+ echo "You already have a PostgreSQL database named 'diaspora_production'..."
+ export dbexist='true'
+fi
+
+case "$1" in
+ upgrade)
+ if ! test -z $dbexist
+ then
+ # Show current version of package
+ installed_diaspora_version=`echo $2|cut -d+ -f1`
+ installed_diaspora_major_version=`echo ${installed_diaspora_version} |cut -d. -f1,2`
+ if test $(echo "${installed_diaspora_major_version} < 0.5" |bc) -eq 1
+ then
+ echo "Stopping diaspora..."
+ invoke-rc.d diaspora stop
+ cd ${diaspora_home}
+ . ${diaspora_conf}
+ echo "Run bundle install..."
+ su diaspora -s /bin/sh -c 'bundle install'
+ echo "Run sidekiq for 5 minutes..."
+ echo "Current time is `date`..."
+ su diaspora -s /bin/sh -c 'bundle exec sidekiq&'
+ sleep 1m
+ echo "Stop sidekiq..."
+ su diaspora -s /bin/sh -c 'pkill -u diaspora -f sidekiq' || true
+ fi
+
+ # Backup the previous version
+ # Just keep the config and vendor/bundle
+ backup() {
+ mv ${diaspora_home}/config ${diaspora_home}-config
+ mv ${diaspora_home}/vendor/bundle ${diaspora_home}-vendor-bundle
+ mv ${diaspora_home}/.bundle ${diaspora_home}.bundle
+ mv ${diaspora_home} ${diaspora_home}-backup.`openssl rand -hex 4`
+ mkdir ${diaspora_home}
+ mkdir ${diaspora_home}/vendor
+ cp -r ${diaspora_home}-config ${diaspora_home}/config
+ cp -r ${diaspora_home}-vendor-bundle ${diaspora_home}/vendor/bundle
+ cp -r ${diaspora_home}.bundle ${diaspora_home}/.bundle
+ chown ${diaspora_user}: -R ${diaspora_home}
+ ln -s /usr/bin ${diaspora_home}
+ }
+ backup || true
+ fi
+ ;;
+ install)
+ if ! test -z $dbexist
+ then
+ # new install should not see existing database
+ echo ""
+ echo "========================================================================="
+ echo "Aborting installation..."
+ echo "You may drop the database and try reinstalling"
+ echo "Command to drop the database: su postgres -c 'dropdb diaspora_production'"
+ echo "WARNING: This will remove all the data in diaspora_production database."
+ echo "========================================================================="
+ echo ""
+ exit 1
+ fi
+ ;;
+ abort-upgrade|install)
+ ;;
+ *)
+ echo "preinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/diaspora-installer.git
More information about the Pkg-ruby-extras-commits
mailing list