1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
#!/bin/sh
# File: sfconf
#
# Author: Ulli Horlacher (framstag@rus.uni-stuttgart.de)
#
# History:
#
# 22 Nov 1997 Framstag initial version
# 23 Nov 1997 Framstag substituted "-" with "_" in all identifiers
# 10 Jan 1998 Framstag added option -m
#
# The configuration helper program for the sendfile package.
#
# Copyright 1997,1998 Ulli Horlacher
# This file is covered by the GNU General Public License
SPOOL=/var/spool/sendfile/`whoami`
CONFIG=$SPOOL/config
EDITOR=${EDITOR:=vi}
PAGER=${PAGER:=more}
PRG=`basename $0`
TMP=$CONFIG/$$.tmp
FILE=
usage() {
echo "$PRG is the sendfile user configuration helper"
echo "usage: $PRG OPTION ARGUMENT"
echo "options: -l -- list"
echo " -e -- edit"
echo " -i -- initialize (= edit with default values)"
echo " -m -- message receiving"
echo "arguments for options -l -e -i :"
echo " config -- user configuration file"
echo " aliases -- user alias file"
echo " filter -- user restrictions file"
echo "arguments for option -l :"
echo " log -- sendfile log file"
echo " msglog -- sendmsg log file"
echo "arguments for option -m :"
echo " all -- messages can be written on all ttys"
echo " here -- messages can be written only on this tty"
echo "examples:"
echo " $PRG -l aliases # list the aliases file"
echo " $PRG -m here # messages will be written only on this tty"
exit
}
testfile() {
if [ ! -f "$1" ]; then
echo "%$PRG-Error: $1 does not exist" >&2
exit 1
fi
if [ ! -r "$1" ]; then
echo "%$PRG-Error: $1 is not readable by you" >&2
exit 1
fi
}
init_append() {
if [ -r $FILE ]; then
cat <<EOD>> $TMP
## The next lines are from your old `basename $FILE` file.
## You may want to delete them (if they are garbage).
EOD
cat $FILE >> $TMP
fi
mv $TMP $FILE
}
init_aliases() {
cat <<EOD> $TMP
## This is the user aliases file for sendfile/sendmsg.
## The syntax is: ALIAS ADDRESS, example:
frams framstag@bofh.belwue.de
EOD
init_append
}
init_config() {
cat <<EOD> $TMP
## This is the user configuration file for sendfile/sendmsg.
## Text after a # is a comment and will be ignored.
# ring the gong when a message arrives (on/off)
bell = on
# allow remote sender to delete his files afterwards (on/off)
deleting = on
# logging of incoming messages in the user log file (on/off)
msglog = off
# notification by message, mail, both or none when a file arrives
# you may specify a second argument as a recipients address
# notification = mail tome@somewhere.inthe.net
notification = message
# enforce secure incoming transfer with pgp (sign/encrypt/both/none)
forcepgp = none
# forward incoming files to another SAFT address
# forward = tome@on.another.org
# if you have an O-SAFT account, specify it here
# (the fetchfile client will use it)
# o-saft = othername@saft.banana.net
EOD
init_append
}
init_restrictions() {
cat <<EOD> $TMP
## This is the user restrictions file for sendfile/sendmsg.
## It contains addresses from where you don't want messages or files.
## The format is: user@host [mfb]
## m stands for messages, f for files and b for both.
## Wildcards * and ? are allowed. Examples:
## bgates@microsoft.com b
## *aol.com m
## Text after a # is a comment, like these first lines.
EOD
init_append
}
#args=`getopt h?lei $*` || usage
#set -- x $args
#while shift; do
# case $1 in
# -\?|-h) usage;;
# -l) list=true;;
# -e) edit=true;;
# -i) init=true;;
# --) shift; break;;
# esac
#done
case "$1" in
-l) list=true;;
-e) edit=true;;
-i) init=true;;
-m) msg=true;;
*) usage;;
esac
if [ "$msg" = true ]; then
case "$2" in
a|all) sendmsg -M;;
h|here|t|this) sendmsg -m;;
*) usage;;
esac
exit;
fi
case "$2" in
a|alias|aliases) FILE=$CONFIG/aliases;;
c|conf|config) FILE=$CONFIG/config;;
f|filter|r|restrictions) FILE=$CONFIG/restrictions;;
l|log) log=true; FILE=$SPOOL/log;;
m|msg|msglog) log=true; FILE=$SPOOL/msglog;;
*) usage;;
esac
if [ "$log" = true ]; then
if [ "$edit" = true ]; then usage; fi
testfile $FILE
awk '{if (NR>1 || $1!="#") print $0}' $FILE | utf7decode | $PAGER
exit $?
fi
if [ "$list" = true ]; then
testfile $FILE
$PAGER $FILE
exit $?
fi
if [ "$edit" = true ]; then
if [ -f $FILE ]; then
$EDITOR $FILE
exit $?
else
echo "%$PRG-Error: $FILE does not exist" >&2
echo "%$PRG-Info: you can create it with: $PRG -i $2" >&2
exit 1
fi
fi
if [ "$init" = true ]; then
trap "rm -f $TMP;exit" 1 2 3 15
case $FILE in
*aliases) init_aliases;;
*config) init_config;;
*restrictions) init_restrictions;;
esac
$EDITOR $FILE
exit $?
fi
|