deflogin: Added SPECIAL_USER

Variable SPECIAL_USER must have the following format:
user:group:uid:gid:homedir:shell
Example:
@$(call set,SPEC_USER,user:user:500:500:/home/user:/bin/bash)
This commit is contained in:
Anton Midyukov 2020-10-20 10:30:35 +07:00
parent 1d6f12bf59
commit c00f508b84
4 changed files with 15 additions and 2 deletions

View File

@ -58,7 +58,8 @@ vm/regular-jeos-systemd: vm/systemd-net \
mixin/regular-vm-jeos mixin/vm-archdep
@$(call add,THE_PACKAGES,glibc-locales)
vm/regular-jeos-sysv: vm/net mixin/regular-vm-jeos mixin/vm-archdep +power; @:
vm/regular-jeos-sysv: vm/net mixin/regular-vm-jeos mixin/vm-archdep +power
@$(call set,SPEC_USER,officer:officer:64:64:/bin/bash)
vm/regular-builder: vm/regular-jeos-sysv mixin/regular-builder
@$(call set,VM_SIZE,10737418240)

View File

@ -62,6 +62,7 @@ distro/.regular-jeos-base: distro/.regular-bare \
@$(call add,THE_BRANDING,alterator) # just to be cleaned up later on
@$(call add,THE_PACKAGES,apt basesystem dhcpcd vim-console su agetty)
@$(call add,THE_LISTS,openssh)
@$(call set,SPEC_USER,officer:officer:64:64:/bin/bash)
# ...and for somewhat bare distros
distro/.regular-jeos: distro/.regular-jeos-base use/stage2/kms \

View File

@ -6,6 +6,7 @@ use/deflogin:
@$(call xport,ROOTPW)
@$(call xport,USERS)
@$(call xport,GROUPS)
@$(call xport,SPEC_USER)
# some presets
# USERS variable chunk format is "login:passwd:admin:sudo"

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -x
# add regular user(s) assigning passwords and attributes of power
# NB: care that the utilities exist; shadow-utils is warranted
@ -34,3 +34,13 @@ set_sudo() {
[ -z "$admin" ] || set_admin "$login"
[ -z "$sudo" ] || set_sudo "$login"
done
# create special user
[ -z "$GLOBAL_SPEC_USER" ] ||
echo "$GLOBAL_SPEC_USER" \
| tr ' ' '\n' \
| while IFS=':' read login group uid gid homedir shell; do
groupadd -g $gid $group >/dev/null 2>&1 || :
useradd -g $gid -u $uid -d $homedir -s $shell $login >/dev/null 2>&1 || :
usermod -G $group $login || :
done