#bin/sh

#
# $1 - username
#

if [ $# -ne 1 ]; then
    echo
    echo "Installs XFCE4 Desktop Environment (with default set of XFCE tools), as well as "
    echo "a couple of (relatively) small but useful programs. In order to create .xinitrc "
    echo "startup file in your home directory, you must supply your username. Since this "
    echo "script installs software and modifies system files, it must be run as root."
    echo
    echo "Usage: $(basename $0) [username]"
    echo
    echo "Note: this script assumes that you have a working Internet connection, as well "
    echo "      as installation of binary packages (pkgin) enabled. Also, it expects that "
    echo "      you have X-Window system (Xorg) installed. All the required steps can be "
    echo "      done during fresh system installation (sysinstall)."
    echo
    exit 1
fi

echo " - Installing utility programs..."
pkgin -y install cowsay fam figlet fortune hal htop mc nano pv screenfetch smartmontools ytree watch wget vim doas links git

echo "permit nopass :wheel" > /usr/pkg/etc/doas.conf

echo " - Installing desktop environment (XFCE)..."
pkgin -y install xfce4 xfce4-extras slim slim-themes urlgfe


echo " - Installing desktop apps (internet etc)..."
pkgin -y install firefox libreoffice filezilla gimp 7-zip vlc

echo " - Configuring services..."
cp /usr/pkg/share/examples/rc.d/famd /etc/rc.d/famd
cp /usr/pkg/share/examples/rc.d/hal /etc/rc.d/hal
cp /usr/pkg/share/examples/rc.d/dbus /etc/rc.d/dbus
cp /usr/pkg/share/examples/rc.d/slim /etc/rc.d/slim
cp /usr/pkg/share/examples/rc.d/smartd /etc/rc.d/smartd
echo "rpcbind=YES" >> /etc/rc.conf
echo "famd=YES" >> /etc/rc.conf
echo "hal=YES" >> /etc/rc.conf
echo "dbus=YES" >> /etc/rc.conf
echo "slim=YES" >> /etc/rc.conf
echo "smartd=YES" >> /etc/rc.conf
echo "sound_load=YES" >> /etc/rc.conf

echo " - Creating .xinitrc..."
echo "xfce4-session" > /home/$1/.xinitrc
figlet "Minty Fresh NetBSD" >> /etc/motd
echo "All done! Enjoy NetBSD $1" | cowsay
echo
echo " - Reboot your machine with "shutdown -r now" to start graphical login."
echo