[alpin installer] switch back to sudo

This commit is contained in:
Nico Schottelius 2023-07-18 14:17:12 +02:00
parent 21f95dad13
commit c6d03c7735

View file

@ -55,27 +55,27 @@ dd if=/dev/zero of=${DISK} bs=1M count=2
case "$BOOT_VIA" in case "$BOOT_VIA" in
bios) bios)
doas sfdisk "$DISK" <<EOF sudo sfdisk "$DISK" <<EOF
label: dos label: dos
,,L ,,L
EOF EOF
doas hdparm -z $DISK sudo hdparm -z $DISK
# For creation, if an existing filesystem is on the partitions # For creation, if an existing filesystem is on the partitions
doas mkfs.ext4 -F ${partition1} sudo mkfs.ext4 -F ${partition1}
doas mount -t ext4 ${partition1} $rootfs_tmpdir sudo mount -t ext4 ${partition1} $rootfs_tmpdir
;; ;;
efi) efi)
doas sfdisk "$DISK" <<EOF sudo sfdisk "$DISK" <<EOF
label: gpt label: gpt
,500MiB,U ,500MiB,U
,,L ,,L
EOF EOF
doas hdparm -z $DISK sudo hdparm -z $DISK
doas mkfs.vfat ${partition1} sudo mkfs.vfat ${partition1}
doas mkfs.ext4 -F ${partition2} sudo mkfs.ext4 -F ${partition2}
doas mount -t ext4 ${partition2} "$rootfs_tmpdir" sudo mount -t ext4 ${partition2} "$rootfs_tmpdir"
doas mkdir "${rootfs_tmpdir}/boot" sudo mkdir "${rootfs_tmpdir}/boot"
doas mount -t vfat ${partition1} "${rootfs_tmpdir}/boot" sudo mount -t vfat ${partition1} "${rootfs_tmpdir}/boot"
;; ;;
*) *)
echo "Unknown disk format, $BOOT_VIA" >&2 echo "Unknown disk format, $BOOT_VIA" >&2
@ -84,24 +84,24 @@ EOF
esac esac
# keep right permissions, use doas # keep right permissions, use sudo
doas tar xf $IMAGE -C $rootfs_tmpdir sudo tar xf $IMAGE -C $rootfs_tmpdir
# These are required by grub-install # These are required by grub-install
# And also for generating grub config that contains rootfstype # And also for generating grub config that contains rootfstype
for dir in dev proc sys; do for dir in dev proc sys; do
doas mount --bind /${dir} ${rootfs_tmpdir}/${dir} sudo mount --bind /${dir} ${rootfs_tmpdir}/${dir}
done done
# Add SSH keys # Add SSH keys
run_root mkdir -p root/.ssh run_root mkdir -p root/.ssh
doas cp $SSH_KEYS $rootfs_tmpdir/root/.ssh/authorized_keys sudo cp $SSH_KEYS $rootfs_tmpdir/root/.ssh/authorized_keys
run_root chown root:root /root/.ssh/authorized_keys run_root chown root:root /root/.ssh/authorized_keys
run_root chmod 0600 /root/.ssh/authorized_keys run_root chmod 0600 /root/.ssh/authorized_keys
run_root chmod 0700 /root/.ssh run_root chmod 0700 /root/.ssh
# Import local resolv.conf. # Import local resolv.conf.
doas cp "$RESOLVCONF" $rootfs_tmpdir/etc/resolv.conf sudo cp "$RESOLVCONF" $rootfs_tmpdir/etc/resolv.conf
# Generate fstab which is later included in the initramfs # Generate fstab which is later included in the initramfs
@ -125,7 +125,7 @@ run_root rc-update add sysctl
run_root rc-update add modules run_root rc-update add modules
run_root sed -i 's/root:!::0:::::/root:*::0:::::/' /etc/shadow run_root sed -i 's/root:!::0:::::/root:*::0:::::/' /etc/shadow
doas tee "$rootfs_tmpdir/etc/network/interfaces" <<EOF sudo tee "$rootfs_tmpdir/etc/network/interfaces" <<EOF
auto lo auto lo
iface lo inet loopback iface lo inet loopback
@ -135,7 +135,7 @@ iface eth0 inet6 manual
EOF EOF
doas tee "$rootfs_tmpdir/etc/hostname" <<EOF sudo tee "$rootfs_tmpdir/etc/hostname" <<EOF
alpine-unconfigured alpine-unconfigured
EOF EOF
@ -161,7 +161,7 @@ case "$BOOT_VIA" in
run_root mkdir /boot/EFI/boot run_root mkdir /boot/EFI/boot
run_root cp /boot/EFI/alpine/grubx64.efi /boot/EFI/boot/bootx64.efi run_root cp /boot/EFI/alpine/grubx64.efi /boot/EFI/boot/bootx64.efi
run_root cp /boot/grub/grub.cfg /boot/EFI/boot/ run_root cp /boot/grub/grub.cfg /boot/EFI/boot/
doas umount ${rootfs_tmpdir}/boot sudo umount ${rootfs_tmpdir}/boot
;; ;;
esac esac
@ -171,9 +171,9 @@ run_root cat /etc/fstab
# Cleanup # Cleanup
run_root rm -f /etc/resolv.conf run_root rm -f /etc/resolv.conf
for dir in dev proc sys; do for dir in dev proc sys; do
doas umount ${rootfs_tmpdir}/${dir} sudo umount ${rootfs_tmpdir}/${dir}
done done
doas umount $rootfs_tmpdir sudo umount $rootfs_tmpdir
sync sync
rmdir ${rootfs_tmpdir} rmdir ${rootfs_tmpdir}