[DRE-commits] [diaspora-installer] 09/55: add postinst script

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Mon Dec 8 12:41:22 UTC 2014


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository diaspora-installer.

commit ed7eb312735b7a5dee84cadca5f184ed8ebf3514
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Tue Dec 2 17:59:30 2014 +0530

    add postinst script
---
 debian/adduser.sh   |  19 +++++++++
 debian/grantpriv.sh |  14 +++++++
 debian/postinst     | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 142 insertions(+)

diff --git a/debian/adduser.sh b/debian/adduser.sh
new file mode 100755
index 0000000..e8b940d
--- /dev/null
+++ b/debian/adduser.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# add diaspora system user (requires adduser >= 3.34)
+# don't muck around with this unless you KNOW what you're doing
+user=diaspora
+
+echo "Creating/updating $user user account..."
+adduser --system --home /usr/share/$user \
+	--gecos "$user system user" --shell /bin/false \
+	--quiet --disabled-password $user || {
+  # adduser failed. Why?
+  if [ `getent passwd $user|awk -F ':' '{print $3}'` -gt 999 ] >/dev/null ; then
+	echo "Non-system user $user found. I will not overwrite a non-system" >&2
+	echo "user.  Remove the user and reinstall diaspora." >&2
+	exit 1
+  fi
+  # unknown adduser error, simply exit
+  exit 1
+  }
diff --git a/debian/grantpriv.sh b/debian/grantpriv.sh
new file mode 100755
index 0000000..fc172c3
--- /dev/null
+++ b/debian/grantpriv.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+user=diaspora
+
+echo "Allow $user user to create databases..."
+sudo -u postgres psql -c "ALTER USER $user CREATEDB;" || {
+  exit 1 
+  }
+echo "Grant all privileges to $user user..."
+sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE template1 to $user;" || {
+  exit 1
+  }
+
+
diff --git a/debian/postinst b/debian/postinst
new file mode 100755
index 0000000..a0c1ac3
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,109 @@
+#! /bin/sh
+# postinst script for diaspora-installer
+# copied from postinst script for hplip
+# $Id: hplip.postinst,v 1.1 2005/10/15 21:39:04 hmh Exp $
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+
+. /usr/share/debconf/confmodule
+. /usr/share/dbconfig-common/dpkg/postinst.pgsql
+
+dbc_dbname="diaspora_pristine_production"
+dbc_dbuser="diasporapristine"
+
+dbc_go diaspora-installer $@
+
+case "$1" in
+    configure)
+
+	/usr/lib/diaspora-installer/scripts/adduser.sh
+	/usr/lib/diaspora-installer/scripts/grantpriv.sh
+	mkdir -p /var/log/diaspora-pristine
+	chown -R diasporapristine: /usr/share/diaspora-pristine
+	cd /usr/share/diaspora-pristine
+	echo "Installing gems with rubygems (their debian packages have bugs)..."
+# These gems need more work before they can be apt-get
+	if ! gem list backbone-on-rails | grep backbone-on-rails
+		then gem install backbone-on-rails
+	fi
+	
+	if ! gem list handlebars_assets | grep handlebars_assets
+		then gem install handlebars_assets
+	fi
+	
+	if ! gem list rails-timeago | grep rails-timeago
+		then gem install rails-timeago
+	fi
+	
+	if ! gem list foreman | grep foreman
+		then gem install -v=0.62.0 foreman
+	fi
+
+	if ! gem list ^devise$ | grep devise
+		then gem install -v=3.4.1 devise
+	fi
+	
+	if ! gem list rails-assets-jquery-idletimer | grep rails-assets-jquery-idletimer
+		then gem install --source https://rails-assets.org rails-assets-jquery-idletimer
+	fi
+	if ! grep RAILS_ENV /etc/diaspora.conf
+		then echo export RAILS_ENV=production >> /etc/diaspora.conf
+	fi
+
+	if ! grep DB /etc/diaspora.conf 
+		then echo export DB=postgres >> /etc/diaspora.conf
+	fi
+	
+	# source diaspora variables	
+	. /etc/diaspora.conf
+	export ENVIRONMENT_URL=https://${SERVERNAME}
+	echo "Verifying we have all required libraries..."
+	sudo -u diaspora -E bundle install --local
+	echo "Initializing database..."
+	sudo -u diaspora -E bundle exec rake db:create db:schema:load
+	echo "Precompiling assets..."
+	sudo -u diaspora -E bundle exec rake assets:precompile
+	sudo -u diaspora  touch public/source.tar.gz
+	echo "Starting diaspora service..."
+	sudo -u diaspora -E -i nohup ./script/server &
+	echo "Copy $SERVERNAME-bundle.pem and $SERVERNAME.key to /etc/diaspora/ssl"
+	echo "And reload nginx, run # /etc/init.d  nginx reload"
+	echo "visit your pod at $ENVIRONMENT_URL"
+	echo "To stop diaspora, run # killall -9 unicorn_rails foreman sidekiq"
+	echo "To see the service status, run # tail -f /usr/share/diaspora/nohup.out"
+   ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+db_stop
+
+
+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