source: branches/samhain-2_2-branch/samhain-install.sh.in@ 156

Last change on this file since 156 was 72, checked in by rainer, 18 years ago

Support installation of init scripts on MaxOS X.

File size: 40.3 KB
RevLine 
[1]1#! /bin/sh
2
3purge=
4verbose=
5express=
6force=
7act=
8
9prefix=@prefix@
10exec_prefix=@exec_prefix@
11sbindir=@sbindir@
12samhain=@install_name@
13mandir=@mandir@
14
15sysconfdir=@sysconfdir@
16configfile=@myconffile@
17
18pid_file=@mylockfile@
19pid_dir=@mylockdir@
20
21data_root=@mydataroot@
22mydatafile=@mydatafile@
23
24mylogfile=@mylogfile@
25mylogdir=@mylogdir@
26
27myhtmlfile=@myhtmlfile@
28
29INSTALL_SHELL="$0 --install-sh -m 700"
30INSTALL_DATA="$0 --install-sh -m 600"
31
32mkinstalldirs="$0 --mkinstalldirs"
33
34
35DESTDIR=
36user=
37
38#
39# Only call rmdir with an absolute path
40#
41SH_RMDIR=echo
42SPATH="/bin:/usr/bin:/sbin:/usr/sbin"
43OLD_IFS=${IFS}
44IFS=':'; export IFS
45for ff in ${SPATH}; do
46 if test -x $ff/rmdir; then
47 SH_RMDIR=`eval echo ${ff}/rmdir`
48 fi
49done
50IFS=${OLD_IFS}; export IFS
51
52case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
53 *c*,-n*) ECHO_N= ECHO_C='
54' ECHO_T=' ' ;;
55 *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
56 *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
57esac
58
59
60if [ x"$1" = x ]
61then
62 echo 'samhain-install.sh [--destdir=DESTDIR][--verbose][--express][--force] action'
63 echo 'action = install-boot|install-data|install-user'
64 echo ' uninstall|purge|uninstall-boot'
65 echo ' uninstall-data|uninstall-man|uninstall-program|uninstall-lkm'
66 echo 'samhain-install.sh --print-config <item>'
67 echo 'item = name | basekey | prefix | exec_prefix | sbin_dir | man_dir'
68 echo ' config_dir | config_file | pid_dir | log_dir | log_file'
69 echo ' data_dir | data_file'
70 exit 1
71fi
72
73while [ x"$1" != x ]; do
74 case $1 in
75 -v|--verbose) verbose=yes
76 shift
77 continue;;
78
79 -e|--express) express=yes
80 shift
81 continue;;
82
83 -f|--force) force=yes
84 shift
85 continue;;
86
87 -d) shift
88 DESTDIR="$1"
89 if test "x${DESTDIR}" = "x/"; then
90 DESTDIR=
91 fi
92 shift
93 continue;;
94
95 --destdir=*) DESTDIR=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
96 if test "x${DESTDIR}" = "x/"; then
97 DESTDIR=
98 fi
99 shift
100 continue;;
101
102 --install-sh)
103 shift
104# install - install a program, script, or datafile
105# This comes from X11R5 (mit/util/scripts/install.sh).
106#
107# Copyright 1991 by the Massachusetts Institute of Technology
108#
109# Permission to use, copy, modify, distribute, and sell this software and its
110# documentation for any purpose is hereby granted without fee, provided that
111# the above copyright notice appear in all copies and that both that
112# copyright notice and this permission notice appear in supporting
113# documentation, and that the name of M.I.T. not be used in advertising or
114# publicity pertaining to distribution of the software without specific,
115# written prior permission. M.I.T. makes no representations about the
116# suitability of this software for any purpose. It is provided "as is"
117# without express or implied warranty.
118#
119# Calling this script install-sh is preferred over install.sh, to prevent
120# `make' implicit rules from creating a file called install from it
121# when there is no Makefile.
122#
123# This script is compatible with the BSD install script, but was written
124# from scratch. It can only install one file at a time, a restriction
125# shared with many OS's install programs.
126
127
128# set DOITPROG to echo to test this script
129
130# Don't use :- since 4.3BSD and earlier shells don't like it.
131doit="${DOITPROG-}"
132
133
134# put in absolute paths if you don't have them in your path; or use env. vars.
135
136mvprog="${MVPROG-mv}"
137cpprog="${CPPROG-cp}"
138chmodprog="${CHMODPROG-chmod}"
139chownprog="${CHOWNPROG-chown}"
140chgrpprog="${CHGRPPROG-chgrp}"
141stripprog="${STRIPPROG-strip}"
142rmprog="${RMPROG-rm}"
143mkdirprog="${MKDIRPROG-mkdir}"
144
145transformbasename=""
146transform_arg=""
147instcmd="$mvprog"
148chmodcmd="$chmodprog 0755"
149chowncmd=""
150chgrpcmd=""
151stripcmd=""
152rmcmd="$rmprog -f"
153mvcmd="$mvprog"
154src=""
155dst=""
156dir_arg=""
157
158while [ x"$1" != x ]; do
159 case $1 in
160 -c) instcmd="$cpprog"
161 shift
162 continue;;
163
164 -d) dir_arg=true
165 shift
166 continue;;
167
168 -m) chmodcmd="$chmodprog $2"
169 shift
170 shift
171 continue;;
172
173 -o) chowncmd="$chownprog $2"
174 shift
175 shift
176 continue;;
177
178 -g) chgrpcmd="$chgrpprog $2"
179 shift
180 shift
181 continue;;
182
183 -s) stripcmd="$stripprog"
184 shift
185 continue;;
186
187 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
188 shift
189 continue;;
190
191 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
192 shift
193 continue;;
194
195 *) if [ x"$src" = x ]
196 then
197 src=$1
198 else
199 # this colon is to work around a 386BSD /bin/sh bug
200 :
201 dst=$1
202 fi
203 shift
204 continue;;
205 esac
206done
207
208if [ x"$src" = x ]
209then
210 echo "install: no input file specified"
211 exit 1
212else
213 true
214fi
215
216if [ x"$dir_arg" != x ]; then
217 dst=$src
218 src=""
219
220 if [ -d $dst ]; then
221 instcmd=:
222 else
223 instcmd=mkdir
224 fi
225else
226
227# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
228# might cause directories to be created, which would be especially bad
229# if $src (and thus $dsttmp) contains '*'.
230
231 if [ -f $src -o -d $src ]
232 then
233 true
234 else
235 echo "install: $src does not exist"
236 exit 1
237 fi
238
239 if [ x"$dst" = x ]
240 then
241 echo "install: no destination specified"
242 exit 1
243 else
244 true
245 fi
246
247# If destination is a directory, append the input filename; if your system
248# does not like double slashes in filenames, you may need to add some logic
249
250 if [ -d $dst ]
251 then
252 dst="$dst"/`basename $src`
253 else
254 true
255 fi
256fi
257
258## this sed command emulates the dirname command
259dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
260
261# Make sure that the destination directory exists.
262# this part is taken from Noah Friedman's mkinstalldirs script
263
264# Skip lots of stat calls in the usual case.
265if [ ! -d "$dstdir" ]; then
266defaultIFS='
267'
268IFS="${IFS-${defaultIFS}}"
269
270oIFS="${IFS}"
271# Some sh's can't handle IFS=/ for some reason.
272IFS='%'
273set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
274IFS="${oIFS}"
275
276pathcomp=''
277
278while [ $# -ne 0 ] ; do
279 pathcomp="${pathcomp}${1}"
280 shift
281
282 if [ ! -d "${pathcomp}" ] ;
283 then
284 $mkdirprog "${pathcomp}"
285 else
286 true
287 fi
288
289 pathcomp="${pathcomp}/"
290done
291fi
292
293if [ x"$dir_arg" != x ]
294then
295 $doit $instcmd $dst &&
296
297 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
298 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
299 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
300 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
301else
302
303# If we're going to rename the final executable, determine the name now.
304
305 if [ x"$transformarg" = x ]
306 then
307 dstfile=`basename $dst`
308 else
309 dstfile=`basename $dst $transformbasename |
310 sed $transformarg`$transformbasename
311 fi
312
313# don't allow the sed command to completely eliminate the filename
314
315 if [ x"$dstfile" = x ]
316 then
317 dstfile=`basename $dst`
318 else
319 true
320 fi
321
322# Make a temp file name in the proper directory.
323
324 dsttmp=$dstdir/#inst.$$#
325
326# Move or copy the file name to the temp name
327
328 $doit $instcmd $src $dsttmp &&
329
330 trap "rm -f ${dsttmp}" 0 &&
331
332# and set any options; do chmod last to preserve setuid bits
333
334# If any of these fail, we abort the whole thing. If we want to
335# ignore errors from any of these, just make sure not to ignore
336# errors from the above "$doit $instcmd $src $dsttmp" command.
337
338 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
339 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
340 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
341 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
342
343# Now rename the file to the real destination.
344
345 $doit $rmcmd -f $dstdir/$dstfile &&
346 $doit $mvcmd $dsttmp $dstdir/$dstfile
347
348fi &&
349
350
351exit 0
352 # ----- END OF INSTALL-SH -----
353 ;;
354
355 --mkinstalldirs)
356 shift
357 # mkinstalldirs --- make directory hierarchy
358 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
359 # Created: 1993-05-16
360 # Public domain
361 # $Id: mkinstalldirs,v 1.10 1996/05/03 07:37:52 friedman Exp $
362 errstatus=0
363 for file
364 do
365 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
366 shift
367 pathcomp=
368 for d
369 do
370 pathcomp="$pathcomp$d"
371 case "$pathcomp" in
372 -* ) pathcomp=./$pathcomp ;;
373 esac
374
375 if test ! -d "$pathcomp"; then
376 echo "mkdir $pathcomp" 1>&2
377
378 mkdir "$pathcomp" || lasterr=$?
379
380 if test ! -d "$pathcomp"; then
381 errstatus=$lasterr
382 fi
383 fi
384
385 pathcomp="$pathcomp/"
386 done
387 done
388 exit $errstatus
389 # mkinstalldirs ends here
390 ;;
391
392 install-deploy)
393 if test -f ./samhainrc.USEME
394 then
395 tmpconfigfile=`echo ${configfile} | sed 's%^REQ_FROM_SERVER%%'`
396 if test x"${tmpconfigfile}" = x
397 then
398 echo " No local path for configfile defined."
399 exit 0
400 else
401 cp samhainrc.USEME "${tmpconfigfile}" && chmod 0600 "${tmpconfigfile}"
402 fi
403 fi
404 if test -f postinstall.USEME
405 then
406 /bin/sh ./postinstall.USEME
407 fi
408 exit 0
409 ;;
410
411 print-config|--print-config)
412 shift
413 pwhat=$1
414 if test x"$1" = x
415 then
416 echo "$0: Missing argument to print-config"
417 exit 1
418 fi
419 case $pwhat in
420 basekey)
421 echo "@mykeybase@"
422 ;;
423
424 prefix)
425 echo $prefix
426 ;;
427
428 exec_prefix)
429 echo $exec_prefix
430 ;;
431
432 sbin_dir)
433 echo $sbindir
434 ;;
435
436 name)
437 echo $samhain
438 ;;
439
440 man_dir)
441 echo $mandir
442 ;;
443
444 config_dir)
445 echo $sysconfdir
446 ;;
447
448 config_file)
449 echo $configfile | sed 's%^REQ_FROM_SERVER%%'
450 ;;
451
452 pid_file)
453 echo ${pid_file}
454 ;;
455
456 pid_dir)
457 echo ${pid_dir}
458 ;;
459
460 data_dir)
461 echo @mydataroot@
462 ;;
463
464 data_file)
465 echo @mydatafile@ | sed 's%^REQ_FROM_SERVER%%'
466 ;;
467
468 log_file)
469 echo @mylogfile@
470 ;;
471
472 log_dir)
473 echo @mylogdir@
474 ;;
475
476 *)
477 echo "$0: Unknown item \"$pwhat\""
478 exit 1
479 ;;
480 esac
481 exit 0
482 ;;
483
484 install-user)
485 act=user
486 shift
487 user=$1
488 break;;
489
490 install-boot)
491 act=boot
492 break;;
493
494 uninstall-boot)
495 act=uboot
496 break;;
497
498 install-data)
499 act=data
500 break;;
501
502 uninstall-data)
503 act=udata
504 break;;
505
506 uninstall-man)
507 act=uman
508 break;;
509
510 uninstall-program)
511 act=uprogram
512 break;;
513
514 uninstall-lkm)
515 act=ulkm
516 break;;
517
518 uninstall | remove | purge)
519 opts=
520 test x"$verbose" = "xyes" && opts="$opts --verbose"
521 test x"$express" = "xyes" && opts="$opts --express"
522 test x"$force" = "xyes" && opts="$opts --force"
523 test x"$DESTDIR" = "x" || opts="$opts --destdir=$DESTDIR"
524 test x"$1" = "xpurge" && purge=yes
525 echo "$0 $opts uninstall-lkm"
526 eval $0 $opts uninstall-lkm
527 echo "$0 $opts uninstall-program"
528 eval $0 $opts uninstall-program
529 echo "$0 $opts uninstall-man"
530 eval $0 $opts uninstall-man
531 if test x"$force" = "x"; then
532 test "x$purge" = xyes && opts="$opts --force"
533 fi
534 echo "$0 $opts uninstall-data"
535 eval $0 $opts uninstall-data
536 echo
537 echo " To uninstall the runlevel scripts, use $0 $opts uninstall-boot"
538 echo
539 exit 0
540 ;;
541 *)
542 echo "Unknown option $1"
543 exit 1
544 ;;
545
546 esac
547done
548
549if test x"$act" = xuser
550then
551
552# -- the routines for installing a new user are adapted from
553# the OpenPKG bootstrap installation script, which is distributed
554# under the following license:
555
556## Shell-based package for OpenPKG BINARY bootstrap installation
557## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
558## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
559## Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
560##
561## Permission to use, copy, modify, and distribute this software for
562## any purpose with or without fee is hereby granted, provided that
563## the above copyright notice and this permission notice appear in all
564## copies.
565##
566## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
567## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
568## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
569## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
570## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
571## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
572## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
573## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
574## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
575## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
576## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
577## SUCH DAMAGE.
578
579 if test x"$user" = x
580 then
581 echo "**ERROR**: No username specified"
582 exit 1
583 fi
584
585 s=`uname -s 2>/dev/null` || s='Unknown'
586 r=`uname -r 2>/dev/null` || r='0.0'
587 platform="${s}/${r}"
588
589 if test x"$user" = xnobody; then
590 case "$platform" in
591 HP-UX/* )
592 group="nogroup"
593 ;;
594 *)
595 group="nobody"
596 ;;
597 esac
598 else
599 group="$user"
600 fi
601 shell=/bin/false
602 if test -f /etc/shells
603 then
604 grep "^/usr/bin/false" /etc/shells >/dev/null 2>&1 && shell=/usr/bin/false
605 grep "^/bin/nologin" /etc/shells >/dev/null 2>&1 && shell=/bin/nologin
606 grep "^/sbin/nologin" /etc/shells >/dev/null 2>&1 && shell=/sbin/nologin
607 fi
608 home="${data_root}"
609
610 xuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
611 grep "^${user}:" | awk -F: '{ print $3; }'`
612 if test "x$xuid" = x
613 then
614 # seek for a reasonable uid/gid pair
615 xuid=1000
616 ok=0
617 while test "x$ok" = x0
618 do
619 eval "u_exists=\$u_exists_$xuid"
620 if test "x$u_exists" = x
621 then
622 u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
623 fi
624 eval "g_exists=\$g_exists_$xuid"
625 if test "x$g_exists" = x
626 then
627 g_exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
628 fi
629 if [ "x$u_exists" = x -a "x$g_exists" = x ]; then
630 ok=1
631 break
632 fi
633 xuid=`expr $xuid + 1`
634 done
635 eval "u_exists_$xuid=yes"
636 eval "g_exists_$xuid=yes"
637 else
638 # user exists
639 xgid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
640 grep "^${user}:" | awk -F: '{ print $4; }'`
641 fi
642
643 if test "x$xgid" = x
644 then
645 xgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
646 grep "^${group}:" | awk -F: '{ print $3; }'`
647 fi
648
649 if test "x$xgid" = x
650 then
651 xgid="$xuid"
652 g_exists=no
653 else
654 g_exists=yes
655 fi
656
657 uid=$xuid
658 gid=$xgid
659
660 if test -f /etc/shells
661 then
662 exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
663 if test "x$exists" = x; then
664 echo "${shell}" >>/etc/shells
665 test -z "$verbose" || echo " Added ${shell} to /etc/shells"
666 fi
667 fi
668
669 exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^$user:"`
670 if test x"$exists" = x; then
671 # add entry to passwd database
672 realname="$user"
673 case "$platform" in
[59]674 FreeBSD/* | NetBSD/* | OpenBSD/* )
[1]675 file=/etc/master.passwd
676 entry="${user}:*:${uid}:${gid}::0:0:${realname}:${home}:${shell}"
677 update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
678 break
679 ;;
680 Linux/* )
681 file=/etc/passwd
682 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
683 update="(PATH=\$PATH:/usr/sbin; pwconv)"
684 break
685 ;;
686 SunOS/5.* )
687 file=/etc/passwd
688 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
689 update="(PATH=\$PATH:/usr/sbin; pwconv)"
690 break
691 ;;
692 OSF1/V5.* )
693 file=/etc/passwd
694 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
695 update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
696 break
697 ;;
698 HP-UX/* )
699 file=/etc/passwd
700 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
701 update=":"
702 break
703 ;;
704 IRIX*/* )
705 file=/etc/passwd
706 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
707 update=":"
708 break
709 ;;
710 *)
711 echo "install-user: Unsupported system $platform"
712 echo "Please add user $user / group $group manually"
713 echo " and re-run make install-user"
714 exit 1
715 ;;
716 esac
717 cp $file $file.bak && \
718 (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
719 rm -f $file.bak >/dev/null 2>&1
720 eval $update
721 test -z "$verbose" || echo " Added user: ${user} uid: ${uid} shell: ${shell}"
722 else
723 test -z "$verbose" || echo " User ${user} exists already"
724 fi
725
726 # check whether group already exists
727 # FIXME
728 exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$group:"`
729 if test x"$exists" = x
730 then
731 #
732 # user has a valid GID
733 #
734 if test g_exists = xyes; then
735 exists=yes
736 fi
737 fi
738 if test x"$exists" = x
739 then
740 # add entry to group database
741 file=/etc/group
742 entry="${group}:*:${gid}:${user}"
743 cp $file $file.bak && \
744 (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
745 rm -f $file.bak >/dev/null 2>&1
746 test -z "$verbose" || echo " Added group: ${group} gid: ${gid} user: ${user}"
747 fi
748
749 exit 0
750fi
751
752if test x"$act" = xboot || test x"$act" = xuboot
753then
754 s=`uname -s 2>/dev/null` || s='Unknown'
755 r=`uname -r 2>/dev/null` || r='0.0'
756 platform="${s}/${r}"
757
758 case "$platform" in
[72]759 Darwin/*)
760 DVER="MACOSX"
761 test -z "$verbose" || echo "MacOS X system detected"
762 rc_main="/Library/StartupItems/${samhain}"
763 ${mkinstalldirs} ${rc_main}
764 rc_dirz=
765 rc_inst="(cd /Library/StartupItems/${samhain} && echo '{' >StartupParameters.plist && echo ' Description = \"@install_name@\";' >>StartupParameters.plist && echo ' Provides = (\"@install_name@\");' >>StartupParameters.plist && echo ' Requires = (\"Network\");' >>StartupParameters.plist && echo ' OrderPreference = \"Last\";' >>StartupParameters.plist && echo '}' >>StartupParameters.plist && chmod 644 StartupParameters.plist; )"
766 rc_uinst="rm -rf /Library/StartupItems/@install_name@"
767 ;;
768
[1]769 IRIX*/*)
770 DVER="IRIX"
771 test -z "$verbose" || echo " IRIX system detected"
772 rc_main=${DESTDIR}/etc/init.d
773 rc_dirz=
774 rc_inst="chmod 755 /etc/init.d/@install_name@; chown root /etc/init.d/@install_name@; chkconfig -f @install_name@ on; (cd /etc; ln -f -s init.d/@install_name@ rc2.d/S99@install_name@; ln -f -s init.d/@install_name@ rc0.d/K10@install_name@; )"
775 rc_uinst="rm -f /etc/init.d/@install_name@; rm -f /etc/rc2.d/S99@install_name@; rm -f /etc/rc0.d/K10@install_name@; chkconfig @install_name@ off"
776 ;;
777
778 AIX/*)
779 DVER="AIX"
780 test -z "$verbose" || echo " AIX system detected"
781 ln -f -s @sbindir@/@install_name@ samhain.startAIX
782 rc_main=@sbindir@
783 rc_dirz=
784 rc_inst="/usr/sbin/mkitab -i '@install_name@:2:wait:@sbindir@/@install_name@ start >/dev/console 2>&1'"
785 rc_uinst="/usr/sbin/rmitab @install_name@"
786 ;;
787
788 HP-UX/*)
789 DVER="HPUX"
790 test -z "$verbose" || echo " HP-UX system detected"
791 rc_main=${DESTDIR}/sbin/init.d
792 rc_dirz=
793 rc_inst="chmod 555 /sbin/init.d/@install_name@; chown bin:bin /sbin/init.d/@install_name@; (cd /sbin && ln -f -s /sbin/init.d/@install_name@ rc2.d/S900@install_name@ && ln -f -s /sbin/init.d/@install_name@ rc1.d/K100@install_name@; )"
794 rc_uinst="rm -f /sbin/init.d/@install_name@; rm -f /sbin/rc2.d/S900@install_name@; rm -f /sbin/rc1.d/K100@install_name@"
795 ;;
796
[59]797 OpenBSD/*)
798 test -z "$verbose" || echo " OpenBSD system detected"
799 grep '^## begin @install_name@' /etc/rc.local >/dev/null 2>&1
800 if [ $? -eq 0 ]; then
801 RCLOCALTMP=`mktemp /etc/rc.local.XXXXXXXXXX` || exit 1
802 sed "/^## begin @install_name@/,/^## end @install_name@/d" /etc/rc.local >$RCLOCALTMP || exit 1
803 cat $RCLOCALTMP >/etc/rc.local || exit 1
804 rm -f $RCLOCALTMP || exit 1
805 if test x"$act" = xuboot; then
806 echo " uninstalling from /etc/rc.local completed"
807 fi
808 fi
809 if test x"$act" = xboot; then
810 echo "## begin @install_name@" >>/etc/rc.local || exit 1
811 echo "if [ -x @sbindir@/@install_name@ ]; then" >>/etc/rc.local || exit 1
812 echo " @sbindir@/@install_name@ start" >>/etc/rc.local || exit 1
813 echo "fi" >>/etc/rc.local || exit 1
814 echo "## end @install_name@" >>/etc/rc.local || exit 1
815 echo " installing to /etc/rc.local completed"
816 fi
817 exit 0
818 ;;
819
820 NetBSD/*)
821 test -z "$verbose" || echo " NetBSD system detected"
822 if test -f /etc/rc.subr; then
823 DVER="FreeBSD"
824 rc_main=${DESTDIR}/etc/rc.d
825 rc_dirz=
826 rc_inst="chmod 755 /etc/rc.d/@install_name@"
827 rc_uinst="rm -f /etc/rc.d/@install_name@"
828 else
829 echo "${0}: unsupported platform ${platform} (too old)"
830 exit 1
831 fi
832 ;;
833
[1]834 FreeBSD/* )
835 test -z "$verbose" || echo " FreeBSD system detected"
[59]836 if test -f /etc/rc.subr; then
837 DVER="FreeBSD"
838 rc_main=${DESTDIR}/etc/rc.d
839 rc_dirz=
840 rc_inst="chmod 755 /etc/rc.d/@install_name@"
841 rc_uinst="rm -f /etc/rc.d/@install_name@"
842 else
843 DVER="Solaris"
844 rc_main=${DESTDIR}/usr/local/etc/rc.d
845 rc_dirz=
846 rc_inst="mv /usr/local/etc/rc.d/@install_name@ /usr/local/etc/rc.d/@install_name@.sh && chmod 755 /usr/local/etc/rc.d/@install_name@.sh"
847 rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh"
848 fi
[1]849 if test x"$act" = xboot
850 then
851 if [ ! -d ${rc_main} ]; then
852 test x"$act" = xboot && mkdir ${rc_main}
853 fi
[59]854 if test "x$DVER" = "xSolaris"; then
[1]855 ( . /etc/defaults/rc.conf
856 . /etc/rc.conf
857 found=0
858 for p in ${local_startup-x}; do
859 if test "x$p" = "x${rc_main}"; then
860 found=1
861 break
862 fi
863 done
864 if test "x$found" = x0; then
865 cp -p /etc/rc.conf /etc/rc.conf.bak
866 (
867 grep -v local_startup /etc/rc.conf.bak
868 echo "local_startup=\"${rc_main} $local_startup\""
869 ) >/etc/rc.conf
870 fi
871 )
[59]872 fi
873 fi
[1]874 ;;
[59]875
[1]876 SunOS/5.* )
877 DVER="Solaris"
[59]878 DVER_REAL="Solaris"
[1]879 test -z "$verbose" || echo " Solaris system detected"
880 rc_dirz=
881 rc_main=${DESTDIR}/etc/init.d
882 rc_inst="chmod 755 ${DESTDIR}/etc/init.d/@install_name@; chown root:sys ${DESTDIR}/etc/init.d/@install_name@; (cd ${DESTDIR}/etc; ln init.d/@install_name@ rc3.d/S99@install_name@; ln init.d/@install_name@ rc0.d/K10@install_name@; ln init.d/@install_name@ rc1.d/K10@install_name@; )"
883 rc_uinst="rm -f ${DESTDIR}/etc/init.d/@install_name@; rm -f ${DESTDIR}/etc/rc0.d/K10@install_name@; rm -f ${DESTDIR}/etc/rc1.d/K10@install_name@; rm -f ${DESTDIR}/etc/rc3.d/S99@install_name@"
884 ;;
[59]885
[1]886 Linux/*)
887 rlv="2 3 4 5"
888 linkopt="-f -s"
889 # find rc directories
890 if test -f /usr/lib/lsb/install_initd && test -d /etc/init.d
891 then
892 test -z "$verbose" || echo " Linux Standard Base system detected"
893 DVER=LSB
894 if test x"$DESTDIR" = x
895 then
896 rc_main=/etc/init.d
897 rc_dirz=
898 rc_inst="/usr/lib/lsb/install_initd /etc/init.d/@install_name@"
899 rc_uinst="/usr/lib/lsb/remove_initd /etc/init.d/@install_name@"
900 else
901 rc_inst=
902 rc_uinst=
903 rc_main=${DESTDIR}/etc/init.d
904 rc_dirz=
905 # test -d /etc/init.d/rc2.d && rc_dirz=${DESTDIR}/etc/init.d/rc
906 # test -d /etc/rc.d/rc2.d && rc_dirz=${DESTDIR}/etc/rc.d/rc
907 # test -d /etc/rc2.d && rc_dirz=${DESTDIR}/etc/rc
908 fi
909 elif test -f /etc/SuSE-release
910 then
911 test -z "$verbose" || echo " SuSE system detected"
912 DVER="Linux"
913 rc_inst=
914 rc_uinst=
915 if test -d /sbin/init.d && test -d /sbin/init.d/rc2.d
916 then
917 test -z "$verbose" || echo " SuSE 6.x system detected"
918 rc_main=${DESTDIR}/sbin/init.d
919 rc_dirz=${DESTDIR}/sbin/init.d/rc
920 elif test -d /etc/init.d && test -d /etc/init.d/rc2.d
921 then
922 test -z "$verbose" || echo " SuSE 7.x or newer detected"
923 rc_main=${DESTDIR}/etc/init.d
924 rc_dirz=${DESTDIR}/etc/init.d/rc
925 else
926 echo "${0}: unknown system"
927 exit 1
928 fi
929 elif test -d /sbin/init.d && test -d /sbin/init.d/rc2.d
930 then
931 DVER="Linux"
932 rc_inst=
933 rc_uinst=
934 test -z "$verbose" || echo " SuSE 5.x system detected"
935 rc_main=${DESTDIR}/sbin/init.d
936 rc_dirz=${DESTDIR}/sbin/init.d/rc
937 elif test -f /etc/debian_version
938 then
939 DVER="Linux"
940 test -z "$verbose" || echo " Debian based system detected"
941 if test x"$DESTDIR" = x
942 then
943 rc_main=/etc/init.d
944 rc_dirz=
945 rc_uinst="/usr/sbin/update-rc.d -f @install_name@ remove"
946 rc_inst="/usr/sbin/update-rc.d @install_name@ defaults 99 10"
947 else
948 rc_inst=
949 rc_uinst=
950 rc_main=${DESTDIR}/etc/init.d
951 # rc_dirz=${DESTDIR}/etc/rc
952 rc_dirz=
953 fi
954 elif test -f /etc/redhat-release
955 then
956 DVER="Linux"
957 test -z "$verbose" || echo " Redhat based system detected"
958 rc_uinst=
959 rc_inst=
960 rc_main=${DESTDIR}/etc/rc.d/init.d
961 rc_dirz=${DESTDIR}/etc/rc.d/rc
962 elif test -f /etc/mandrake-release
963 then
964 DVER="Linux"
965 test -z "$verbose" || echo " Mandrake based system detected"
966 rc_uinst=
967 rc_inst=
968 rc_main=${DESTDIR}/etc/rc.d/init.d
969 rc_dirz=${DESTDIR}/etc/rc.d/rc
970 elif test -f /etc/yellowdog-release
971 then
972 DVER="Linux"
973 test -z "$verbose" || echo " Yellow Dog based system detected"
974 rc_uinst=
975 rc_inst=
976 rc_main=${DESTDIR}/etc/rc.d/init.d
977 rc_dirz=${DESTDIR}/etc/rc.d/rc
978 elif test -f /etc/slackware-version && test -f /etc/rc.d/rc.sysvinit
979 then
980 DVER="Linux"
981 test -z "$verbose" || echo " Slackware based system detected"
982 rc_uinst=
983 rc_inst=
984 rc_main=${DESTDIR}/etc/rc.d
985 rc_dirz=${DESTDIR}/etc/rc.d/rc
986 elif test -f /etc/gentoo-release
987 then
988 DVER="Gentoo"
989 test -z "$verbose" || echo " Gentoo based system detected"
990 rc_uinst="/sbin/rc-update del @install_name@"
991 rc_inst="/sbin/rc-update add @install_name@ default"
992 rc_main=${DESTDIR}/etc/init.d
993 rc_dirz=
994 else
995 echo "${0}: unknown Linux distribution"
996 rc_uinst=
997 rc_inst=
998 rc_main=
999 rc_dirz=
1000 for ff in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
1001 if test -d $ff; then
1002 rc_main="$ff"
1003 break
1004 fi
1005 done
1006 for fg in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
1007 if test -d $fg; then
1008 rc_dirz="`echo $fg | sed -e 's,2.*,,'`"
1009 break
1010 fi
1011 done
1012 if [ x"${rc_dirz}" = x ]; then
1013 echo "${0}: no install directory for runlevel scripts found"
1014 exit 1
1015 fi
1016 if [ x"${rc_main}" = x ]; then
1017 echo "${0}: no install directory for runlevel scripts found"
1018 exit 1
1019 fi
1020 DVER="Linux"
1021 rc_main="${DESTDIR}${rc_main}"
1022 rc_dirz="${DESTDIR}${rc_dirz}"
1023 fi
1024 ;;
1025
1026 *)
1027 echo "${0}: unsupported platform ${platform}"
1028 exit 1
1029 ;;
1030 esac
1031
1032 if test x"${rc_main}" = x
1033 then
1034 echo "${0}: no install directory for runlevel scripts found"
1035 exit 1
1036 fi
1037
1038 if test x"${act}" = xboot
1039 then
1040
1041 startscript=NONE
1042 if test -f init/samhain.start${DVER}
1043 then
1044 startscript=`eval echo init/samhain.start${DVER}`
1045 elif test -f samhain.start${DVER}
1046 then
1047 startscript=`eval echo samhain.start${DVER}`
1048 else
1049 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1050 exit 1
1051 fi
1052
1053 if test "x${startscript}" = xNONE; then
1054 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1055 exit 1
1056 else
1057 if test -f ${rc_main}/${samhain} && test x"$force" != xyes
1058 then
1059 echo " ${rc_main}/${samhain} exists ... not overwritten (or use --force)"
1060 else
1061 if test x"$DESTDIR" = x
1062 then
1063 :
1064 else
1065 ${mkinstalldirs} ${rc_main}
1066 #
[59]1067 if test x"${DVER_REAL}" = xSolaris; then
[1]1068 ${mkinstalldirs} ${DESTDIR}/etc/rc0.d
1069 ${mkinstalldirs} ${DESTDIR}/etc/rc1.d
1070 ${mkinstalldirs} ${DESTDIR}/etc/rc3.d
1071 fi
1072 #
1073 fi
1074 test -z "$verbose" || echo " ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}"
1075 if test -f "@INSTALL@"; then
1076 ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}
1077 else
1078 cp ${startscript} ${rc_main}/${samhain} && chmod 0700 ${rc_main}/${samhain}
1079 fi
1080 fi
1081 fi
1082
1083
1084 if test x"${rc_dirz}" != x
1085 then
1086 for ff in $rlv
1087 do
1088 if test x"${DESTDIR}" = x
1089 then
1090 rldir="${rc_dirz}${ff}.d/"
1091 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain}"
1092 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain})
1093 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain}"
1094 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain})
1095 else
1096 :
1097 # ${mkinstalldirs} ${rc_dirz}${ff}.d
1098 fi
1099
1100
1101 done
1102 fi
1103
1104 if test x"${rc_inst}" != x
1105 then
1106 if test x"${DESTDIR}" = x
1107 then
1108 test -z "$verbose" || echo " ${rc_inst}"
1109 eval ${rc_inst}
1110 fi
1111 fi
1112 echo "installing init scripts completed"
1113 fi
1114
1115 if test x"${act}" = xuboot
1116 then
1117 if test x"${rc_uinst}" != x
1118 then
1119 test -z "$verbose" || echo " ${rc_uinst}"
1120 echo
1121 eval ${rc_uinst}
1122 fi
1123
1124 if test x"${rc_dirz}" != x
1125 then
1126 for ff in $rlv
1127 do
1128 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1129 rm -f ${rc_dirz}${ff}.d/S99${samhain}
1130 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1131 rm -f ${rc_dirz}${ff}.d/K10${samhain}
1132 done
1133 fi
1134
1135 test -z "$verbose" || echo " rm -f ${rc_main}/${samhain}"
1136 rm -f ${rc_main}/${samhain}
1137
1138 echo " uninstalling init scripts completed"
1139 fi
1140
1141 # boot_install|boot_uninstall completed
1142 exit 0
1143fi
1144
1145if test x"${act}" = xulkm
1146then
1147 RVER=`uname -r`
1148 if test "x@sh_lkm@" != "x"; then
1149 if test -d /lib/modules/$RVER; then
1150 MODDIR="/lib/modules/$RVER"
1151 elif test -d /lib/modules/misc; then
1152 MODDIR="/lib/modules/misc"
1153 elif test -d /lib/modules; then
1154 MODDIR="/lib/modules/misc"
1155 fi
1156 # -- NEW --
1157 ALLMODS="@sh_lkm@"
1158 for p in $ALLMODS; do
1159 test -z "$verbose" || echo " rm -f ${DESTDIR}${MODDIR}/`echo $p|sed '
1160s%samhain%@install_name@%'`"
1161 rm -f ${DESTDIR}${MODDIR}/`echo $p|sed 's%samhain%@install_name@%'`
1162 done
1163 fi
1164fi
1165
1166if test x"${act}" = xuprogram
1167then
1168 PROGRAMS="@setpwd_prg@ @stegin_prg@ @yulectl_prg@ @sh_main_prg@"
1169 for p in $PROGRAMS; do
1170 test -z "$verbose" || echo " rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"
1171 rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`
1172 done
1173 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sbindir} ... $ECHO_C"
1174 ${SH_RMDIR} ${DESTDIR}${sbindir} >/dev/null 2>&1
1175 if test x$? = x0; then
1176 test -z "$verbose" || echo "${ECHO_T}done"
1177 else
1178 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1179 fi
1180 exit 0
1181fi
1182
1183if test x"${act}" = xuman
1184then
1185 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man8/@install_name@.8"
1186 rm -f ${DESTDIR}${mandir}/man8/@install_name@.8
1187 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5"
1188 rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5
1189
1190 OLD_IFS=${IFS}
1191 IFS=':'; export IFS
1192 for ff in ${MANPATH}; do
1193 if test x"$ff/man8" = x"${DESTDIR}${mandir}/man8"; then
1194 echo " man directory ${DESTDIR}${mandir} is in your MANPATH"
1195 echo " -- will not try to remove"
1196 IFS=${OLD_IFS}; export IFS
1197 exit 0
1198 fi
1199 done
1200 IFS=${OLD_IFS}; export IFS
1201
1202 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man8 ... $ECHO_C"
1203 ${SH_RMDIR} ${DESTDIR}${mandir}/man8 >/dev/null 2>&1
1204 if test x$? = x0; then
1205 test -z "$verbose" || echo "${ECHO_T}done"
1206 else
1207 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1208 fi
1209
1210 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man5 ... $ECHO_C"
1211 ${SH_RMDIR} ${DESTDIR}${mandir}/man5 >/dev/null 2>&1
1212 if test x$? = x0; then
1213 test -z "$verbose" || echo "${ECHO_T}done"
1214 else
1215 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1216 fi
1217
1218 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir} ... $ECHO_C"
1219 ${SH_RMDIR} ${DESTDIR}${mandir} >/dev/null 2>&1
1220 if test x$? = x0; then
1221 test -z "$verbose" || echo "${ECHO_T}done"
1222 else
1223 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1224 fi
1225
1226 exit 0
1227fi
1228
1229if test x"${act}" = xudata
1230then
1231 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`"
1232 rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`
1233 test -z "$verbose" || echo " rm -f ${DESTDIR}${pid_file}"
1234 rm -f ${DESTDIR}${pid_file}
1235 test -z "$verbose" || echo " rm -f ${DESTDIR}${mylogfile}"
1236 rm -f ${DESTDIR}${mylogfile}
1237 test -z "$verbose" || echo " rm -f ${DESTDIR}${myhtmlfile}"
1238 rm -f ${DESTDIR}${myhtmlfile}
1239
1240 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${pid_dir} ... $ECHO_C"
1241 ${SH_RMDIR} ${DESTDIR}${pid_dir} >/dev/null 2>&1
1242 if test x$? = x0; then
1243 test -z "$verbose" || echo "${ECHO_T}done"
1244 else
1245 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1246 fi
1247
1248 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mylogdir} ... $ECHO_C"
1249 ${SH_RMDIR} ${DESTDIR}${mylogdir} >/dev/null 2>&1
1250 if test x$? = x0; then
1251 test -z "$verbose" || echo "${ECHO_T}done"
1252 else
1253 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1254 fi
1255
1256 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${data_root} ... $ECHO_C"
1257 ${SH_RMDIR} ${DESTDIR}${data_root} >/dev/null 2>&1
1258 if test x$? = x0; then
1259 test -z "$verbose" || echo "${ECHO_T}done"
1260 else
1261 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1262 fi
1263
1264 if test x"$force" = "xyes"
1265 then
1266 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1267 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1268 elif test x"$purge" = "xyes"
1269 then
1270 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1271 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1272 elif test x"$express" = x; then
1273 echo " Do you want to remove the configuration file [y/n] ?"
1274 while [ "1" = "1" ]; do
1275 read ff
1276 case "$ff" in
1277 Y* | y* )
1278 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1279 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1280 break
1281 ;;
1282 N* | n* )
1283 test -z "$verbose" || echo " ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` NOT removed"
1284 break
1285 ;;
1286 *)
1287 echo " Enter y[es] or n[o]"
1288 ;;
1289 esac
1290 done
1291 else
1292 test -z "$verbose" || echo " NOT REMOVED: config file ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` (use --force to remove)"
1293 fi
1294
1295 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sysconfdir} ... $ECHO_C"
1296 ${SH_RMDIR} ${DESTDIR}${sysconfdir} >/dev/null 2>&1
1297 if test x$? = x0; then
1298 test -z "$verbose" || echo "${ECHO_T}done"
1299 else
1300 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1301 fi
1302
1303 exit 0
1304fi
1305
1306if test x"${act}" = xdata
1307then
1308 STEGIN=@stegin_prg@
1309 CONVERT=
1310
1311 GPGPATH=@mygpg@
1312
1313 NTEST=@mytclient@
1314
1315 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1316 then
1317 RCFILE=yulerc
1318 if test -f $RCFILE
1319 then
1320 :
1321 else
1322 if test -f yulerc.template
1323 then
1324 cp yulerc.template $RCFILE
1325 fi
1326 fi
1327 else
1328 RCFILE=samhainrc
1329 IN_RCFILE=samhainrc.@selectconfig@
1330
1331 if test -f ${RCFILE}
1332 then
1333 :
1334 else
1335 if test -f ${IN_RCFILE}
1336 then
1337 test -z "$verbose" || echo " cp ${IN_RCFILE} ${RCFILE}"
1338 cp ${IN_RCFILE} ${RCFILE}
1339 fi
1340 fi
1341 fi
1342
1343 if test -f $RCFILE
1344 then
1345 :
1346 else
1347 echo "${0}: cannot find configuration file $RCFILE"
1348 exit 1
1349 fi
1350
1351 if test x"${GPGPATH}" != x
1352 then
1353 echo
1354 echo "You need to sign the config file now"
1355 echo
1356 test -z "$verbose" || echo " ${GPGPATH} -a --clearsign $RCFILE"
1357 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1358 then
1359 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1360 grep "^${samhain}:" | awk -F: '{ print $3; }'`
1361 if test x"${myident_uid}" != x
1362 then
1363 DOT_GNUPG=`eval echo ~${samhain}/.gnupg`
1364 test -z "$verbose" || echo " using --homedir ${DOT_GNUPG}"
1365 ${GPGPATH} --homedir ${DOT_GNUPG} -a --clearsign $RCFILE
1366 else
1367 ${GPGPATH} -a --clearsign $RCFILE
1368 fi
1369 else
1370 ${GPGPATH} -a --clearsign $RCFILE
1371 fi
1372
1373 if test -f ${RCFILE}.asc
1374 then
1375 test -z "$verbose" || echo " mv -f ${RCFILE}.asc samhainrc.pre"
1376 mv -f ${RCFILE}.asc samhainrc.pre
1377 else
1378 echo "**********************************************************"
1379 echo
1380 echo "${0}: ERROR: cannot find signed file ${RCFILE}.asc"
1381 echo
1382 echo " --- You need to sign the configuration file ---"
1383 echo
1384 echo "**********************************************************"
1385 cp ${RCFILE} samhainrc.pre
1386 fi
1387 else
1388 test -z "$verbose" || echo " cp $RCFILE samhainrc.pre"
1389 cp $RCFILE samhainrc.pre
1390 fi
1391
1392 if test x"${STEGIN}" != x
1393 then
1394 test -z "$verbose" || echo " searching for ImageMagick convert utility"
1395 OPATH=${PATH}
1396 PATH="/usr/local/bin:/usr/X11R6/bin:"${PATH}
1397
1398 OIFS=${IFS}
1399 IFS=":"
1400
1401 for dd in ${PATH}
1402 do
1403 if test -f "${dd}/convert"
1404 then
1405 "${dd}/convert" --help | grep ImageMagick >/dev/null 2>&1 && \
1406 CONVERT="${dd}/convert"
1407 test -z "$verbose" || echo " CONVERT=${dd}/convert"
1408 fi
1409 done
1410
1411 IFS=${OIFS}
1412
1413 if test x"${CONVERT}" = x
1414 then
1415 echo "${0}: cannot find ImageMagick convert utility in PATH=${PATH}"
1416 exit 1
1417 fi
1418
1419 PATH=${OPATH}
1420
1421 if test -f stealth_template.jpg
1422 then
1423 test -z "$verbose" || echo " ${CONVERT} +compress stealth_template.jpg stealth_template.ps"
1424 "${CONVERT}" +compress stealth_template.jpg stealth_template.ps
1425 else
1426 echo "${0}: cannot find file stealth_template.jpg"
1427 exit 1
1428 fi
1429
1430
1431 if test -f stealth_template.ps
1432 then
1433 :
1434 else
1435 echo "${0}: file stealth_template.ps not created"
1436 exit 1
1437 fi
1438
1439 if test -f samhainrc.pre
1440 then
1441 :
1442 else
1443 echo "${0}: cannot find configuration file samhainrc.pre"
1444 exit 1
1445 fi
1446
1447 if test -f ./samhain_stealth
1448 then
1449 :
1450 else
1451 echo "${0}: cannot find utility ./samhain_stealth"
1452 exit 1
1453 fi
1454
1455 ccount=`./samhain_stealth -o samhainrc.pre 2>&1 | awk '{ print $1 }'`
1456 mcount=`./samhain_stealth -i stealth_template.ps 2>&1 | awk '{ print $7 }'`
1457
1458 if test ${mcount} -lt ${ccount}
1459 then
1460 echo "${0}: configuration file samhainrc too big,"
1461 echo " need a larger image stealth_template.jpg to store"
1462 exit 1
1463 fi
1464
1465 test -z "$verbose" || echo " ./samhain_stealth -s stealth_template.ps samhainrc.pre"
1466 ./samhain_stealth -s stealth_template.ps samhainrc.pre
1467
1468 test -z "$verbose" || echo " mv -f stealth_template.ps samhainrc.install"
1469 mv -f stealth_template.ps samhainrc.install
1470 else
1471 test -z "$verbose" || echo " mv -f samhainrc.pre samhainrc.install"
1472 mv -f samhainrc.pre samhainrc.install
1473 fi
1474
1475 tmp_configfile=`echo ${configfile} | sed 's%^REQ_FROM_SERVER%%'`
1476
1477 if test x"${tmp_configfile}" = x
1478 then
1479 echo " No local configfile to install."
1480 exit 0
1481 fi
1482
1483 if test -f ${DESTDIR}${tmp_configfile} && test x"$force" = x
1484 then
1485 echo " ${DESTDIR}${tmp_configfile} exists ... not overwritten (or use --force)"
1486 else
1487 test -z "$verbose" || echo " ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}"
1488 ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}
1489 fi
1490
1491 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1492 then
1493 test -z "$verbose" || echo " chown @myident@ ${DESTDIR}${tmp_configfile}"
1494 chown @myident@ ${DESTDIR}${tmp_configfile}
1495 fi
1496
1497 #
1498 # Changed: don't check if DESTDIR is set, as these are not
1499 # the true install locations anyway
1500 #
1501 if test -f trustfile && test x"${DESTDIR}" = x
1502 then
1503 test -z "$verbose" || echo " checking whether paths are trustworthy"
1504 RESULT=`./trustfile ${DESTDIR}${tmp_configfile} 2>&1`
1505 if test x$? != x0
1506 then
1507 echo
1508 ./trustfile ${DESTDIR}${tmp_configfile}
1509 echo
1510 else
1511 test -z "$verbose" || echo " configuration file ${DESTDIR}${tmp_configfile} ... OK"
1512 fi
1513
1514 RESULT=`./trustfile ${DESTDIR}${pid_dir} >/dev/null 2>&1`
1515 if test x$? != x0
1516 then
1517 echo
1518 ./trustfile ${DESTDIR}${pid_dir}
1519 echo
1520 else
1521 test -z "$verbose" || echo " state directory ${DESTDIR}${pid_dir} ... OK"
1522 fi
1523
1524 RESULT=`./trustfile ${DESTDIR}${mylogdir} >/dev/null 2>&1`
1525 if test x$? != x0
1526 then
1527 echo
1528 ./trustfile ${DESTDIR}${mylogdir}
1529 echo
1530 else
1531 test -z "$verbose" || echo " state directory ${DESTDIR}${mylogdir} ... OK"
1532 fi
1533
1534 RESULT=`./trustfile ${DESTDIR}${data_root} >/dev/null 2>&1`
1535 if test x$? != x0
1536 then
1537 echo
1538 ./trustfile ${DESTDIR}${data_root}
1539 echo
1540 else
1541 test -z "$verbose" || echo " data directory ${DESTDIR}${data_root} ... OK"
1542 fi
1543 fi
1544 # install_data
1545 exit 0
1546fi
1547
1548
Note: See TracBrowser for help on using the repository browser.