Skip to content

Commit 7daf7f1

Browse files
update user ssetup functions & fix some (4)
1 parent 48eba62 commit 7daf7f1

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

plugins/envsetup

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,28 @@ do_mount() {
7979
fi
8080
}
8181

82+
do_unmount()
83+
{
84+
local chroot_dir=$1
85+
points="$chroot_dir/dev $chroot_dir/sys $chroot_dir/proc"
86+
see_for_directory "$points"
87+
if is_mounted "$chroot_dir/dev" >>/dev/null; then
88+
shout "unmounting: $chroot_dir/dev"
89+
$SUDO umount "$chroot_dir"/dev/pts
90+
$SUDO umount "$chroot_dir"/dev
91+
fi
92+
93+
if is_mounted "$chroot_dir"/proc >>/dev/null; then
94+
shout "unmounting: $chroot_dir/proc"
95+
$SUDO umount $chroot_dir/proc
96+
fi
97+
98+
if is_mounted "$chroot_dir"/sys >>/dev/null; then
99+
shout "unmounting: $chroot_dir/sys"
100+
$SUDO umount "$chroot_dir"/sys
101+
fi
102+
}
103+
82104
is_mounted() {
83105
local chroot_dir=$1
84106
if [ -d "$chroot_dir" ]; then
@@ -260,7 +282,6 @@ do_debootstrap() {
260282
do_second_stage "$target_dir" "$arch"
261283

262284
install_pkg "pv \
263-
awk \
264285
bzip2 \
265286
lz4 \
266287
gzip \
@@ -312,12 +333,12 @@ do_debootstrap() {
312333
fi
313334
}
314335

315-
setup_user_env() {
316-
export _user
317-
export _passwd
318-
export _pass_cmd
336+
setup_user()
337+
{
338+
default_uid=1001
339+
default_gid=1001
319340

320-
if [ -n "$FS_USER" ]; then
341+
if [ -n "$FS_USER" ]; then
321342
_user=$FS_USER
322343
else
323344
warn "username not set in \$\"FS_USER\""
@@ -327,22 +348,11 @@ setup_user_env() {
327348

328349
if [ -n "$FS_PASSWD" ]; then
329350
_passwd=$FS_PASSWD
330-
_pass_cmd="-p $(openssl passwd -1 $_passwd)"
331-
elif [ -z "$FS_USER" ]; then
351+
else
332352
_passwd="fs-cook-${RANDOM}"
333353
warn "password not set in \$\"FS_PASSWD\""
334354
msg "defaulting to $_passwd"
335-
_pass_cmd="-p $(openssl passwd -1 $_passwd)"
336355
fi
337-
338-
}
339-
340-
setup_user()
341-
{
342-
setup_user_env
343-
344-
default_uid=1001
345-
default_gid=1001
346356

347357
# SUDO setup
348358
if ! $ENABLE_PASSWD; then
@@ -372,7 +382,8 @@ setup_user()
372382

373383
# create user
374384
CMD="useradd -m \
375-
$_pass_cmd -G sudo \
385+
-p $(openssl passwd -1 $_passwd) \
386+
-G sudo \
376387
-d /home/$_user \
377388
-g $gid_val \
378389
-u $uid_val \

0 commit comments

Comments
 (0)