#! /bin/bash

set -e

export DEBIAN_FRONTEND="noninteractive"

# Install PikaOS Basics	

apt-get install --yes --option Dpkg::Options::="--force-confnew" --option Dpkg::Options::="--force-overwrite" --no-install-recommends \
    pika-baseos \
    console-setup \
    console-setup-linux \
    sudo \
    nano \
    vim-tiny \
    pika-audio-pipewire \
    dialog \
    locales \
    locales-all

# Setup Locales

## Uncomment en_US.UTF-8 for inclusion in generation
sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen

## Generate locale
locale-gen

## Setup locale config
update-locale LANG="en_US.UTF-8"

tee /etc/default/keyboard <<'EOF'
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
KEYMAP=us
EOF

cp -fv /etc/default/keyboard /etc/vconsole.conf || true

tee /etc/default/locale <<'EOF'
#  File generated by update-locale
LANG=en_US.UTF-8
EOF

cp -fv /etc/default/locale /etc/locale.conf || true

# Setup console-setup

cat > /etc/default/console-setup <<EOF
# CONFIGURATION FILE FOR SETUPCON

# Consult the console-setup(5) manual page.

ACTIVE_CONSOLES="/dev/tty[1-6]"

CHARMAP="UTF-8"

CODESET="guess"
FONTFACE="Terminus"
FONTSIZE="16x32"

VIDEOMODE=

# The following is an example how to use a braille font
# FONT='lat9w-08.psf.gz brl-8x8.psf'
EOF

dpkg-reconfigure --frontend=noninteractive console-setup
