File: install.sh

package info (click to toggle)
smartlist 3.15-28
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,308 kB
  • sloc: ansic: 9,238; sh: 4,901; makefile: 118
file content (241 lines) | stat: -rwxr-xr-x 6,143 bytes parent folder | download | duplicates (9)
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#! /bin/sh
: &&O='cd .' || exec /bin/sh "$0" $argv:q # we're in a csh, feed myself to sh
$O || exec /bin/sh "$0" "$@"		  # we're in a buggy zsh
#$Id: install.sh,v 1.56 1998/11/06 05:35:21 guenther Exp $

umask 022				# set it to a sane value

if test -z "$IFS"
then IFS=" \
	\

"
  export IFS
fi

SHELL=/bin/sh				# make sure we get a decent shell
test -z "$MAKE" && MAKE=make		# provide a default "make"
export SHELL MAKE
umask 022				# making sure that umask has sane value

( exec 2>/dev/null
  case `echo x x` in
     *) exit 0 ;;
  esac
)
if test $? != 0				# for BSDI /bin/sh shells
then
  echo "This shell is not sufficiently Bourne shell compatible."
  echo "I recommend upgrading your /bin/sh first."
  exit 69
fi

test $# = 0 -a -f asked.patch && set dummy `cat asked.patch` && shift

test $# != 1 -a $# != 2 && echo "Usage: install.sh target-dir [final-dir [.bin]]" &&
 exit 64

target="$1"
finaldir="$2"
bindir="$3"

if [ "$finaldir" = "" ]; then
  finaldir=$target
fi

case "$target" in		# Make sure $target is absolute
  /*) ;;
  *) target=`cd "$target";pwd` ;;
esac

test -z "$bindir" && bindir=.bin

test ! -d "$target" && echo "Please create the target directory first" &&
 echo "Make sure it has the right owner & group" && exit 2

cd "`dirname $0`"
PATH=.:$PATH

setid=../src/setid

if test ! -f ../config.h
then
  echo "You must merge the source trees of procmail and SmartList"
  echo "together.  Simply unpack them on top of each other."
  exit 2
fi

if binmail=/usr/sbin/sendmail
then
  case "$binmail" in
     /*) ;;		# some !@#$%^&*() shells don't grok [!/]
     *) binmail="";;
  esac
  case "$binmail" in
     ""|*procmail:*)
	 echo "Failed in extracting the value of SENDMAIL from procmail"
	 echo \
	"Please make sure that the NEW version of procmail has been installed"
	 echo \
       'If you already have, make sure that "console" is undefined in config.h'
	 echo "This is what I'm seeing:"
	 procmail -v 2>&1 | sed -e 1q
	 exit 64 ;;
  esac
else
  echo "Please make sure that procmail is on our PATH"
  exit 64
fi

if expr "X$bindir" : 'X\.bin' >/dev/null
then
:
else
  echo "I prefer a bin directory that starts with .bin"
  echo "If you want to enforce a different name, patch install.sh first :-)."
  exit 64
fi

export target finaldir bindir binmail PATH

if test -f "$target/.etc/rc.init.dist" -a ! -f asked.patch
then
   ( exec 2>/dev/null
     diff >/dev/null
     if test $? = 2
     then
	exec patch </dev/null
     fi
     exit 1
   )
  if test $? != 0
  then
     echo 1>&2 "Although not mandatory, it could save *you* some time if the"
     echo 1>&2 "'diff' and 'patch' utilities are in the PATH.  If either one"
     echo 1>&2 "is not available, forget I asked and run install.sh again."
     echo "$*" >asked.patch
     exit 75
  fi
fi

if test ! -z "$LD_LIBRARY_PATH"
then
  echo '***************************** WARNING *********************************'
  echo '* You seem to have set the LD_LIBRARY_PATH variable, this might cause *'
  echo '* some trouble during the installation of this package.		      *'
  echo '* If install.sh does not finish successfully, clear		      *'
  echo '* LD_LIBRARY_PATH from the environment, and start over.		      *'
  echo '***************************** WARNING *********************************'
fi

TMPF=/tmp/list.id.$$

trap "/bin/rm -f $TMPF; exit 1" 1 2 3 13 15

/bin/rm -f $TMPF

echo Id test >$TMPF

AM_ROOT=no

if ls -l $TMPF | grep '^[^ ]*  *[0-9][0-9]*  *root ' >/dev/null
then
  /bin/rm -f $TMPF
  AM_ROOT=yes
  installerid=`ls -l ../Makefile |
   sed -e 's/^[^ ]* *[0-9][0-9]*[^0-9] *\([^ ]*\) .*$/\1/'`
  listid=`ls -ld $target/. |
   sed -e 's/^[^ ]* *[0-9][0-9]*[^0-9] *\([^ ]*\) .*$/\1/'`
  if test root = $listid
  then
     echo "Please give $target the right owner & group first"
     exit 2
  fi
else
  /bin/rm -f $TMPF
  ( exec 2>/dev/null; echo Id test >targetdir.tmp )
  if test $? != 0
  then	# You can run install.sh WITHOUT root permissions as well!
     echo "Please run install.sh with root permissions instead"
     exit 77
  fi
  echo 1>&2 \
   "*** This script is best run as root, if that's not possible press return"
  echo 1>&2 \
   "*** to continue; if it *is* possible, abort now and restart as root!"
  read a
  listid=`ls -l install.sh |
   sed -e 's/^[^ ]* *[0-9][0-9]*[^0-9] *\([^ ]*\) .*$/\1/'`
fi

trap "" 1 2 3 13 15

export listid

rm -f install.list
date >install.list
chmod 0666 install.list

if test $AM_ROOT = yes
then
  if test ! -f $setid
  then
     echo "Please execute the following commands first:"
     echo ""
     echo "	cd ..; make setid; cd SmartList"
     echo ""
     echo "Then run this script again."
     exit 64
  fi
  exec 4<&0
  case $installerid in
     [0-9]*) . ./install.sh2 ;;
     *) $setid $installerid <install.sh2 || exit 1;;
  esac
  $setid $listid $target <install.sh3 || exit 64
  exec 4<&-
  echo "Making $target/$bindir/flist suid root..."
  if chown root "$target/$bindir/flist" && chmod 04755 "$target/$bindir/flist"
  then
  :
  else
     echo "You either have to symlink the $target/$bindir"
     echo "directory to a partition where root has root permissions;"
     echo "or make sure that root can use its rights on the existing"
     echo "partition (that contains $target/$bindir)."
     echo "Then run this script again."
     exit 64
  fi
else
  exec 4<&0
  . ./install.sh2
  . ./install.sh3
  exec 4<&-
fi

chmod 0644 install.list

echo '**********************************************************************'
echo "Finished installing, now you should:"
echo ""
if test -f $target/.etc/rc.init.new
then
  echo "	edit $target/.etc/rc.init.new"
  echo ""
  echo "AND then (preserving hardlinks!):"
  echo ""
  echo "	cat $target/.etc/rc.init.new >$target/.etc/rc.init"
else
  echo "	edit $target/.etc/rc.init"
fi
echo ""
echo "so that \`PATH', \`domain' and \`listmaster' reflect your installation."
if test -f $target/.etc/rc.init.new
then
  echo "Finally, to reenable the lists execute:"
  echo ""
  echo "		/bin/rm -f $target/.etc/rc.lock"
  echo ""
  touch "$target/.etc/rc.lock"
fi
echo '**********************************************************************'