#!/bin/bash2

FILE=/opt/phion/maintree/swupdates.db
IN=/tmp/swupdates-backup.sql
PID=`cat /var/phion/run/rangeconf-swstatus.pid`

if [ ! -f "$FILE" ]; then
	echo "file $FILE doesn't exist" >&2
	exit 1
fi

showdb -V >& /dev/null

if [ "$?" -lt 1 ]; then
	echo "showdb/changedb is too old!" >&2
	exit 2
fi

rm -f "$FILE"
showdb -S "$FILE" < "$IN"

# reload, wenn die pid-datei wirklich zum gconfd-status-worker gehoert
stat /proc/$PID/exe | grep -q bin/gconfd && kill $PID

exit 0

