# vim: set ft=sh:

run_hook() {
    if [[ -n "${ip}" && -n "${artix_nfs_srv}" ]]; then

        artix_nfs_srv=$(eval echo ${artix_nfs_srv})
        [[ -n "${artix_nfs_opt}" ]] && artix_nfs_opt="-o ${artix_nfs_opt}"

        mount_handler="artix_nfs_mount_handler"
    fi
}

artix_nfs_mount_handler() {
    newroot="${1}"
    mkdir -p "${bootmnt}"
    msg ":: Mounting '${artix_nfs_srv}'"
    # Do not put "${artix_nfs_opt}" nfsmount fails!
    if ! nfsmount ${artix_nfs_opt} "${artix_nfs_srv}" "${bootmnt}"; then
        echo "ERROR: Mounting '${artix_nfs_srv}'"
        echo "   Falling back to interactive prompt"
        echo "   You can try to fix the problem manually, log out when you are finished"
        launch_interactive_shell
    fi

    if [[ "${copytoram}" != "n" ]]; then
        copytoram="y"
    fi

    artix_mount_handler ${newroot}
}
