handle host user being root or a default debian user/group
This commit is contained in:
parent
4eff8b258b
commit
108089eac2
|
@ -6,15 +6,23 @@ gid=${GID?}
|
||||||
user=${USER:-"build"}
|
user=${USER:-"build"}
|
||||||
export HOME="/home/${user}"
|
export HOME="/home/${user}"
|
||||||
|
|
||||||
groupdel dialout
|
# If running user is not root, make a custom user/group
|
||||||
groupadd -g "$gid" "${user}"
|
[ "$uid" != "0" ] && {
|
||||||
useradd \
|
getent group "$gid" && groupdel "$gid"
|
||||||
-g "$gid" \
|
getent passwd "$uid" && userdel "$uid"
|
||||||
-G sudo \
|
groupadd -g "$gid" "${user}"
|
||||||
-u "$uid" \
|
useradd \
|
||||||
-d "/home/${user}" \
|
-g "$gid" \
|
||||||
-s /bin/bash \
|
-G sudo \
|
||||||
"${user}"
|
-u "$uid" \
|
||||||
|
-d "/home/${user}" \
|
||||||
|
-s /bin/bash \
|
||||||
|
"${user}"
|
||||||
|
}
|
||||||
|
|
||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
setpriv --reuid="$uid" --regid="$gid" --init-groups "$@"
|
|
||||||
|
# If running user is not root, pivot to running user
|
||||||
|
[ "$uid" != "0" ] && {
|
||||||
|
setpriv --reuid="$uid" --regid="$gid" --init-groups "$@"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue