# setup - do not touch
mount -t proc none /proc/
mount -t sysfs none /sys/
mount -t devpts none /dev/pts/
# end setup


# set timezone
echo "Europe/Paris" > /etc/timezone
ln -sf /usr/share/zoneinfo/$(cat /etc/timezone) /etc/localtime
dpkg-reconfigure -f noninteractive tzdata

sudo apt-get update

sudo apt-get upgrade -y

# install lang pack
lang=fr
for l in $(cat /usr/share/linuxmint/mintlocale/language_packs); do
	category=$(echo $l | awk -F ':' '{print $1}')
	if [ $category = 'tr' ]; then
		languagecode=$(echo $l | awk -F ':' '{print $2}')
		if [ -z $languagecode ] || [ $languagecode = 'fr' ]; then
			dep=$(echo $l | awk -F ':' '{print $3}')
			if [ -z $dep ] || dpkg -l $dep > /dev/null 2>&1; then
				pull=$(echo $l | awk -F ':' '{print $4}')
				echo "Installing $pull$lang because dep is '$dep'"
				sudo apt-get install -y $pull$lang
			fi
		fi
	fi
done

# setup custom background
rm /usr/share/backgrounds/linuxmint/default_background.jpg
ln -s sele_ring_lis67.jpg /usr/share/backgrounds/linuxmint/default_background.jpg

# gen locales
locale-gen fr

# language french
update-locale LANG=fr_FR.UTF-8 LANGUAGE=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8

# keyboard french
sed -i 's/us/fr/g' /etc/default/keyboard

# install custom packages

# ANCESTRIS
sudo add-apt-repository -y ppa:ancestris/ancestris-stable
sudo apt-get update
sudo apt-get install -y ancestris

# ABRICOTINE
wget "https://github.com/brrd/abricotine/releases/download/1.0.0/abricotine-1.0.0-ubuntu-debian-x64.deb"
sudo dpkg -i abricotine-1.0.0-ubuntu-debian-x64.deb
rm abricotine-1.0.0-ubuntu-debian-x64.deb

# BAOBAB
sudo apt-get install -y baobab

# SCRIBUS
sudo apt-get install -y scribus

# KEEPASSXC
sudo add-apt-repository -y ppa:phoerious/keepassxc
sudo apt-get update
sudo apt-get install -y keepassxc

# clean - do not touch
rm -rf /tmp/*

# fix hosts for live cd
cat <<EOF > /etc/hosts
127.0.0.1	localhost.localdomain	localhost
::1		localhost.localdomain	localhost
EOF

# fix resolv.conf for live cd
cat <<EOF > /etc/resolv.conf
nameserver 127.0.0.53
EOF

# fix firefox not starting correctly after modifications
sudo apt install --reinstall firefox

umount /proc/
umount /sys/
umount /dev/pts
