rlm@1: #!/bin/bash
rlm@1: # Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de>
rlm@1: # You may do everything with this code except misrepresent its origin.
rlm@1: # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
rlm@1: 
rlm@1: if [ $# -eq 1 ]; then
rlm@1:   set -- "$1" "$1" "$1"
rlm@1: fi
rlm@1: 
rlm@1: if [ $# -ne 3 ]; then
rlm@1:   echo 1>&2
rlm@1:   echo 1>&2 'USAGE 1: install_package <description> <name> <group>'
rlm@1:   echo 1>&2 'USAGE 2: install_package <name>'
rlm@1:   echo 1>&2
rlm@1:   echo 1>&2 'Creates a new package user called <name> with primary group <group>'
rlm@1:   echo 1>&2 'and description <description>.'
rlm@1:   echo 1>&2 'If the user account has been created successfully, `su - <name>'"'"' will be'
rlm@1:   echo 1>&2 'executed so that you can start working with the new account right away.'
rlm@1:   echo 1>&2
rlm@1:   echo 1>&2 '<description> needs to be a valid string for the /etc/passwd description'
rlm@1:   echo 1>&2 '  field. This means, among other things, that it must not contain ":".'
rlm@1:   echo 1>&2 '  Don'"'"'t forget to properly quote <description> if it contains spaces or'
rlm@1:   echo 1>&2 '  other characters interpreted by the shell!'
rlm@1:   echo 1>&2
rlm@1:   echo 1>&2 'This script leaves the actual creation of the new account to the'
rlm@1:   echo 1>&2 'add_package_user script. Check out its documentation for details.'
rlm@1:   echo 1>&2
rlm@1:   echo 1>&2 'When called with just one argument, that argument will be used as'
rlm@1:   echo 1>&2 '<name>, <description> and <group>'
rlm@1:   exit 1
rlm@1: fi
rlm@1: 
rlm@1: if [ $UID -ne 0 ]; then echo Please run this script as root. ; exit 1; fi
rlm@1: add_package_user "${1}" $2 10000 20000 $3 10000 20000 || exit 1
rlm@1: su - $2