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

# ===
# Disk Configuration
# ===
# disk: the disk to install to
# default: the first disk that isn't the installer
#disk=/dev/hda

# bootpartitionsize: controls how large the boot partition will be
# default: 500M
#bootpartitionsize=500M

# swapsize: how large should the swap partition be
# default: equal to the installed physical memory
#swapsize=

# ===
# XBPS Configuration
# ===
# xbpsrepository: which repo should the install pull from
# default: http://repo.voidlinux.eu/current

# pkgs: additional packages to install into the target
# default: none
#pkgs=""

# ===
# Default User
# ===
# username: the username of the user to be created
# default: voidlinux
username="vagrant"

# password: password to set for the new user
# default: unset (will prompt during install)
# Warning: This does not work in musl!
password="vagrant"

# ===
# Misc. Options
# ===
# timezone: Timezone in TZ format
# default: America/Chicago
#timezone="America/Chicago"

# keymap: Keymap to use by default
# default: us
#keymap

# locale: initial glibc locale
# default: en_US.UTF-8
#libclocale=en.US.UTF-8

# hostname: static hostname for the system
# default: derived from DNS
#hostname=VoidLinux

# end_action: what to do at the end of the install
# default: shutdown
# alternate values: reboot, script
end_action=func

# end_script: script to optionally run at end of install
# the user script must reside somewhere xbps-uhelper fetch
# can retrieve it from
# default: not set

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

    xbps-install -r ${target} -Sy dbus virtualbox-ose-guest

    chroot ${target} ln -s /etc/sv/dbus /etc/runit/runsvdir/default/dbus
    chroot ${target} ln -s /etc/sv/vboxservice /etc/runit/runsvdir/default/vboxservice

    sync
    reboot -f
}