view previous-work/more_control_helpers/sbin/install_package @ 36:d66d34065dd9 tip

better less.
author Robert McIntyre <rlm@mit.edu>
date Sun, 19 May 2013 14:40:32 -0400
parents d6bef198ae71
children
line wrap: on
line source
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!
6 if [ $# -eq 1 ]; then
7 set -- "$1" "$1" "$1"
8 fi
10 if [ $# -ne 3 ]; then
11 echo 1>&2
12 echo 1>&2 'USAGE 1: install_package <description> <name> <group>'
13 echo 1>&2 'USAGE 2: install_package <name>'
14 echo 1>&2
15 echo 1>&2 'Creates a new package user called <name> with primary group <group>'
16 echo 1>&2 'and description <description>.'
17 echo 1>&2 'If the user account has been created successfully, `su - <name>'"'"' will be'
18 echo 1>&2 'executed so that you can start working with the new account right away.'
19 echo 1>&2
20 echo 1>&2 '<description> needs to be a valid string for the /etc/passwd description'
21 echo 1>&2 ' field. This means, among other things, that it must not contain ":".'
22 echo 1>&2 ' Don'"'"'t forget to properly quote <description> if it contains spaces or'
23 echo 1>&2 ' other characters interpreted by the shell!'
24 echo 1>&2
25 echo 1>&2 'This script leaves the actual creation of the new account to the'
26 echo 1>&2 'add_package_user script. Check out its documentation for details.'
27 echo 1>&2
28 echo 1>&2 'When called with just one argument, that argument will be used as'
29 echo 1>&2 '<name>, <description> and <group>'
30 exit 1
31 fi
33 if [ $UID -ne 0 ]; then echo Please run this script as root. ; exit 1; fi
34 add_package_user "${1}" $2 10000 20000 $3 10000 20000 || exit 1
35 su - $2