dermotbradley / create-alpine-disk-image

Create cloud-init enabled Alpine disk images for physical machines (PCs & RPIs), VMs, and Cloud servers
GNU General Public License v2.0
93 stars 11 forks source link

/bin/sh: syntax error: unexpected end of file (expecting "}") #35

Closed jorddenn closed 1 year ago

jorddenn commented 2 years ago

Running

./create-alpine-disk-image --boottype uefi --release 3.16 --optimise --cpu-vendor amd --harden --ipv4only --virtual proxmox --script-filename test.sh --mirror http://dl-cdn.alpinelinux.org/alpine

chroot: Disable non-server kernel modules
chroot:   Blacklisting drivers kernel modules
chroot:   Disabling drivers kernel modules
chroot:   Blacklisting net kernel modules
chroot:   Disabling net kernel modules
chroot:   Creating init.d script for disabling kernel module loading
chroot: Delete unnecessary users and groups
/bin/sh: syntax error: unexpected end of file (expecting "}")

AN ERROR OCCURRED, cleaning up before aborting!

  Unmounting /dev inside chroot
  Unmounting /sys inside chroot
  Unmounting /proc inside chroot
  Unmounting /efi inside chroot
  Unmounting root filesystem inside chroot
  Freeing up loop device

the test.sh is missing the closing '}' for the "Delete unnecessary users and groups" section. Adding the '--debug' flag properly closes the brackets. After adding the closing bracket the script competes.

I was originally using debug because I was getting the following, hence the mirror to the HTTP URL. Same as #16 ?

[2022-07-28 17:33:31] Install base Alpine (plus bootloader packages) for x86_64 arch inside chroot
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
6907320:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1914:
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.16/main: Permission denied
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.16/main: No such file or directory
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
6907320:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1914:
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.16/community: Permission denied
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.16/community: No such file or directory
ERROR: unable to select packages:
  alpine-base (no such package):
    required by: world[alpine-base]
  dosfstools (no such package):
    required by: world[dosfstools]
  efivar (no such package):
    required by: world[efivar]
  grub (no such package):
    required by: world[grub]
  grub-efi (no such package):
    required by: world[grub-efi]
  mkinitfs (no such package):
    required by: world[mkinitfs]
[2022-07-28 17:33:31]
[2022-07-28 17:33:31]
[2022-07-28 17:33:31] AN ERROR OCCURRED, cleaning up before aborting!
[2022-07-28 17:33:31]
[2022-07-28 17:33:31]
[2022-07-28 17:33:31]   Unmounting /efi inside chroot
[2022-07-28 17:33:31]   Unmounting root filesystem inside chroot
[2022-07-28 17:33:31]   Freeing up loop device

Running on an Alpine VM in Proxmox (Virtual ISO).

cat /etc/alpine-release
3.16.0

uname -a
Linux base 5.15.55-0-virt #1-Alpine SMP Mon, 18 Jul 2022 06:51:44 +0000 x86_64 GNU/Linux
dermotbradley commented 2 years ago

Hi. I just updated the script to fix the missing "}" issue.

The certificate issue was not the same as #16 as that affecting running the script on non Alpine hosts. The problem you saw I believe is that you ran the script on Alpine Edge which recently switched various packages from OpenSSL 1.1.x to 3.x - the static apk-tools binary (which was linked against OpenSSL 1.1.x) was being used on Alpine hosts as well as non-Alpine hosts when it shouldn't have been - I've now changed the script to only download that on non-Alpine hosts.

Can you retest and let me know if the problem is resolved?

jorddenn commented 2 years ago

Looks awesome, no missing bracket and no need to force a mirror