#!/bin/sh
# Copyright (C) 2016 Algo Communication Products Ltd.
# restore UI settings from uploaded file

if [ "$#" != "2" ]; then
	cat <<EOF
Usage: $0 <working-directory> <saved-ui.zip>
EOF
	exit 1
fi

CONF_WD="$1"
CONF_FILE="$2"
PATH=/opt/algo/bin:$PATH

if [ -f "$CONF_WD/$CONF_FILE" ]; then
	cd /apps/curapp/user
	rm -rf *
	unzip -o "$CONF_WD/$CONF_FILE"
	sync
fi

if [ -d "$CONF_WD" ] && [ "$CONF_WD" != "/" ]; then
	rm -rf "$CONF_WD"/*
fi
