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


1.3
date	2005.01.18.18.12.55;	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.08.02.05.41.19;	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/ssh/sshd_config"
BACKUP="${BACKUPDIR}/sshd_config"

echo "Saving changes..."

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

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

if [ "$1" = "yes" ]; then
	RESTART=yes
fi
shift

if [ "$2" = "yes" ]; then
	SFTP=yes
fi
shift

OPT=`cat /usr/share/sushi/system/sshdconf/form \
	| sed -e 's/.*script[1-9],\(.*\) *.*/\1/' | sed -e 's/,.*//' \
	| awk '{print $1'} | egrep -v '^(#|list:|blank:|Subsystem)'`
echo -n "# Generated by sushi on " > $CONFFILE
date >>$CONFFILE
a=1
for i in $OPT
do
	ANS=$(echo `eval echo \\$${a}`)
	if [ -n "$ANS" ]; then
		echo "$i $ANS" >> $CONFFILE
	fi
	a=`expr $a + 1`
done

if [ ! -z "$SFTP" ]; then
	echo "Subsystem	sftp	/usr/libexec/sftp-server" >> $CONFFILE
fi

chmod 644 $CONFFILE
chown root:wheel $CONFFILE
echo "Successfully wrote a new sshd_config file"

if [ ! -z "$RESTART" ]; then
	/etc/rc.d/sshd reload
fi
@


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/08/02 05:41:19 garbled Exp $
d16 1
a16 1
# backup
d18 4
@


1.1
log
@Add the capabilty to sushi to edit the /etc/sshd.conf file.  The defaults
are taken from the manpage.
@
text
@d2 16
a17 1
# $NetBSD$
d22 1
d24 11
a34 5
OPT=`cat /usr/share/sushi/system/sshdconf/form | sed -e 's/.*script[1-9],\(.*\)		 *.*/\1/' \
	| sed -e 's/,.*//' | grep -v '^#' | grep -v '^list:'`
echo -n "# Generated by sushi on " > /etc/sshd.conf
date >>/etc/sshd.conf
a=2
d38 2
a39 2
	if [ ! -z "$ANS" ]; then
		echo "$i $ANS" >> /etc/sshd.conf
d43 9
a51 3
chmod 644 /etc/sshd.conf
chown root:wheel /etc/sshd.conf
echo "Successfully wrote a new sshd.conf file"
@

