Creates two user utility functions
This commit is contained in:
parent
41f1fb4da8
commit
e1bf0b113c
9
docs/kickstart/user/exists?.md
Normal file
9
docs/kickstart/user/exists?.md
Normal file
@ -0,0 +1,9 @@
|
||||
# kickstart.user.exists? user
|
||||
Checks if `user` already exists
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
$ kickstart.user.exists? root || echo Root-less
|
||||
```
|
16
docs/kickstart/user/homeFolder.md
Normal file
16
docs/kickstart/user/homeFolder.md
Normal file
@ -0,0 +1,16 @@
|
||||
# kickstart.user.homeFolder user
|
||||
|
||||
Looks up the `user` home folder on the `/etc/passwd` file.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
$ kickstart.user.homeFolder vagrant
|
||||
/home/vagrant
|
||||
|
||||
$ kickstart.user.homeFolder root
|
||||
/root
|
||||
|
||||
$ kickstart.user.homeFolder no-user-existing
|
||||
|
||||
```
|
@ -1,5 +1,9 @@
|
||||
kickstart.user.exists?() {
|
||||
kickstart.mute id $1
|
||||
}
|
||||
|
||||
kickstart.user.create() {
|
||||
kickstart.mute id $1 || ( useradd -m -s /bin/bash -U -p `openssl passwd -1 $2` $1 )
|
||||
kickstart.user.exists? $1 || ( useradd -m -s /bin/bash -U -p `openssl passwd -1 $2` $1 )
|
||||
}
|
||||
|
||||
kickstart.user.is_on_group() {
|
||||
@ -18,6 +22,10 @@ kickstart.user.remove_group() {
|
||||
usermod -G `kickstart.print_with_separator , ${groups[*]}` $1
|
||||
}
|
||||
|
||||
kickstart.user.homeFolder() {
|
||||
grep ^$1 /etc/passwd | cut -d: -f 6
|
||||
}
|
||||
|
||||
kickstart.user.exec.command.module() {
|
||||
local cur_dir=`pwd`
|
||||
cat <<COMMAND
|
||||
|
Loading…
Reference in New Issue
Block a user