summarylogtreecommitdiffstats
path: root/openbazaar.install
diff options
context:
space:
mode:
authorM0Rf302015-06-17 16:02:22 +0200
committerM0Rf302015-06-17 16:02:22 +0200
commita89ef894ab9d522936dde06a94abf34db699e7b1 (patch)
tree83d9116b6df1888e59f1ab3e2a9dd90177d466c1 /openbazaar.install
downloadaur-a89ef894ab9d522936dde06a94abf34db699e7b1.tar.gz
Initial import
Diffstat (limited to 'openbazaar.install')
-rw-r--r--openbazaar.install48
1 files changed, 48 insertions, 0 deletions
diff --git a/openbazaar.install b/openbazaar.install
new file mode 100644
index 00000000000..191529222ec
--- /dev/null
+++ b/openbazaar.install
@@ -0,0 +1,48 @@
+usr=openbazaar
+home=/var/lib/openbazaar
+log=/var/lib/openbazaar/logs
+dbdata=obdata
+
+post_install() {
+ _mkuser
+ _mkdbfolder
+ _chown
+}
+
+post_upgrade() {
+ _mkuser
+ _chown
+}
+
+## arg 1: the old package version
+post_remove() {
+ #_rmuser
+ echo "Please remove $home and user $usr manually"
+ echo "WARNING!!!"
+ echo "Be sure to save your db and gpg backup"
+}
+
+_chown() {
+ chown -R $usr:$usr $home $log $home/$dbdata
+}
+
+_mkuser() {
+ getent passwd $usr &>/dev/null || {
+ echo -n "Creating openbazaar user... "
+ grep -E "^openbazaar:" /etc/group >/dev/null || groupadd $usr
+ useradd -m -d $home -g $usr -s /usr/bin/nologin $usr 2>/dev/null
+ echo "done"
+ }
+}
+
+_rmuser() {
+ echo -n "Removing openbazaar user... "
+ userdel -rf $usr 2>/dev/null
+ echo "done"
+}
+
+_mkdbfolder() {
+ echo -n "Creating database folder... "
+ mkdir -p $home/$dbdata
+ echo "done"
+}