#!/bin/bash
# $Header: /cvs/WebShield/wsrc/files/mgmt/ws_restore_defaults,v 1.1.8.2 2005/05/16 10:30:25 hbalasub Exp $
#
# Reset appliance to install defaults
#
# Copyright (C) 2004 Networks Associates Technology Inc. All rights reserved.
#
if [ -f $NETAWSS/.profile.vars ]; then
    . $NETAWSS/.profile.vars
else
    . /var/NAIENV/.profile.vars
fi
[[ "$PATH" == "$wsPATH":* || -z "$wsPATH" ]] || PATH=$wsPATH:$PATH

shopt -s extglob
shopt -s nullglob
shopt -s dotglob

logger -t ${0##*/} Restoring appliance original default settings

# reset the console and IMAP passwords to default

defpass="webshieldchangeme"
echo "$defpass" | /usr/bin/passwd --stdin support > /dev/null 2>&1
echo "!$defpass" | /usr/bin/passwd --stdin root > /dev/null 2>&1
echo "$defpass" | /usr/sbin/saslpasswd2 -u webshield -pc webshield > /dev/null 2>&1
echo "!$defpass" | /usr/sbin/saslpasswd2 -u webshield -pc root > /dev/null 2>&1

# clear out zebra config
for f in $NETAWSS/proto/zebra/*; do rm -f "/etc/zebra/${f##*/}"; done

# clear out WS config
touch $XMLCONFDIR/.restore_defaults

# restore spam evaluate flag
mkdir -p "$XMLCONFDIR/spamconfig"
:> "$XMLCONFDIR/spamconfig/wsui_spam_can_evaluate"

# apply the default config
/sbin/reboot &

exit 0
