|
2 | 2 |
|
3 | 3 | ################################ |
4 | 4 | # MIT License |
5 | | -# |
| 5 | +# |
6 | 6 | # Copyright (c) 2021 RandomCoderOrg,Saicharankandkuri <[email protected]> |
7 | | -# |
| 7 | +# |
8 | 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | 9 | # of this software and associated documentation files (the "Software"), to deal |
10 | 10 | # in the Software without restriction, including without limitation the rights |
|
14 | 14 | # |
15 | 15 | # The above copyright notice and this permission notice shall be included in all |
16 | 16 | # copies or substantial portions of the Software. |
17 | | -# |
| 17 | +# |
18 | 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
@@ -61,6 +61,12 @@ msg() { |
61 | 61 | } |
62 | 62 | # lshout () { echo -e "${*}";:; } |
63 | 63 |
|
| 64 | +trim_quotes() { |
| 65 | + # Usage: trim_quotes "string" |
| 66 | + : "${1//\'}" |
| 67 | + printf '%s\n' "${_//\"}" |
| 68 | +} |
| 69 | + |
64 | 70 | do_mount() { |
65 | 71 | local chroot_dir=$1 |
66 | 72 | points="$chroot_dir/dev $chroot_dir/sys $chroot_dir/proc" |
@@ -220,7 +226,7 @@ includes_packages() { |
220 | 226 | shout "$x includes processed " |
221 | 227 | } |
222 | 228 |
|
223 | | -do_debootstrap() { |
| 229 | +do_build() { |
224 | 230 | export target_dir="$1" |
225 | 231 | export arch="$2" |
226 | 232 |
|
@@ -298,70 +304,6 @@ do_debootstrap() { |
298 | 304 | fi |
299 | 305 | } |
300 | 306 |
|
301 | | -setup_user() |
302 | | -{ |
303 | | - default_uid=1001 |
304 | | - default_gid=1001 |
305 | | - |
306 | | - if [ -n "$FS_USER" ]; then |
307 | | - _user=$FS_USER |
308 | | - else |
309 | | - warn "username not set in \$\"FS_USER\"" |
310 | | - msg "defaulting to ${USER}01" |
311 | | - _user="${USER}01" |
312 | | - fi |
313 | | - |
314 | | - if [ -n "$FS_PASSWD" ]; then |
315 | | - _passwd=$FS_PASSWD |
316 | | - else |
317 | | - _passwd="fs-cook-${RANDOM}" |
318 | | - warn "password not set in \$\"FS_PASSWD\"" |
319 | | - msg "defaulting to $_passwd" |
320 | | - fi |
321 | | - |
322 | | - # SUDO setup |
323 | | - if ! $ENABLE_PASSWD; then |
324 | | - pass_set_cmd="echo $_user ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$_user;chmod 0440 /etc/sudoers.d/$_user" |
325 | | - else |
326 | | - pass_set_cmd="echo $_user ALL=\(root\) ALL > /etc/sudoers.d/$_user;chmod 0440 /etc/sudoers.d/$_user" |
327 | | - fi |
328 | | - |
329 | | - # UID setup |
330 | | - if [ -n "$FS_UID" ]; then |
331 | | - uid_val="$FS_UID" |
332 | | - else |
333 | | - uid_val="$default_uid" |
334 | | - fi |
335 | | - |
336 | | - # GID setup |
337 | | - if [ -n "$FS_GID" ]; then |
338 | | - gid_val="$FS_GID" |
339 | | - else |
340 | | - gid_val="$default_gid" |
341 | | - fi |
342 | | - |
343 | | - shout "setting up $_user..." |
344 | | - |
345 | | - # create user group |
346 | | - run_cmd "groupadd --gid 1001 $_user" |
347 | | - |
348 | | - # create user |
349 | | - CMD="useradd -m \ |
350 | | - -p \$\(openssl passwd -1 $_passwd\) \ |
351 | | - -G sudo \ |
352 | | - -d /home/$_user \ |
353 | | - -g $gid_val \ |
354 | | - -u $uid_val \ |
355 | | - -k /etc/skel \ |
356 | | - -s /bin/bash \ |
357 | | - $_user" |
358 | | - |
359 | | - run_cmd "apt update" |
360 | | - install_pkg "openssl" |
361 | | - run_cmd "$CMD" |
362 | | - run_cmd "$pass_set_cmd" |
363 | | - |
364 | | -} |
365 | 307 | arch_translate() { |
366 | 308 | arch=$1 |
367 | 309 | export t_arch |
@@ -406,7 +348,7 @@ do_qemu_user_emulation() { |
406 | 348 | } |
407 | 349 |
|
408 | 350 | do_chroot_ae() { |
409 | | - local chroot_dir="$1" |
| 351 | + local chroot_dir=$1 |
410 | 352 | shift |
411 | 353 | local command=$* |
412 | 354 | do_mount "$chroot_dir" |
|
0 commit comments