[DRE-commits] [diaspora] 132/257: add scripts to create user and grant db privileges
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Sun Apr 12 14:17:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository diaspora.
commit 3047b08621012a28ebe6cbd331fdd5c962fa70f6
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Mon Nov 24 02:40:39 2014 +0530
add scripts to create user and grant db privileges
---
debian/adduser.sh | 19 +++++++++++++++++++
debian/grantpriv.sh | 14 ++++++++++++++
debian/install | 2 ++
3 files changed, 35 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/install b/debian/install
index e2e2e32..cac1628 100644
--- a/debian/install
+++ b/debian/install
@@ -21,3 +21,5 @@ redis-integration2.conf usr/share/diaspora
script usr/share/diaspora
spec usr/share/diaspora
vendor usr/share/diaspora
+debian/adduser.sh usr/lib/diaspora/scripts
+debian/grantpriv.sh usr/lib/diaspora/scripts
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/diaspora.git
More information about the Pkg-ruby-extras-commits
mailing list