File: useradd

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (181 lines) | stat: -rw-r--r-- 6,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# (C) 2011 magicant

# Completion script for the "useradd" command.
# Supports shadow tool suite 4.1.4.2, OpenBSD 4.9, NetBSD 5.0, SunOS 5.11,
# HP-UX 11i v3.

function completion/useradd {

        typeset type="$(uname 2>/dev/null)"
        case $type in
                (Linux) typeset long=true ;;
                (*)     typeset long= ;;
        esac

        typeset OPTIONS ARGOPT PREFIX
        OPTIONS=( #>#
        "b: ${long:+--base-dir:}; specify the directory the home directory is created in"
        "c: ${long:+--comment:}; specify a comment (typically the user's full name)"
        "d: ${long:+--home:}; specify the home directory"
        "D ${long:+--defaults}; print or show the default settings"
        "e: ${long:+--expiredate:}; specify the date the account expires on"
        "f: ${long:+--inactive:}; specify the date the password expires on"
        "G: ${long:+--groups:}; specify supplementary groups"
        "g: ${long:+--group:}; specify the group"
        "k: ${long:+--skel:}; specify the skeleton directory"
        "m ${long:+--create-home}; create the home directory"
        "o ${long:+--non-unique}; allow assigning one user ID to more than one user name"
        "s: ${long:+--shell:}; specify the login shell"
        "u: ${long:+--uid:}; specify the user ID number"
        ) #<#

        case $type in
        (Linux|SunOS)
                OPTIONS=("$OPTIONS" #>#
                "K: ${long:+--key:}; specify an option to override the default"
                ) #<#
                ;;
        esac
        case $type in
        (SunOS)
                OPTIONS=("$OPTIONS" #>#
                "p:; specify a project"
                ) #<#
                ;;
        (*)
                OPTIONS=("$OPTIONS" #>#
                "p: ${long:+--password:}; specify the encrypted password"
                ) #<#
                ;;
        esac
        case $type in
        (Linux)
                OPTIONS=("$OPTIONS" #>#
                "h --help; print help"
                "l --no-log-init; don't add the user to the lastlog and faillog databases"
                "M; don't create the home directory"
                "N --no-user-group; don't create the user's own group"
                "r --system; create a system account"
                "U --user-group; create the user's own group"
                "Z: --selinux-user:; specify the SELinux user"
                ) #<#
                ;;
        (*BSD)
                OPTIONS=("$OPTIONS" #>#
                "L:; specify the login class"
                "v; print operations that are executed"
                ) #<#
                case $type in
                (OpenBSD)
                        OPTIONS=("$OPTIONS" #>#
                        "r:; specify the integer range from which the new user ID is chosen"
                        ) #<#
                        ;;
                (NetBSD)
                        OPTIONS=("$OPTIONS" #>#
                        "F; force the user to change the password on next login"
                        "M:; specify the permission of the home directory"
                        "S; allow samba user names with a trailing dollar sign to be added to the system"
                        ) #<#
                        ;;
                esac
                ;;
        (SunOS)
                OPTIONS=("$OPTIONS" #>#
                "A:; specify authorizations"
                "P:; specify execution profiles"
                "R:; specify execution roles"
                ) #<#
                ;;
        (HP-UX)
                OPTIONS=("$OPTIONS" #>#
                "i; inherit the existing home directory"
                "O:; specify if the -o option is enabled by default"
                "r:; specify if the existing home directory's permission is reset"
                "S:; specify the alternate password file of NIS"
                "t:; specify the template file containing default settings"
                ) #<#
                ;;
        esac

        command -f completion//parseoptions ${long:+-es}
        case $ARGOPT in
        (-)
                command -f completion//completeoptions
                ;;
        ([bdk]|--base-dir|--home|--skel)
                complete -T -P "$PREFIX" -S / -d
                ;;
        (A)
                # TODO
                ;;
#       (c|--comment)
#               ;;
        (e|--expiredate)
                #TODO
        (f|--inactive)
                #TODO
                ;;
        (G|--groups)
                PREFIX="${TARGETWORD%"${${TARGETWORD#"$PREFIX"}##*,}"}"
                complete -T -P "$PREFIX" -S , -g
                ;;
        (g|--group)
                complete -P "$PREFIX" -g
                ;;
        (K|--key)
                # TODO
                ;;
        (L)
                # TODO
                ;;
#       (M)
#               ;;
        (O)
                complete -P "$PREFIX" -D "yes" yes
                complete -P "$PREFIX" -D "no" yes
                ;;
        (P)
                # TODO
                ;;
        (p)
                # TODO
                ;;
        (R)
                # TODO
                ;;
        (r)
                case $type in
                (HP-UX)
                        complete -P "$PREFIX" -D "yes" yes
                        complete -P "$PREFIX" -D "no" yes
                        ;;
                esac
                ;;
        (S)
                # TODO
                ;;
        (s|--shell)
                complete -P "$PREFIX" -- $(sed -e 's/#.*//' /etc/shells 2>/dev/null) ||
                {
                        complete -T -P "$PREFIX" -S / -d
                        complete -P "$PREFIX" --executable-file
                }
                ;;
        (t)
                complete -P "$PREFIX" -f
                ;;
#       (u|--uid)
#               ;;
        (Z|--selinux-user)
                # TODO
                ;;
        ('')
                complete -u
                ;;
        esac

}


# vim: set ft=sh ts=8 sts=8 sw=8 et: