#!/bin/sh

. /usr/share/nsdk/settings-functions.sh

debug()
{
	echo "[settings-migration] $@"
}

error()
{
	debug "ERROR: $@"
}

# Convenience function for migrating a single setting file.
# Checks if the old file exists, and if it does, moves it to a new location.
migrate_settings_file()
{
	local OLD_FILE="$1"
	local NEW_FILE="$2"
	if [ -e "$RW_SETTINGS_DIR/$OLD_FILE" ]; then
		debug "Migrating settings file $OLD_FILE to $NEW_FILE"

		mkdir -p "$(dirname "$RW_SETTINGS_DIR/$NEW_FILE")"
		mv "$RW_SETTINGS_DIR/$OLD_FILE" "$RW_SETTINGS_DIR/$NEW_FILE"
	fi
}
