New Script -- run-parts
[pkgusr] / usr / sbin / install_package
1 #!/bin/bash
2 # Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de>
3 # You may do everything with this code except misrepresent its origin.
4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
5
6 if [ $# -ne 3 ]; then
7     echo 1>&2
8     echo 1>&2 'USAGE: install_package <description> <name> <group>'
9     echo 1>&2
10     echo 1>&2 'Creates a new package user called <name> with primary group <group>'
11     echo 1>&2 'and description <description>.'
12     echo 1>&2 'If the user account has been created successfully, `su <name>'"'"' will be'
13     echo 1>&2 'executed so that you can start working with the new account right away.'
14     echo 1>&2
15     echo 1>&2 '<description> needs to be a valid string for the /etc/passwd description'
16     echo 1>&2 '  field. This means, among other things, that it must not contain ":".'
17     echo 1>&2 '  Don'"'"'t forget to properly quote <description> if it contains spaces or'
18     echo 1>&2 '  other characters interpreted by the shell!'
19     echo 1>&2
20     echo 1>&2 'This script leaves the actual creation of the new account to the'
21     echo 1>&2 'add_package_user script. Check out its documentation for details.'
22     echo 1>&2
23     exit 1
24 fi
25
26 if [ $UID -ne 0 ]; then
27     echo Please run this script as root.
28     exit 1
29 fi
30
31 add_package_user "${1}" $2 10000 20000 $3 10000 20000 || exit 1
32 rm -f /var/mail/$2
33 su $2