osi-tools/osi-mk.d/testuser.sh

24 lines
550 B
Bash
Raw Normal View History

2018-08-06 00:09:42 +00:00
#!/hint/bash
2018-08-06 01:49:45 +00:00
post_install+=(01:testuser:early)
testuser:early() {
2018-08-06 00:09:42 +00:00
local arg_mountpoint=$1
2018-08-12 21:56:14 +00:00
if ! grep -q ^testuser: -- "$arg_mountpoint/etc/passwd"; then
chroot "$arg_mountpoint" useradd \
--gid=users \
--comment='Test User' \
--create-home \
testuser
fi
2018-08-06 01:49:45 +00:00
}
2018-08-06 00:09:42 +00:00
post_install+=(90:testuser:late)
2018-08-06 01:49:45 +00:00
testuser:late() {
local arg_mountpoint=$1
2018-08-06 00:09:42 +00:00
2018-08-06 01:49:45 +00:00
local uidgid
uidgid=$(awk -v FS=: -v OFS=: '$1 == "testuser" { print $3, $4 }' < "${arg_mountpoint}/etc/passwd")
chown -R -- "$uidgid" "${arg_mountpoint}/home/testuser"
2018-08-06 00:09:42 +00:00
}