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.03.06.21.21.06;	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"
MAILERCONF="/etc/mailer.conf"
BACKUP="${BACKUPDIR}/mailer.conf"

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

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

if [ "$1" = "sendmail" ]; then
	sendmail=0
	grep sendmail/sendmail $MAILERCONF >/dev/null
	if [ $? -eq 0 ]; then
		grep "^#.*sendmail/sendmail" $MAILERCONF >/dev/null
		if [ $? -ne 0 ]; then
			sendmail=1
		fi
	fi

	if [ $sendmail -eq 1 ]; then
		echo "Sendmail is already your default mailer."
		exit 0
	fi
	echo "sendmail		/usr/libexec/sendmail/sendmail" >$MAILERCONF
	echo "send-mail		/usr/libexec/sendmail/sendmail" >>$MAILERCONF
	echo "mailq		/usr/libexec/sendmail/sendmail" >>$MAILERCONF
	echo "newaliases	/usr/libexec/sendmail/sendmail" >>$MAILERCONF
	echo "hoststat		/usr/libexec/sendmail/sendmail" >>$MAILERCONF
	echo "purgestat		/usr/libexec/sendmail/sendmail" >>$MAILERCONF
	chown root:wheel $MAILERCONF
	chmod 644 $MAILERCONF
	echo "Sendmail has now been made your default mailer."
	exit 0
fi

if [ "$1" = "postfix" ]; then
	postfix=0
	grep postfix/sendmail $MAILERCONF >/dev/null
	if [ $? -eq 0 ]; then
		grep "^#.*postfix/sendmail" $MAILERCONF >/dev/null
		if [ $? -ne 0 ]; then
			postfix=1
		fi
	fi

	if [ $postfix -eq 1 ]; then
		echo "Postfix is already your default mailer."
		exit 0
	fi
	echo "sendmail		/usr/libexec/postfix/sendmail" >$MAILERCONF
	echo "send-mail		/usr/libexec/postfix/sendmail" >>$MAILERCONF
	echo "mailq		/usr/libexec/postfix/sendmail" >>$MAILERCONF
	echo "newaliases	/usr/libexec/postfix/sendmail" >>$MAILERCONF
	chown root:wheel $MAILERCONF
	chmod 644 $MAILERCONF
	echo "Postfix has now been made your default mailer."
	exit 0
fi

if [ "$1" = "exim" ]; then
	PKGNM=`pkg_info -e exim`
	LOCALBASE=`pkg_info -p $PKGNM | grep CWD | sed -e 's@@.*CWD to: @@@@'`
	cp $LOCALBASE/etc/exim/mailer.conf.exim $MAILERCONF
	chown root:wheel $MAILERCONF
	chmod 644 $MAILERCONF
	echo "$PKGNM has now been made your default mailer."
	exit 0
fi

if [ "$1" = "postfix-current" ]; then
	PKGNM=`pkg_info -e postfix-current`
	LOCALBASE=`pkg_info -p $PKGNM | grep CWD | sed -e 's@@.*CWD to: @@@@'`
	cp $LOCALBASE/etc/mailer.conf.postfix $MAILERCONF
	chown root:wheel $MAILERCONF
	chmod 644 $MAILERCONF
	echo "$PKGNM has now been made your default mailer."
	exit 0
fi

if [ "$1" = "sendmail88" ]; then
	PKGNM=`pkg_info -e sendmail88`
	LOCALBASE=`pkg_info -p $PKGNM | grep CWD | sed -e 's@@.*CWD to: @@@@'`
	cp $LOCALBASE/etc/mailer.conf.sendmail $MAILERCONF
	chown root:wheel $MAILERCONF
	chmod 644 $MAILERCONF
	echo "$PKGNM has now been made your default mailer."
	exit 0
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/03/06 21:21:06 garbled Exp $
d14 1
a14 1
# backup
d16 4
d32 1
a32 1
		echo "Sendmail is already your default mailer"
d58 1
a58 1
		echo "Postfix is already your default mailer"
d77 1
a77 1
	echo "$PKGNM has now been made your default mailer"
d87 1
a87 1
	echo "$PKGNM has now been made your default mailer"
d97 1
a97 1
	echo "$PKGNM has now been made your default mailer"
@


1.1
log
@Add scripts to edit your /etc/mailer.conf file.  Currently it can also deal
with the exim/sendmail88 and postfix-current packages.
@
text
@d2 1
a2 1
# $NetBSD$
d4 1
d6 10
d18 1
d20 9
a28 2
	if [ "$?" = "0" ]; then
		echo "Sendmail is allready your default mailer"
a36 1
	echo "Sendmail has now been made your default mailer."
d39 1
d44 1
d46 9
a54 2
	if [ "$?" = "0" ]; then
		echo "Postfix is allready your default mailer"
a60 1
	echo "Postfix has now been made your default mailer."
d63 1
@

