#!/bin/sh
# postinst script for qtmobilehotspot
#
# see: dh_installdeb(1)

set -e

# folder that should remain after updates but not after removes
if [ ! -d /home/user/.qtmobilehotspot ]; then
	mkdir /home/user/.qtmobilehotspot
	chown user:users /home/user/.qtmobilehotspot
fi

# make files executable
if [ -e /opt/qtmobilehotspot/qtmobilehotspot ]; then
	chmod a+x /opt/qtmobilehotspot/qtmobilehotspot
fi
if [ -e /opt/qtmobilehotspot/util/start.sh ]; then
	chmod a+x /opt/qtmobilehotspot/util/start.sh
fi
if [ -e /opt/qtmobilehotspot/util/qtmhprivoxy/privoxy ]; then
	chmod a+x /opt/qtmobilehotspot/util/qtmhprivoxy/privoxy.executable
fi

# copy windows driver to MyDocs
if [ -d /home/user/MyDocs ]; then
	if [ ! -d /home/user/MyDocs/QtMobileHotspot-Driver ]; then
		mkdir /home/user/MyDocs/QtMobileHotspot-Driver
	fi
	cp -R /opt/qtmobilehotspot/docs/windows-usb-driver /home/user/MyDocs/QtMobileHotspot-Driver
fi

# clear configuration (annoying, but necessary til we reach a stable release, as previous configuration may become out of date)
gconftool --recursive-unset /apps/qtmobilehotspot


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

exit 0


