File: sf_install

package info (click to toggle)
sendfile 2.1-8.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,232 kB
  • ctags: 680
  • sloc: ansic: 11,722; sh: 2,443; perl: 228; makefile: 132; java: 36
file content (200 lines) | stat: -rwxr-xr-x 5,743 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# Das Schnellinstallations-Script fuer sendfile im /sw. 
# Bei Aufruf ohne Parameter wird ein Hilfetext ausgegeben.
#

mkdir_recursive() {
  if [ ! -d $1 ]; then
    mkdir `echo $1 | 
           awk -F/ '{ for (i=2; $i!=""; i++)
                      { for (j=2; j<=i; j++) printf("/"$j)
  		        printf(" ") } }'
          ` 2>/dev/null
  fi
}

RESTART=false
SPOOL=/var/spool/sendfile
CONFIG=/usr/local/etc
ALLOW=/usr/local/etc/sendfile.allow
DENY=/usr/local/etc/sendfile.deny
if [ "$2" = "" ]; then 
  SERVERDIR=/usr/local/sbin
else
  SERVERDIR=$2
fi

if [ "$1" != "ok" ]; then
  more <<EOD

Dies ist das no-questions-no-answers Schnellinstallations-Script fuer sendfile.
( Dokumentation zu SAFT/sendfile befindet sich in /client/doc/sendfile-2.1, bei
  Fragen oder Kritik bitte mail an framstag@rus.uni-stuttgart.de schicken. )

Es werden folgende Default-Werte benutzt (und automatisch angelegt):

	spool directory =	$SPOOL
	config directory =	$CONFIG
	sendfiled directory =	$SERVERDIR

In /etc/services und /etc/inetd.conf werden am Ende entsprechende Eintraege
gemacht.

In /etc/profile und in /etc/csh.login wird am Ende eine Zeile zum Test auf 
Files im sendfile-Spool hinzugefuegt.

Um den sendfile-Service wieder zu deinstallieren, genuegt ein:
	rm $SERVERDIR/sendfiled

Wollen Sie andere Default-Eintraege, so muessen Sie diese in makeconfig im
Source (ftp://ftp.uni-stuttgart.de/pub/unix/comm/misc/sendfile.tar.gz)
eintragen und selber compilieren. 

Einzige Ausnahme: das Directory des sendfiled kann auch hiermit angegeben
werden:
	/client/bin/sf_install ok /directory/wo/sendfiled/rein/soll

Sind Sie mit den Default-Eintraegen einverstanden, dann geben Sie jetzt ein:

	/client/bin/sf_install ok

EOD
  exit
fi

if [ "$LOGNAME" != root ]; then
  if [ "`whoami`" != root ]; then
    echo "Der SAFT/sendfile Service kann nur von root installiert werden!!"
    exit 1
  fi
fi

cd SW_INSTALL
umask 022

SENDFILED=`awk '/^saft/ { sfd=$6;
                          if (index($7,"/sendfiled")>0) sfd=$7;
                          if (substr(sfd,1,1)=="?") sfd=substr(sfd,2);
                          print sfd;
                        }' /etc/inetd.conf`
if [ "$SENDFILED" != "$SERVERDIR/sendfiled" -a "$SENDFILED" != "" ]; then
  echo "WARNING: cannot install sendfiled in $SERVERDIR because in /etc/inetd.conf"
  echo "         there is $SENDFILED specified! Check it!"
else
  echo "installing the sendfile-daemon in $SERVERDIR"
  mkdir_recursive $SERVERDIR
  cp sendfiled $SERVERDIR
  chmod 755 $SERVERDIR/sendfiled
fi

mkdir_recursive $CONFIG
NOSENDFILE=$CONFIG/nosendfile
if [ -f $NOSENDFILE ]; then 
  if grep ^allow-only $NOSENDFILE >/dev/null; then 
    echo "Information: $NOSENDFILE is now $ALLOW (autoconverted)"
    grep -v ^allow-only $NOSENDFILE > $ALLOW
  else  
    echo "Information: $NOSENDFILE is now $DENY (autoconverted)"
    mv $NOSENDFILE $DENY
  fi
fi
if [ ! -f $DENY -a ! -f $ALLOW]; then 
  echo "installing $DENY"
  cp sendfile.deny $DENY
  chmod 644 $DENY
fi

if [ ! -f $CONFIG/sendfile.cf ]; then 
  echo installing $CONFIG/sendfile.cf
  cp sendfile.cf $CONFIG/sendfile.cf
  chmod 644 $CONFIG/sendfile.cf
else
  if [ "`diff sendfile.cf $CONFIG`" ]; then
    echo "`pwd`/sendfile.cf differs from $CONFIG/sendfile.cf !"
    echo "Please take a look what has been changed!"
  fi
fi

SERVICES="`awk '/[ \t]487\/tcp/' /etc/services`"
if [ "$SERVICES" != "" ]; then
  case "$SERVICES" in 
    saft*)	;;
    *)		echo "install-error: tcp-port 487 ist bereits belegt!"; exit 1;;
  esac
