#!/bin/sh
# Void Linux Automatic Install Configuration

export username="void"
export password="void"

export XBPS_ARCH=x86_64-musl
export xbpsrepository=https://repo-default.voidlinux.org/current/musl

export end_action=func
end_function() {
    printf "Linking default services"
    chroot "$target" ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/dhcpcd
    chroot "$target" ln -s /etc/sv/sshd /etc/runit/runsvdir/default/sshd

    sync
    reboot -f
}


VAI_partition_disk() {
    # Paritition Disk
    sfdisk "${disk}" <<EOF
;
EOF
}

VAI_format_disk() {
    # Make Filesystems
    mkfs.ext4 -F "${disk}1"
}

VAI_mount_target() {
    # Mount targetfs
    mkdir -p "${target}"
    mount "${disk}1" "${target}"
}

VAI_configure_fstab() {
    uuid1="$(blkid -s UUID -o value "${disk}1")"
    echo "UUID=$uuid1 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
}
