#!/bin/bash
# enable ssh
ln -s /lib/systemd/system/ssh.service /etc/systemd/system/multi-user.target.wants/ssh.service
mv -f /etc/rc2.d/K01ssh /etc/rc2.d/S01ssh
mv -f /etc/rc3.d/K01ssh /etc/rc3.d/S01ssh
mv -f /etc/rc4.d/K01ssh /etc/rc4.d/S01ssh
mv -f /etc/rc5.d/K01ssh /etc/rc5.d/S01ssh
rm -f /etc/init/ssh.override
# install necessary packages
apt-get -y install enscript feh ghostscript gsfonts imagemagick imagemagick-6-common imagemagick-6.q16 libjpeg9 libjpeg-progs libjxr0:armhf libjxr-tools liblqr-1-0 libmagickcore-6.q16-3 libmagickcore-6.q16-3-extra libmagickwand-6.q16-3 libnetpbm10 libwmf0.2-7 netpbm poppler-utils python3-magic python-magic rclone zsh zsh-common
# fix cursor and screensaver
/home/pi/kiosk/bin/change-file a /etc/lightdm/lightdm.conf 'xserver-command=X -nocursor -s 0 dpms'
/home/pi/kiosk/bin/change-file a /etc/xdg/lxsession/LXDE/autostart '@xset s noblank' '@xset s off' '@xset -dpms'
# make it start on boot
/home/pi/kiosk/bin/change-file c /etc/rc.local 'exit 0' '#exit 0'
/home/pi/kiosk/bin/change-file a /etc/rc.local 'sleep 9' 'sudo -u pi /home/pi/kiosk/bin/show' 'exit 0'
# make sure Raspberry Pi is caught up on all updates
apt-get -y update
apt-get -y dist-upgrade