else
  echo configuring /etc/services
  echo "#" >>/etc/services
  echo "saft	487/tcp		# simple asynchronous file transfer" >>/etc/services
fi

if [ "`grep '^saft' /etc/inetd.conf`" = "" ]; then
  if [ -f /usr/sbin/tcpd ]; then 
    SFD="/usr/sbin/tcpd $SERVERDIR/sendfiled"
  else
    SFD="$SERVERDIR/sendfiled sendfiled"
  fi
  RESTART=true
  echo configuring /etc/inetd.conf
  echo "#" >>/etc/inetd.conf
  echo "# simple asynchronous file transfer" >>/etc/inetd.conf
  echo "saft	stream	tcp	nowait	root	$SFD" >>/etc/inetd.conf
fi

if [ -f /etc/inetd.sec ]; then
  if [ "`grep '^saft' /etc/inetd.sec`" = "" ]; then
    echo >> /etc/inetd.sec
    echo "saft allow" >> /etc/inetd.sec
  fi
fi

if [ -f /etc/profile ]; then
  if [ "`grep check_sendfile /etc/profile`" = "" ]; then
    echo adding check_sendfile to /etc/profile
    echo >>/etc/profile
    echo test -x /client/bin/check_sendfile && /client/bin/check_sendfile \
         >>/etc/profile
  fi
fi
if [ -f /etc/csh.login ]; then
  if [ "`grep check_sendfile /etc/csh.login`" = "" ]; then
    echo adding check_sendfile to /etc/csh.login
    echo >>/etc/csh.login
    echo test -x /client/bin/check_sendfile && /client/bin/check_sendfile \
         >>/etc/csh.login
  fi
fi

if [ ! -d "$SPOOL" ]; then
  echo creating $SPOOL
  mkdir_recursive $SPOOL
fi
if [ ! -d "$SPOOL/LOG" ]; then mkdir $SPOOL/LOG; fi
if [ ! -d "$SPOOL/OUTGOING" ]; then mkdir $SPOOL/OUTGOING; fi
chmod 755  $SPOOL
chmod 700  $SPOOL/LOG
chmod 1777 $SPOOL/OUTGOING

free=`$SENDFILED -f`
minfree=`awk '/minfree =/{print $3}' $CONFIG/sendfile.cf`
if [ $free -le $minfree ]; then
  cat <<EOD
		! ACHTUNG ! 
Es ist nicht genug Platz in $SPOOL !
Entweder muss dem Spool Directory mehr Platz zugewiesen werden oder der Wert
der Option minfree in $CONFIG heruntergesetzt werden.
EOD
fi

echo
echo "Sie koeenen bei Bedarf die folgende Zeile in Ihr System Bootscript aufnehmen:"
echo "    $SERVERDIR/sendfiled -Q &"
echo "Dies wird beim Booten einen outgoing spooling sendfile daemon starten,"
echo "der alte liegengebliebene Files im outgoing spool verarbeitet."
echo

if [ "$RESTART" = true ]; then
  echo
  echo "Bitte jetzt den inetd neu starten ( oder einfach neu booten :-) )"
  echo
fi