source: trunk/samhain-install.sh.in@ 61

Last change on this file since 61 was 59, checked in by rainer, 18 years ago

Fix for exit status if database load fails; fix for problem with GrowingLogFiles if signed database is used; better support for *BSD init script installation.

File size: 39.6 KB
Line 
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
674 FreeBSD/* | NetBSD/* | OpenBSD/* )
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
759 IRIX*/*)
760 DVER="IRIX"
761 test -z "$verbose" || echo " IRIX system detected"
762 rc_main=${DESTDIR}/etc/init.d
763 rc_dirz=
764 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@; )"
765 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"
766 ;;
767
768 AIX/*)
769 DVER="AIX"
770 test -z "$verbose" || echo " AIX system detected"
771 ln -f -s @sbindir@/@install_name@ samhain.startAIX
772 rc_main=@sbindir@
773 rc_dirz=
774 rc_inst="/usr/sbin/mkitab -i '@install_name@:2:wait:@sbindir@/@install_name@ start >/dev/console 2>&1'"
775 rc_uinst="/usr/sbin/rmitab @install_name@"
776 ;;
777
778 HP-UX/*)
779 DVER="HPUX"
780 test -z "$verbose" || echo " HP-UX system detected"
781 rc_main=${DESTDIR}/sbin/init.d
782 rc_dirz=
783 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@; )"
784 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@"
785 ;;
786
787 OpenBSD/*)
788 test -z "$verbose" || echo " OpenBSD system detected"
789 grep '^## begin @install_name@' /etc/rc.local >/dev/null 2>&1
790 if [ $? -eq 0 ]; then
791 RCLOCALTMP=`mktemp /etc/rc.local.XXXXXXXXXX` || exit 1
792 sed "/^## begin @install_name@/,/^## end @install_name@/d" /etc/rc.local >$RCLOCALTMP || exit 1
793 cat $RCLOCALTMP >/etc/rc.local || exit 1
794 rm -f $RCLOCALTMP || exit 1
795 if test x"$act" = xuboot; then
796 echo " uninstalling from /etc/rc.local completed"
797 fi
798 fi
799 if test x"$act" = xboot; then
800 echo "## begin @install_name@" >>/etc/rc.local || exit 1
801 echo "if [ -x @sbindir@/@install_name@ ]; then" >>/etc/rc.local || exit 1
802 echo " @sbindir@/@install_name@ start" >>/etc/rc.local || exit 1
803 echo "fi" >>/etc/rc.local || exit 1
804 echo "## end @install_name@" >>/etc/rc.local || exit 1
805 echo " installing to /etc/rc.local completed"
806 fi
807 exit 0
808 ;;
809
810 NetBSD/*)
811 test -z "$verbose" || echo " NetBSD system detected"
812 if test -f /etc/rc.subr; then
813 DVER="FreeBSD"
814 rc_main=${DESTDIR}/etc/rc.d
815 rc_dirz=
816 rc_inst="chmod 755 /etc/rc.d/@install_name@"
817 rc_uinst="rm -f /etc/rc.d/@install_name@"
818 else
819 echo "${0}: unsupported platform ${platform} (too old)"
820 exit 1
821 fi
822 ;;
823
824 FreeBSD/* )
825 test -z "$verbose" || echo " FreeBSD system detected"
826 if test -f /etc/rc.subr; then
827 DVER="FreeBSD"
828 rc_main=${DESTDIR}/etc/rc.d
829 rc_dirz=
830 rc_inst="chmod 755 /etc/rc.d/@install_name@"
831 rc_uinst="rm -f /etc/rc.d/@install_name@"
832 else
833 DVER="Solaris"
834 rc_main=${DESTDIR}/usr/local/etc/rc.d
835 rc_dirz=
836 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"
837 rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh"
838 fi
839 if test x"$act" = xboot
840 then
841 if [ ! -d ${rc_main} ]; then
842 test x"$act" = xboot && mkdir ${rc_main}
843 fi
844 if test "x$DVER" = "xSolaris"; then
845 ( . /etc/defaults/rc.conf
846 . /etc/rc.conf
847 found=0
848 for p in ${local_startup-x}; do
849 if test "x$p" = "x${rc_main}"; then
850 found=1
851 break
852 fi
853 done
854 if test "x$found" = x0; then
855 cp -p /etc/rc.conf /etc/rc.conf.bak
856 (
857 grep -v local_startup /etc/rc.conf.bak
858 echo "local_startup=\"${rc_main} $local_startup\""
859 ) >/etc/rc.conf
860 fi
861 )
862 fi
863 fi
864 ;;
865
866 SunOS/5.* )
867 DVER="Solaris"
868 DVER_REAL="Solaris"
869 test -z "$verbose" || echo " Solaris system detected"
870 rc_dirz=
871 rc_main=${DESTDIR}/etc/init.d
872 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@; )"
873 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@"
874 ;;
875
876 Linux/*)
877 rlv="2 3 4 5"
878 linkopt="-f -s"
879 # find rc directories
880 if test -f /usr/lib/lsb/install_initd && test -d /etc/init.d
881 then
882 test -z "$verbose" || echo " Linux Standard Base system detected"
883 DVER=LSB
884 if test x"$DESTDIR" = x
885 then
886 rc_main=/etc/init.d
887 rc_dirz=
888 rc_inst="/usr/lib/lsb/install_initd /etc/init.d/@install_name@"
889 rc_uinst="/usr/lib/lsb/remove_initd /etc/init.d/@install_name@"
890 else
891 rc_inst=
892 rc_uinst=
893 rc_main=${DESTDIR}/etc/init.d
894 rc_dirz=
895 # test -d /etc/init.d/rc2.d && rc_dirz=${DESTDIR}/etc/init.d/rc
896 # test -d /etc/rc.d/rc2.d && rc_dirz=${DESTDIR}/etc/rc.d/rc
897 # test -d /etc/rc2.d && rc_dirz=${DESTDIR}/etc/rc
898 fi
899 elif test -f /etc/SuSE-release
900 then
901 test -z "$verbose" || echo " SuSE system detected"
902 DVER="Linux"
903 rc_inst=
904 rc_uinst=
905 if test -d /sbin/init.d && test -d /sbin/init.d/rc2.d
906 then
907 test -z "$verbose" || echo " SuSE 6.x system detected"
908 rc_main=${DESTDIR}/sbin/init.d
909 rc_dirz=${DESTDIR}/sbin/init.d/rc
910 elif test -d /etc/init.d && test -d /etc/init.d/rc2.d
911 then
912 test -z "$verbose" || echo " SuSE 7.x or newer detected"
913 rc_main=${DESTDIR}/etc/init.d
914 rc_dirz=${DESTDIR}/etc/init.d/rc
915 else
916 echo "${0}: unknown system"
917 exit 1
918 fi
919 elif test -d /sbin/init.d && test -d /sbin/init.d/rc2.d
920 then
921 DVER="Linux"
922 rc_inst=
923 rc_uinst=
924 test -z "$verbose" || echo " SuSE 5.x system detected"
925 rc_main=${DESTDIR}/sbin/init.d
926 rc_dirz=${DESTDIR}/sbin/init.d/rc
927 elif test -f /etc/debian_version
928 then
929 DVER="Linux"
930 test -z "$verbose" || echo " Debian based system detected"
931 if test x"$DESTDIR" = x
932 then
933 rc_main=/etc/init.d
934 rc_dirz=
935 rc_uinst="/usr/sbin/update-rc.d -f @install_name@ remove"
936 rc_inst="/usr/sbin/update-rc.d @install_name@ defaults 99 10"
937 else
938 rc_inst=
939 rc_uinst=
940 rc_main=${DESTDIR}/etc/init.d
941 # rc_dirz=${DESTDIR}/etc/rc
942 rc_dirz=
943 fi
944 elif test -f /etc/redhat-release
945 then
946 DVER="Linux"
947 test -z "$verbose" || echo " Redhat based system detected"
948 rc_uinst=
949 rc_inst=
950 rc_main=${DESTDIR}/etc/rc.d/init.d
951 rc_dirz=${DESTDIR}/etc/rc.d/rc
952 elif test -f /etc/mandrake-release
953 then
954 DVER="Linux"
955 test -z "$verbose" || echo " Mandrake based system detected"
956 rc_uinst=
957 rc_inst=
958 rc_main=${DESTDIR}/etc/rc.d/init.d
959 rc_dirz=${DESTDIR}/etc/rc.d/rc
960 elif test -f /etc/yellowdog-release
961 then
962 DVER="Linux"
963 test -z "$verbose" || echo " Yellow Dog based system detected"
964 rc_uinst=
965 rc_inst=
966 rc_main=${DESTDIR}/etc/rc.d/init.d
967 rc_dirz=${DESTDIR}/etc/rc.d/rc
968 elif test -f /etc/slackware-version && test -f /etc/rc.d/rc.sysvinit
969 then
970 DVER="Linux"
971 test -z "$verbose" || echo " Slackware based system detected"
972 rc_uinst=
973 rc_inst=
974 rc_main=${DESTDIR}/etc/rc.d
975 rc_dirz=${DESTDIR}/etc/rc.d/rc
976 elif test -f /etc/gentoo-release
977 then
978 DVER="Gentoo"
979 test -z "$verbose" || echo " Gentoo based system detected"
980 rc_uinst="/sbin/rc-update del @install_name@"
981 rc_inst="/sbin/rc-update add @install_name@ default"
982 rc_main=${DESTDIR}/etc/init.d
983 rc_dirz=
984 else
985 echo "${0}: unknown Linux distribution"
986 rc_uinst=
987 rc_inst=
988 rc_main=
989 rc_dirz=
990 for ff in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
991 if test -d $ff; then
992 rc_main="$ff"
993 break
994 fi
995 done
996 for fg in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
997 if test -d $fg; then
998 rc_dirz="`echo $fg | sed -e 's,2.*,,'`"
999 break
1000 fi
1001 done
1002 if [ x"${rc_dirz}" = x ]; then
1003 echo "${0}: no install directory for runlevel scripts found"
1004 exit 1
1005 fi
1006 if [ x"${rc_main}" = x ]; then
1007 echo "${0}: no install directory for runlevel scripts found"
1008 exit 1
1009 fi
1010 DVER="Linux"
1011 rc_main="${DESTDIR}${rc_main}"
1012 rc_dirz="${DESTDIR}${rc_dirz}"
1013 fi
1014 ;;
1015
1016 *)
1017 echo "${0}: unsupported platform ${platform}"
1018 exit 1
1019 ;;
1020 esac
1021
1022 if test x"${rc_main}" = x
1023 then
1024 echo "${0}: no install directory for runlevel scripts found"
1025 exit 1
1026 fi
1027
1028 if test x"${act}" = xboot
1029 then
1030
1031 startscript=NONE
1032 if test -f init/samhain.start${DVER}
1033 then
1034 startscript=`eval echo init/samhain.start${DVER}`
1035 elif test -f samhain.start${DVER}
1036 then
1037 startscript=`eval echo samhain.start${DVER}`
1038 else
1039 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1040 exit 1
1041 fi
1042
1043 if test "x${startscript}" = xNONE; then
1044 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1045 exit 1
1046 else
1047 if test -f ${rc_main}/${samhain} && test x"$force" != xyes
1048 then
1049 echo " ${rc_main}/${samhain} exists ... not overwritten (or use --force)"
1050 else
1051 if test x"$DESTDIR" = x
1052 then
1053 :
1054 else
1055 ${mkinstalldirs} ${rc_main}
1056 #
1057 if test x"${DVER_REAL}" = xSolaris; then
1058 ${mkinstalldirs} ${DESTDIR}/etc/rc0.d
1059 ${mkinstalldirs} ${DESTDIR}/etc/rc1.d
1060 ${mkinstalldirs} ${DESTDIR}/etc/rc3.d
1061 fi
1062 #
1063 fi
1064 test -z "$verbose" || echo " ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}"
1065 if test -f "@INSTALL@"; then
1066 ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}
1067 else
1068 cp ${startscript} ${rc_main}/${samhain} && chmod 0700 ${rc_main}/${samhain}
1069 fi
1070 fi
1071 fi
1072
1073
1074 if test x"${rc_dirz}" != x
1075 then
1076 for ff in $rlv
1077 do
1078 if test x"${DESTDIR}" = x
1079 then
1080 rldir="${rc_dirz}${ff}.d/"
1081 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain}"
1082 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain})
1083 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain}"
1084 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain})
1085 else
1086 :
1087 # ${mkinstalldirs} ${rc_dirz}${ff}.d
1088 fi
1089
1090
1091 done
1092 fi
1093
1094 if test x"${rc_inst}" != x
1095 then
1096 if test x"${DESTDIR}" = x
1097 then
1098 test -z "$verbose" || echo " ${rc_inst}"
1099 eval ${rc_inst}
1100 fi
1101 fi
1102 echo "installing init scripts completed"
1103 fi
1104
1105 if test x"${act}" = xuboot
1106 then
1107 if test x"${rc_uinst}" != x
1108 then
1109 test -z "$verbose" || echo " ${rc_uinst}"
1110 echo
1111 eval ${rc_uinst}
1112 fi
1113
1114 if test x"${rc_dirz}" != x
1115 then
1116 for ff in $rlv
1117 do
1118 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1119 rm -f ${rc_dirz}${ff}.d/S99${samhain}
1120 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1121 rm -f ${rc_dirz}${ff}.d/K10${samhain}
1122 done
1123 fi
1124
1125 test -z "$verbose" || echo " rm -f ${rc_main}/${samhain}"
1126 rm -f ${rc_main}/${samhain}
1127
1128 echo " uninstalling init scripts completed"
1129 fi
1130
1131 # boot_install|boot_uninstall completed
1132 exit 0
1133fi
1134
1135if test x"${act}" = xulkm
1136then
1137 RVER=`uname -r`
1138 if test "x@sh_lkm@" != "x"; then
1139 if test -d /lib/modules/$RVER; then
1140 MODDIR="/lib/modules/$RVER"
1141 elif test -d /lib/modules/misc; then
1142 MODDIR="/lib/modules/misc"
1143 elif test -d /lib/modules; then
1144 MODDIR="/lib/modules/misc"
1145 fi
1146 # -- NEW --
1147 ALLMODS="@sh_lkm@"
1148 for p in $ALLMODS; do
1149 test -z "$verbose" || echo " rm -f ${DESTDIR}${MODDIR}/`echo $p|sed '
1150s%samhain%@install_name@%'`"
1151 rm -f ${DESTDIR}${MODDIR}/`echo $p|sed 's%samhain%@install_name@%'`
1152 done
1153 fi
1154fi
1155
1156if test x"${act}" = xuprogram
1157then
1158 PROGRAMS="@setpwd_prg@ @stegin_prg@ @yulectl_prg@ @sh_main_prg@"
1159 for p in $PROGRAMS; do
1160 test -z "$verbose" || echo " rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"
1161 rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`
1162 done
1163 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sbindir} ... $ECHO_C"
1164 ${SH_RMDIR} ${DESTDIR}${sbindir} >/dev/null 2>&1
1165 if test x$? = x0; then
1166 test -z "$verbose" || echo "${ECHO_T}done"
1167 else
1168 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1169 fi
1170 exit 0
1171fi
1172
1173if test x"${act}" = xuman
1174then
1175 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man8/@install_name@.8"
1176 rm -f ${DESTDIR}${mandir}/man8/@install_name@.8
1177 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5"
1178 rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5
1179
1180 OLD_IFS=${IFS}
1181 IFS=':'; export IFS
1182 for ff in ${MANPATH}; do
1183 if test x"$ff/man8" = x"${DESTDIR}${mandir}/man8"; then
1184 echo " man directory ${DESTDIR}${mandir} is in your MANPATH"
1185 echo " -- will not try to remove"
1186 IFS=${OLD_IFS}; export IFS
1187 exit 0
1188 fi
1189 done
1190 IFS=${OLD_IFS}; export IFS
1191
1192 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man8 ... $ECHO_C"
1193 ${SH_RMDIR} ${DESTDIR}${mandir}/man8 >/dev/null 2>&1
1194 if test x$? = x0; then
1195 test -z "$verbose" || echo "${ECHO_T}done"
1196 else
1197 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1198 fi
1199
1200 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man5 ... $ECHO_C"
1201 ${SH_RMDIR} ${DESTDIR}${mandir}/man5 >/dev/null 2>&1
1202 if test x$? = x0; then
1203 test -z "$verbose" || echo "${ECHO_T}done"
1204 else
1205 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1206 fi
1207
1208 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir} ... $ECHO_C"
1209 ${SH_RMDIR} ${DESTDIR}${mandir} >/dev/null 2>&1
1210 if test x$? = x0; then
1211 test -z "$verbose" || echo "${ECHO_T}done"
1212 else
1213 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1214 fi
1215
1216 exit 0
1217fi
1218
1219if test x"${act}" = xudata
1220then
1221 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`"
1222 rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`
1223 test -z "$verbose" || echo " rm -f ${DESTDIR}${pid_file}"
1224 rm -f ${DESTDIR}${pid_file}
1225 test -z "$verbose" || echo " rm -f ${DESTDIR}${mylogfile}"
1226 rm -f ${DESTDIR}${mylogfile}
1227 test -z "$verbose" || echo " rm -f ${DESTDIR}${myhtmlfile}"
1228 rm -f ${DESTDIR}${myhtmlfile}
1229
1230 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${pid_dir} ... $ECHO_C"
1231 ${SH_RMDIR} ${DESTDIR}${pid_dir} >/dev/null 2>&1
1232 if test x$? = x0; then
1233 test -z "$verbose" || echo "${ECHO_T}done"
1234 else
1235 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1236 fi
1237
1238 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mylogdir} ... $ECHO_C"
1239 ${SH_RMDIR} ${DESTDIR}${mylogdir} >/dev/null 2>&1
1240 if test x$? = x0; then
1241 test -z "$verbose" || echo "${ECHO_T}done"
1242 else
1243 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1244 fi
1245
1246 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${data_root} ... $ECHO_C"
1247 ${SH_RMDIR} ${DESTDIR}${data_root} >/dev/null 2>&1
1248 if test x$? = x0; then
1249 test -z "$verbose" || echo "${ECHO_T}done"
1250 else
1251 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1252 fi
1253
1254 if test x"$force" = "xyes"
1255 then
1256 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1257 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1258 elif test x"$purge" = "xyes"
1259 then
1260 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1261 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1262 elif test x"$express" = x; then
1263 echo " Do you want to remove the configuration file [y/n] ?"
1264 while [ "1" = "1" ]; do
1265 read ff
1266 case "$ff" in
1267 Y* | y* )
1268 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1269 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1270 break
1271 ;;
1272 N* | n* )
1273 test -z "$verbose" || echo " ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` NOT removed"
1274 break
1275 ;;
1276 *)
1277 echo " Enter y[es] or n[o]"
1278 ;;
1279 esac
1280 done
1281 else
1282 test -z "$verbose" || echo " NOT REMOVED: config file ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` (use --force to remove)"
1283 fi
1284
1285 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sysconfdir} ... $ECHO_C"
1286 ${SH_RMDIR} ${DESTDIR}${sysconfdir} >/dev/null 2>&1
1287 if test x$? = x0; then
1288 test -z "$verbose" || echo "${ECHO_T}done"
1289 else
1290 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1291 fi
1292
1293 exit 0
1294fi
1295
1296if test x"${act}" = xdata
1297then
1298 STEGIN=@stegin_prg@
1299 CONVERT=
1300
1301 GPGPATH=@mygpg@
1302
1303 NTEST=@mytclient@
1304
1305 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1306 then
1307 RCFILE=yulerc
1308 if test -f $RCFILE
1309 then
1310 :
1311 else
1312 if test -f yulerc.template
1313 then
1314 cp yulerc.template $RCFILE
1315 fi
1316 fi
1317 else
1318 RCFILE=samhainrc
1319 IN_RCFILE=samhainrc.@selectconfig@
1320
1321 if test -f ${RCFILE}
1322 then
1323 :
1324 else
1325 if test -f ${IN_RCFILE}
1326 then
1327 test -z "$verbose" || echo " cp ${IN_RCFILE} ${RCFILE}"
1328 cp ${IN_RCFILE} ${RCFILE}
1329 fi
1330 fi
1331 fi
1332
1333 if test -f $RCFILE
1334 then
1335 :
1336 else
1337 echo "${0}: cannot find configuration file $RCFILE"
1338 exit 1
1339 fi
1340
1341 if test x"${GPGPATH}" != x
1342 then
1343 echo
1344 echo "You need to sign the config file now"
1345 echo
1346 test -z "$verbose" || echo " ${GPGPATH} -a --clearsign $RCFILE"
1347 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1348 then
1349 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1350 grep "^${samhain}:" | awk -F: '{ print $3; }'`
1351 if test x"${myident_uid}" != x
1352 then
1353 DOT_GNUPG=`eval echo ~${samhain}/.gnupg`
1354 test -z "$verbose" || echo " using --homedir ${DOT_GNUPG}"
1355 ${GPGPATH} --homedir ${DOT_GNUPG} -a --clearsign $RCFILE
1356 else
1357 ${GPGPATH} -a --clearsign $RCFILE
1358 fi
1359 else
1360 ${GPGPATH} -a --clearsign $RCFILE
1361 fi
1362
1363 if test -f ${RCFILE}.asc
1364 then
1365 test -z "$verbose" || echo " mv -f ${RCFILE}.asc samhainrc.pre"
1366 mv -f ${RCFILE}.asc samhainrc.pre
1367 else
1368 echo "**********************************************************"
1369 echo
1370 echo "${0}: ERROR: cannot find signed file ${RCFILE}.asc"
1371 echo
1372 echo " --- You need to sign the configuration file ---"
1373 echo
1374 echo "**********************************************************"
1375 cp ${RCFILE} samhainrc.pre
1376 fi
1377 else
1378 test -z "$verbose" || echo " cp $RCFILE samhainrc.pre"
1379 cp $RCFILE samhainrc.pre
1380 fi
1381
1382 if test x"${STEGIN}" != x
1383 then
1384 test -z "$verbose" || echo " searching for ImageMagick convert utility"
1385 OPATH=${PATH}
1386 PATH="/usr/local/bin:/usr/X11R6/bin:"${PATH}
1387
1388 OIFS=${IFS}
1389 IFS=":"
1390
1391 for dd in ${PATH}
1392 do
1393 if test -f "${dd}/convert"
1394 then
1395 "${dd}/convert" --help | grep ImageMagick >/dev/null 2>&1 && \
1396 CONVERT="${dd}/convert"
1397 test -z "$verbose" || echo " CONVERT=${dd}/convert"
1398 fi
1399 done
1400
1401 IFS=${OIFS}
1402
1403 if test x"${CONVERT}" = x
1404 then
1405 echo "${0}: cannot find ImageMagick convert utility in PATH=${PATH}"
1406 exit 1
1407 fi
1408
1409 PATH=${OPATH}
1410
1411 if test -f stealth_template.jpg
1412 then
1413 test -z "$verbose" || echo " ${CONVERT} +compress stealth_template.jpg stealth_template.ps"
1414 "${CONVERT}" +compress stealth_template.jpg stealth_template.ps
1415 else
1416 echo "${0}: cannot find file stealth_template.jpg"
1417 exit 1
1418 fi
1419
1420
1421 if test -f stealth_template.ps
1422 then
1423 :
1424 else
1425 echo "${0}: file stealth_template.ps not created"
1426 exit 1
1427 fi
1428
1429 if test -f samhainrc.pre
1430 then
1431 :
1432 else
1433 echo "${0}: cannot find configuration file samhainrc.pre"
1434 exit 1
1435 fi
1436
1437 if test -f ./samhain_stealth
1438 then
1439 :
1440 else
1441 echo "${0}: cannot find utility ./samhain_stealth"
1442 exit 1
1443 fi
1444
1445 ccount=`./samhain_stealth -o samhainrc.pre 2>&1 | awk '{ print $1 }'`
1446 mcount=`./samhain_stealth -i stealth_template.ps 2>&1 | awk '{ print $7 }'`
1447
1448 if test ${mcount} -lt ${ccount}
1449 then
1450 echo "${0}: configuration file samhainrc too big,"
1451 echo " need a larger image stealth_template.jpg to store"
1452 exit 1
1453 fi
1454
1455 test -z "$verbose" || echo " ./samhain_stealth -s stealth_template.ps samhainrc.pre"
1456 ./samhain_stealth -s stealth_template.ps samhainrc.pre
1457
1458 test -z "$verbose" || echo " mv -f stealth_template.ps samhainrc.install"
1459 mv -f stealth_template.ps samhainrc.install
1460 else
1461 test -z "$verbose" || echo " mv -f samhainrc.pre samhainrc.install"
1462 mv -f samhainrc.pre samhainrc.install
1463 fi
1464
1465 tmp_configfile=`echo ${configfile} | sed 's%^REQ_FROM_SERVER%%'`
1466
1467 if test x"${tmp_configfile}" = x
1468 then
1469 echo " No local configfile to install."
1470 exit 0
1471 fi
1472
1473 if test -f ${DESTDIR}${tmp_configfile} && test x"$force" = x
1474 then
1475 echo " ${DESTDIR}${tmp_configfile} exists ... not overwritten (or use --force)"
1476 else
1477 test -z "$verbose" || echo " ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}"
1478 ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}
1479 fi
1480
1481 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1482 then
1483 test -z "$verbose" || echo " chown @myident@ ${DESTDIR}${tmp_configfile}"
1484 chown @myident@ ${DESTDIR}${tmp_configfile}
1485 fi
1486
1487 #
1488 # Changed: don't check if DESTDIR is set, as these are not
1489 # the true install locations anyway
1490 #
1491 if test -f trustfile && test x"${DESTDIR}" = x
1492 then
1493 test -z "$verbose" || echo " checking whether paths are trustworthy"
1494 RESULT=`./trustfile ${DESTDIR}${tmp_configfile} 2>&1`
1495 if test x$? != x0
1496 then
1497 echo
1498 ./trustfile ${DESTDIR}${tmp_configfile}
1499 echo
1500 else
1501 test -z "$verbose" || echo " configuration file ${DESTDIR}${tmp_configfile} ... OK"
1502 fi
1503
1504 RESULT=`./trustfile ${DESTDIR}${pid_dir} >/dev/null 2>&1`
1505 if test x$? != x0
1506 then
1507 echo
1508 ./trustfile ${DESTDIR}${pid_dir}
1509 echo
1510 else
1511 test -z "$verbose" || echo " state directory ${DESTDIR}${pid_dir} ... OK"
1512 fi
1513
1514 RESULT=`./trustfile ${DESTDIR}${mylogdir} >/dev/null 2>&1`
1515 if test x$? != x0
1516 then
1517 echo
1518 ./trustfile ${DESTDIR}${mylogdir}
1519 echo
1520 else
1521 test -z "$verbose" || echo " state directory ${DESTDIR}${mylogdir} ... OK"
1522 fi
1523
1524 RESULT=`./trustfile ${DESTDIR}${data_root} >/dev/null 2>&1`
1525 if test x$? != x0
1526 then
1527 echo
1528 ./trustfile ${DESTDIR}${data_root}
1529 echo
1530 else
1531 test -z "$verbose" || echo " data directory ${DESTDIR}${data_root} ... OK"
1532 fi
1533 fi
1534 # install_data
1535 exit 0
1536fi
1537
1538
Note: See TracBrowser for help on using the repository browser.