96725c352bcb86de98afa603c47cd73ba5dfaa3f
[invirt/packages/invirt-dev.git] / debian / invirt-dev.postinst
1 #!/bin/sh
2 set -e
3
4 #DEBHELPER#
5
6 case "$1" in
7     configure)
8         if [ -z "$2" ]; then
9             adduser --system repository
10             addgroup --system repo
11             
12             # Clean up the old sudoers block, then add it back
13             perl -i.bak -ne 's%^### (BEGIN|END) invirt-dev\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
14             
15             cat >>/etc/sudoers <<EOF
16 ### BEGIN invirt-dev
17 %repo   ALL=(repository)        ALWAYS_SET_HOME,NOPASSWD: /usr/bin/reprepro
18 ### END invirt-dev
19 EOF
20             echo "-----"
21             echo "invirt-dev: run"
22             echo "  adduser --disabled-password \$user"
23             echo "  adduser \$user repo"
24             echo "  adduser \$user sbuild"
25             echo "to make individual users that will build packages."
26             echo "-----"
27         fi
28     ;;
29
30     abort-upgrade|abort-remove|abort-deconfigure)
31     ;;
32
33     *)
34         echo "postinst called with unknown argument \`$1'" >&2
35         exit 1
36     ;;
37 esac