#!/bin/sh
#
#    Copyright (c) 2003 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    File name:   logout
#    Module name: fabos/src/security/utils.c
#
#    This script will logout all sessions of specified particular users.
#    It's called by the in a number of situtaions in secure mode
#    by the FABOS code such as when passwords change or FCS role
#    change.
#
export PATH=/fabos/sbin:/fabos/bin:/bin:/usr/bin:/sbin

chkstring=`ls /proc`

if [ "$chkstring" != "" ]
then
	echo This is a recovery command that can only be run in single user mode.
	exit -1
fi

cd /etc/fabos

# For loop will disable security on all logical switches by changing sec.mode
# value in config file to 0.
for conf_file in `ls -1 fabos.*.conf`
do
	if [ "$conf_file" != "fabos.chassis.conf" ]
	then
		sed 's/sec.mode:.*/sec.mode:0/g' $conf_file > /tmp/$conf_file
		mv /tmp/$conf_file $conf_file
	fi
done

# Save config file on the secondary partition
cp /etc/fabos/fabos.*.conf /mnt/etc/fabos

# Remove binary files in case they're corrupted.  The security daemon
# will create a new file during startup.
rm /etc/fabos/*.secdb
rm /mnt/etc/fabos/*.secdb
