#!/bin/sh
#  General fixups.
#
#  Copyright: ©2008–2013, Güralp Systems Ltd.
#  Author: Laurence Withers <lwithers@guralp.com>
#  License: GPLv3
#
# NB: In future, we shouldn't edit this file (except to remove things which
# have become completely irrelevant). Instead, create a new 4xxx script and add
# it to the end of the chain. This way, we will be able to upgrade from
# arbitrarily old versions.
#



# fix incorrect path caused by typo in config-base
if [ -d "/etc/conf.d/serial/nema-out" ]
then
	echo ' * Renaming faulty "nema-out" directory to "nmea-out"'
	mkdir -p "/etc/conf.d/serial/nmea-out"
	mv "/etc/conf.d/serial/nema-out/"* "/etc/conf.d/serial/nmea-out"
	rm -rf "/etc/conf.d/serial/nema-out"
fi



# add a description to gdi-base, if it doesn't already have one; makes menus
# where gdi-base instances are selected more friendly
if [ -e "/etc/gdi-base/default.local" ]
then
	if [ -z "`gcs_rwvar "gcs_get_varcf" "application_description" "/etc/gdi-base/default.local"`" ]
	then
		gcs_rwvar "gcs_set_varcf" "application_description" "/etc/gdi-base/default.local" "Default data transport daemon"
	fi
fi



# remove some old directories, if they exist
remove_old_dir() {
	if [ -d "$1" ]
	then
		echo " * Removing old directory $1"
		rm -rf "$1"
	fi
}

remove_old_dir "/var/spool/quickstatus"
remove_old_dir "/usr/share/rdisk"
remove_old_dir "/etc/ssl.local"
remove_old_dir "/var/log/gstm-server"



# done
exit 0
