1#!/bin/sh 2# preinst script for bareos 3# 4# see: dh_installdeb(1) 5 6set -e 7 8# summary of how this script can be called: 9# * <new-preinst> `install' 10# * <new-preinst> `install' <old-version> 11# * <new-preinst> `upgrade' <old-version> 12# * <old-preinst> `abort-upgrade' <new-version> 13# for details, see http://www.debian.org/doc/debian-policy/ or 14# the debian-policy package 15 16daemon_user=bareos-regress 17daemon_group=bareos-regress 18 19WORKING_DIR="@working_dir@/bareos-regress" 20 21 22create_group() 23{ 24 [ -z "$1" ] && return 25 # creating group if he isn't already there. 26 # use addgroup instead of groupadd, 27 # because "addgroup" uses the next available number, 28 # while "groupadd" uses uses GID_MIN -1 (999) 29 getent group $1 > /dev/null || addgroup -q --system $1 30} 31 32create_user() 33{ 34 [ -z "$1" ] && return 35 # creating user if he isn't already there. 36 # use adduser instead of useradd, 37 # because "adduser" uses the next available number, 38 # while "useradd" uses uses UID_MIN -1 (999) 39 getent passwd $1 > /dev/null || adduser -q --system --ingroup $daemon_group --home "$WORKING_DIR" --no-create-home --gecos "$1" --shell /bin/bash $1 40} 41 42 43case "$1" in 44 install|upgrade) 45 create_group $daemon_group 46 create_user $daemon_user 47 ;; 48 49 abort-upgrade) 50 ;; 51 52 *) 53 echo "preinst called with unknown argument \`$1'" >&2 54 exit 1 55 ;; 56esac 57 58# dh_installdeb will replace this with shell code automatically 59# generated by other debhelper scripts. 60 61#DEBHELPER# 62 63exit 0 64