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

Last change on this file since 525 was 481, checked in by katerina, 9 years ago

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

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