#! /bin/sh

# this script is called from the live installer once it finished copying the live
# image. So we only do the minimal changes necessary to reboot into the system

is_usb=0
if test "$1" = usb; then
  is_usb=1
fi

#chkconfig sshd on
chkconfig cron on
if test -e /etc/init.d/boot.compcache; then
   chkconfig boot.compcache off
fi
rm /usr/lib/systemd/system/sysinit.target.wants/langset.service
rm /usr/lib/systemd/system/langset.service /usr/lib/systemd/system/sysinit.target.wants/langset.service
sed -i -e 's@initrd.* liveinstall@@' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
systemctl enable purge-kernels || true
systemctl enable SuSEfirewall2 || true
mv /etc/xdg/autostart/epoptes-client.desktop /usr/share/applications/
: > /var/run/utmp

# remove live-cd user
userdel linux
userdel -r linux1 || true
userdel -r linux2 || true
userdel -r linux3 || true
userdel -r linux4 || true
userdel -r linux5 || true

# a lot of stuff!
rm -rf /home/linux/.local/share/akonadi
mv /home/linux /home/linux~

#remove default ssh keys so new keys are generated after installation
rm -f /etc/ssh/ssh_host_*key || true
mv /etc/init.d/boot.local.life /etc/init.d/boot.local || true
chmod 0755 /etc/init.d/boot.local
/usr/bin/systemctl -f enable NetworkManager.service || true

#restore disabled services
mv /livedisabled/hplip-systray.desktop /etc/xdg/autostart/hplip-systray.desktop || true
mv /livedisabled/tracker-miner-fs.desktop /etc/xdg/autostart/tracker-miner-fs.desktop || true
mv /livedisabled/tracker-store.desktop /etc/xdg/autostart/tracker-store.desktop  || true
mv /livedisabled/zeitgeist-datahub.desktop /etc/xdg/autostart/zeitgeist-datahub.desktop || true
mv /livedisabled/packagekitd /usr/lib/ || true
mv /etc/systemd/journald.conf.original /etc/systemd/journald.conf || true
mv /var/log/journal-disabled /var/log/journal || true
rm -rf /livedisabled ||true

