#!/bin/bash

set -e

SD_PATH="/lib/systemd/system"
TARGET_PATH="/etc/systemd/system/multi-user.target.wants"
THERMAL_ETC_PATH="/usr/local/etc/thermald/"
THERMAL_DEFAULT_CONFIG="/usr/share/commonsense-configs/thermald_configs/thermal-conf.xml"
GPS_LOG="/var/log/gnss"

case "$1" in
	configure)
        mkdir -p ${TARGET_PATH} || :
        ln -s "${SD_PATH}/commonsense-configs-atomisp_configs.service" ${TARGET_PATH} || :
        mkdir -p ${THERMAL_ETC_PATH} || :
        cp ${THERMAL_DEFAULT_CONFIG} ${THERMAL_ETC_PATH} || :
	#update-rc.d fan_control.sh defaults
	update-rc.d bt-enable.sh defaults
	#update-rc.d led_control.sh defaults
	update-rc.d sensorhub_daemon.sh defaults
	update-rc.d usb-net-cfg.sh defaults
	mkdir -p ${GPS_LOG} || :
	chmod 777 ${GPS_LOG} || :
	rm -f /etc/systemd/system/multi-user.target.wants/thermald.service
	update-rc.d thermald_control.sh defaults
	update-rc.d grandom.sh defaults

	need_close=`cat /etc/default/apport | grep enabled=`
	sed -i "s/$need_close/enabled=0/g" /etc/default/apport

	if [ -e "/usr/share/ubuntu/scripts/ubiquity-done" ]; then
		/usr/share/ubuntu/scripts/oem-config.d/early/10_euclid-audio-configs
		/usr/share/ubuntu/scripts/oem-config.d/custom/13_oem-network
		/usr/share/ubuntu/scripts/oem-config.d/late/13_set_dhcpd_configuration
	fi
	;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
