head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	2005.01.18.18.12.56;	author peter;	state Exp;
branches;
next	1.2;

1.2
date	2004.03.09.21.36.37;	author garbled;	state Exp;
branches;
next	1.1;

1.1
date	2001.03.06.21.26.27;	author garbled;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Minor cleanup and tweaks, be consistent with the other system admin scripts.
@
text
@#!/bin/sh
# $NetBSD: script,v 1.2 2004/03/09 21:36:37 garbled Exp $

BACKUPDIR="/var/sushi"
CONFFILE="/etc/usermgmt.conf"
BACKUP="${BACKUPDIR}/usermgmt.conf"

echo "Saving changes..."

if [ ! -d $BACKUPDIR ]; then
	mkdir $BACKUPDIR
	chown root:wheel $BACKUPDIR
	chmod 700 $BACKUPDIR
fi

if [ ! -f $CONFFILE ]; then
	touch $CONFFILE
	chown root:wheel $CONFFILE
	chmod 644 $CONFFILE
fi

# create a backup
cp -p $CONFFILE $BACKUP
if [ $? -ne 0 ]; then
	echo "Can't create a backup"
	exit 1
fi

BIGLIST="group class base_dir skel_dir shell inactive expire preserve \
password range"

j=0
for i in $BIGLIST
do
	j=`expr $j + 1`
	new=$(echo `eval echo \\$${j}` | sed -e 's/^ *//')
	if [ -z "$new" ]; then
		continue
	fi
	n=`echo $i | wc -m`
	if [ $n -gt 7 ]; then
		echo "$i	$new" >> $BACKUP.new
	else
		echo "$i		$new" >> $BACKUP.new
	fi
done

cp -p $BACKUP.new $CONFFILE

if [ $? -eq 0 ]; then
	echo "Successfully wrote a new $CONFFILE"
	echo ""
	cat $CONFFILE
else
	echo "Failed to write a new $CONFFILE"
fi

rm -f $BACKUP.new

exit 0
@


1.2
log
@Apply patches in PR bin/24645 by Peter Postma:
	Here are some enhancements to sushi's System Maintenance menu.
	To summarize the changes:

	* Make a backup of the file before modifying it.
	* Fixes to get all menus/forms working.
	* Missing/invalid settings (like in rc.conf and inetd.conf)
	  have been added/removed.
	* Most files don't get overwritten now but are edited instead.
	  So specials settings in e.g. /etc/rc.conf don't get lost now.
	* Some help menu fixes. ($NetBSD$ tag has been removed because I
	  don't see how it would be useful for either user or developer).
@
text
@d2 1
a2 1
# $NetBSD: script,v 1.1 2001/03/06 21:26:27 garbled Exp $
d22 1
a22 1
# backup
d24 4
d55 1
a55 1
	echo "Failed"
@


1.1
log
@Add new menu to sushi to deal with editing the /etc/usermgmt.conf file.
@
text
@d2 25
a26 1
# $NetBSD$
a27 1
cp /dev/null /etc/usermgmt.conf
a28 1
BIGLIST="group base_dir skel_dir shell inactive expire preserve password range"
d32 2
a33 2
	x=$(echo `eval echo \\$${j}` | sed -e 's/^ *//')
	if [ "$x" = "" ]; then
d38 1
a38 1
		echo "$i	$x" >>/etc/usermgmt.conf
d40 1
a40 1
		echo "$i		$x" >>/etc/usermgmt.conf
d43 14
a56 2
chown root:wheel /etc/usermgmt.conf
chmod 644 /etc/usermgmt.conf
@

