unshare-helper/app/skel/scripts/30_user.sh

12 lines
526 B
Bash

if [ "$UNSHH_ROOT" = "0" ]; then
set +e
unshare --mount --map-root-user -R "$UNSHH_CHROOT" groupadd -g "$UNSHH_GROUP_ID" "$UNSHH_GROUP_NAME"
unshare --mount --map-root-user -R "$UNSHH_CHROOT" useradd -m --uid "$UNSHH_USER_ID" --gid "$UNSHH_GROUP_ID" "$UNSHH_USER_NAME"
set -e
mkdir -p "$UNSHH_CHROOT/home/$UNSHH_USER_NAME/host"
mount --rbind "/home/$UNSHH_USER_NAME" "$UNSHH_CHROOT/home/$UNSHH_USER_NAME/host"
else
mkdir -p "$UNSHH_CHROOT/root/host"
mount --rbind "/home/$UNSHH_USER_NAME" "$UNSHH_CHROOT/root/host"
fi