File: install.conf

package info (click to toggle)
ffingerd 1.28-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 220 kB
  • ctags: 42
  • sloc: ansic: 324; sh: 316; makefile: 83
file content (112 lines) | stat: -rwxr-xr-x 3,473 bytes parent folder | download | duplicates (4)
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
#! /bin/sh

# This was an intermediate step in the development of this script, and I
# think it should be preserved as an example of the raw power of sed :
#
#if id=`sed -n -e 's/#.*//' \
#	     -e '/[ 	]79\/tcp/{' \
#	     -e 's/^[ 	]*\([^ 	]*\)[ 	]*79\/tcp.*$/\1/' \
#	     -e 'p' \
#	     -e '}' < /etc/services`; then
#
# Basically, this script expects the full path to the finger daemon as
# $1, the full path to awk in $2, the full path to sed in $3.  Then it
# looks in /etc/services for the finger service, if it does not find it,
# it adds it.  Then it looks in /etc/inetd.conf for the finger entry,
# commenting it out if it is found.  Then an entry for the new finger
# daemon is added.

# First rule of programming: The User Is Evil
# Check that the command line arguments are OK
if test g"$1" = g -o g"$2" = g -o g"$3" = g -o g"$4" = g ; then
  echo "Please use \"make install.all\" to run this script."
  exit 2
fi
for i in "$1" "$2" "$3" "$4"; do
  if test ! -x "$i"; then
    echo "$i does not exist or is not executable !"
    exit 3
  fi
done

#
# Go through /etc/services, removing comments, looking for the line with
# [whitespace]79/tcp.  Save that line into $id.  Fail if sed didn't like
# my code or had a non-zero exit code.
#
if id=`$3 -n -e 's/#.*//' \
	     -e '/[ 	]79\/tcp/p' < /etc/services`; then
  if test g"$id" != g ; then
    echo Finger service found in /etc/services, identifier is \"$id\"
  else
    echo Finger service not found in /etc/services
    echo adding \"finger 79/tcp\" ...
    echo >> /etc/services
    echo "finger 79/tcp" >> /etc/services
    id="finger"
  fi
else
  echo "sed did not like my script :("
  echo "Consider installing GNU sed."
  exit 1
fi

#
# Now move /etc/inetd.conf to /etc/inetd.conf.backup. If that fails,
# bail out.  Otherwise run $2 (/usr/bin/awk) with the environment
# variable BINARY=$1 (/usr/sbin/fingerd), feeding in the original
# inetd.conf file and writing the result to /etc/inetd.conf.  This awk
# script matches all lines with one of the aliases from the
# /etc/services finger entry we found, comments them out, and outputs
# a new line with our new finger daemon behind it.
#
if mv /etc/inetd.conf /etc/inetd.conf.backup; then
  if BINARY="$1" K="$id" $2 'BEGIN{ split(ENVIRON["K"],k); notfound=1; \
      for (i in k) a[k[i]]=1; delete a["79/tcp"]; } \
      { if ($1 in a) \
	  { print "# " $0 "\n" k[1] " stream tcp nowait nobody " \
	    ENVIRON["BINARY"] " fingerd"; \
	    notfound=0;
	  }
	else print $0;
      } \
      END { if (notfound) \
        print k[1] " stream tcp nowait nobody " ENVIRON["BINARY"] \
	      " fingerd"; }' < /etc/inetd.conf.backup > /etc/inetd.conf; then
    echo "edited /etc/inetd.conf successfully";
  else
    echo "awk did not like my script :("
    echo "Consider installing mawk or GNU awk"
    mv -f /etc/inetd.conf.backup /etc/inetd.conf
    exit 1
  fi
else
  echo "Sorry, could not edit /etc/inetd.conf";
  exit 1
fi

#
# Send inetd a hangup if we find the inetd.pid file
#
if test -f /etc/inetd.pid; then
  kill -1 `cat /etc/inetd.pid`
else
  if test -f /var/run/inetd.pid; then
    kill -1 `cat /var/run/inetd.pid`
  else
    if test -f /usr/etc/inetd.pid; then
      kill -1 `cat /usr/etc/inetd.pid`
    else
      if test `/bin/uname` = HP-UX; then
        /etc/inetd -c
      else
	if test $4 != none; then
	  $4 -1 inetd
	else
          echo "I could not locate inetd.pid, please kill -1 inetd yourself."
	fi
      fi
    fi
  fi
fi