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

Last change on this file since 293 was 203, checked in by katerina, 16 years ago

Fix compile failures on RHEL3 (ticket #130) and FreeBSD7 amd64 (ticket #131).

File size: 40.5 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
[170]29datarootdir=@datarootdir@
30
[1]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|uninstall-lkm'
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-lkm)
517 act=ulkm
518 break;;
519
520 uninstall | remove | purge)
521 opts=
522 test x"$verbose" = "xyes" && opts="$opts --verbose"
523 test x"$express" = "xyes" && opts="$opts --express"
524 test x"$force" = "xyes" && opts="$opts --force"
525 test x"$DESTDIR" = "x" || opts="$opts --destdir=$DESTDIR"
526 test x"$1" = "xpurge" && purge=yes
527 echo "$0 $opts uninstall-lkm"
528 eval $0 $opts uninstall-lkm
529 echo "$0 $opts uninstall-program"
530 eval $0 $opts uninstall-program
531 echo "$0 $opts uninstall-man"
532 eval $0 $opts uninstall-man
533 if test x"$force" = "x"; then
534 test "x$purge" = xyes && opts="$opts --force"
535 fi
536 echo "$0 $opts uninstall-data"
537 eval $0 $opts uninstall-data
538 echo
539 echo " To uninstall the runlevel scripts, use $0 $opts uninstall-boot"
540 echo
541 exit 0
542 ;;
543 *)
544 echo "Unknown option $1"
545 exit 1
546 ;;
547
548 esac
549done
550
551if test x"$act" = xuser
552then
553
554# -- the routines for installing a new user are adapted from
555# the OpenPKG bootstrap installation script, which is distributed
556# under the following license:
557
558## Shell-based package for OpenPKG BINARY bootstrap installation
559## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
560## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
561## Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
562##
563## Permission to use, copy, modify, and distribute this software for
564## any purpose with or without fee is hereby granted, provided that
565## the above copyright notice and this permission notice appear in all
566## copies.
567##
568## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
569## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
570## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
571## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
572## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
573## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
574## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
575## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
576## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
577## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
578## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
579## SUCH DAMAGE.
580
581 if test x"$user" = x
582 then
583 echo "**ERROR**: No username specified"
584 exit 1
585 fi
586
587 s=`uname -s 2>/dev/null` || s='Unknown'
588 r=`uname -r 2>/dev/null` || r='0.0'
589 platform="${s}/${r}"
590
591 if test x"$user" = xnobody; then
592 case "$platform" in
593 HP-UX/* )
594 group="nogroup"
595 ;;
596 *)
597 group="nobody"
598 ;;
599 esac
600 else
601 group="$user"
602 fi
603 shell=/bin/false
604 if test -f /etc/shells
605 then
606 grep "^/usr/bin/false" /etc/shells >/dev/null 2>&1 && shell=/usr/bin/false
607 grep "^/bin/nologin" /etc/shells >/dev/null 2>&1 && shell=/bin/nologin
608 grep "^/sbin/nologin" /etc/shells >/dev/null 2>&1 && shell=/sbin/nologin
609 fi
610 home="${data_root}"
611
612 xuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
613 grep "^${user}:" | awk -F: '{ print $3; }'`
614 if test "x$xuid" = x
615 then
616 # seek for a reasonable uid/gid pair
617 xuid=1000
618 ok=0
619 while test "x$ok" = x0
620 do
621 eval "u_exists=\$u_exists_$xuid"
622 if test "x$u_exists" = x
623 then
624 u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
625 fi
626 eval "g_exists=\$g_exists_$xuid"
627 if test "x$g_exists" = x
628 then
629 g_exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
630 fi
631 if [ "x$u_exists" = x -a "x$g_exists" = x ]; then
632 ok=1
633 break
634 fi
635 xuid=`expr $xuid + 1`
636 done
637 eval "u_exists_$xuid=yes"
638 eval "g_exists_$xuid=yes"
639 else
640 # user exists
641 xgid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
642 grep "^${user}:" | awk -F: '{ print $4; }'`
643 fi
644
645 if test "x$xgid" = x
646 then
647 xgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
648 grep "^${group}:" | awk -F: '{ print $3; }'`
649 fi
650
651 if test "x$xgid" = x
652 then
653 xgid="$xuid"
654 g_exists=no
655 else
656 g_exists=yes
657 fi
658
659 uid=$xuid
660 gid=$xgid
661
662 if test -f /etc/shells
663 then
664 exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
665 if test "x$exists" = x; then
666 echo "${shell}" >>/etc/shells
667 test -z "$verbose" || echo " Added ${shell} to /etc/shells"
668 fi
669 fi
670
671 exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^$user:"`
672 if test x"$exists" = x; then
673 # add entry to passwd database
674 realname="$user"
675 case "$platform" in
[59]676 FreeBSD/* | NetBSD/* | OpenBSD/* )
[1]677 file=/etc/master.passwd
678 entry="${user}:*:${uid}:${gid}::0:0:${realname}:${home}:${shell}"
679 update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
680 break
681 ;;
682 Linux/* )
683 file=/etc/passwd
684 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
685 update="(PATH=\$PATH:/usr/sbin; pwconv)"
686 break
687 ;;
688 SunOS/5.* )
689 file=/etc/passwd
690 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
691 update="(PATH=\$PATH:/usr/sbin; pwconv)"
692 break
693 ;;
694 OSF1/V5.* )
695 file=/etc/passwd
696 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
697 update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
698 break
699 ;;
700 HP-UX/* )
701 file=/etc/passwd
702 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
703 update=":"
704 break
705 ;;
706 IRIX*/* )
707 file=/etc/passwd
708 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}"
709 update=":"
710 break
711 ;;
712 *)
713 echo "install-user: Unsupported system $platform"
714 echo "Please add user $user / group $group manually"
715 echo " and re-run make install-user"
716 exit 1
717 ;;
718 esac
719 cp $file $file.bak && \
720 (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
721 rm -f $file.bak >/dev/null 2>&1
722 eval $update
723 test -z "$verbose" || echo " Added user: ${user} uid: ${uid} shell: ${shell}"
724 else
725 test -z "$verbose" || echo " User ${user} exists already"
726 fi
727
728 # check whether group already exists
729 # FIXME
730 exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$group:"`
731 if test x"$exists" = x
732 then
733 #
734 # user has a valid GID
735 #
736 if test g_exists = xyes; then
737 exists=yes
738 fi
739 fi
740 if test x"$exists" = x
741 then
742 # add entry to group database
743 file=/etc/group
744 entry="${group}:*:${gid}:${user}"
745 cp $file $file.bak && \
746 (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
747 rm -f $file.bak >/dev/null 2>&1
748 test -z "$verbose" || echo " Added group: ${group} gid: ${gid} user: ${user}"
749 fi
750
751 exit 0
752fi
753
754if test x"$act" = xboot || test x"$act" = xuboot
755then
756 s=`uname -s 2>/dev/null` || s='Unknown'
757 r=`uname -r 2>/dev/null` || r='0.0'
758 platform="${s}/${r}"
759
760 case "$platform" in
[71]761 Darwin/*)
762 DVER="MACOSX"
763 test -z "$verbose" || echo "MacOS X system detected"
764 rc_main="/Library/StartupItems/${samhain}"
765 ${mkinstalldirs} ${rc_main}
766 rc_dirz=
767 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; )"
768 rc_uinst="rm -rf /Library/StartupItems/@install_name@"
769 ;;
770
[1]771 IRIX*/*)
772 DVER="IRIX"
773 test -z "$verbose" || echo " IRIX system detected"
774 rc_main=${DESTDIR}/etc/init.d
775 rc_dirz=
776 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@; )"
777 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"
778 ;;
779
780 AIX/*)
781 DVER="AIX"
782 test -z "$verbose" || echo " AIX system detected"
783 ln -f -s @sbindir@/@install_name@ samhain.startAIX
784 rc_main=@sbindir@
785 rc_dirz=
786 rc_inst="/usr/sbin/mkitab -i '@install_name@:2:wait:@sbindir@/@install_name@ start >/dev/console 2>&1'"
787 rc_uinst="/usr/sbin/rmitab @install_name@"
788 ;;
789
790 HP-UX/*)
791 DVER="HPUX"
792 test -z "$verbose" || echo " HP-UX system detected"
793 rc_main=${DESTDIR}/sbin/init.d
794 rc_dirz=
795 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@; )"
796 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@"
797 ;;
798
[59]799 OpenBSD/*)
800 test -z "$verbose" || echo " OpenBSD system detected"
801 grep '^## begin @install_name@' /etc/rc.local >/dev/null 2>&1
802 if [ $? -eq 0 ]; then
803 RCLOCALTMP=`mktemp /etc/rc.local.XXXXXXXXXX` || exit 1
804 sed "/^## begin @install_name@/,/^## end @install_name@/d" /etc/rc.local >$RCLOCALTMP || exit 1
805 cat $RCLOCALTMP >/etc/rc.local || exit 1
806 rm -f $RCLOCALTMP || exit 1
807 if test x"$act" = xuboot; then
808 echo " uninstalling from /etc/rc.local completed"
809 fi
810 fi
811 if test x"$act" = xboot; then
812 echo "## begin @install_name@" >>/etc/rc.local || exit 1
813 echo "if [ -x @sbindir@/@install_name@ ]; then" >>/etc/rc.local || exit 1
814 echo " @sbindir@/@install_name@ start" >>/etc/rc.local || exit 1
815 echo "fi" >>/etc/rc.local || exit 1
816 echo "## end @install_name@" >>/etc/rc.local || exit 1
817 echo " installing to /etc/rc.local completed"
818 fi
819 exit 0
820 ;;
821
822 NetBSD/*)
823 test -z "$verbose" || echo " NetBSD system detected"
824 if test -f /etc/rc.subr; then
825 DVER="FreeBSD"
826 rc_main=${DESTDIR}/etc/rc.d
827 rc_dirz=
828 rc_inst="chmod 755 /etc/rc.d/@install_name@"
829 rc_uinst="rm -f /etc/rc.d/@install_name@"
830 else
831 echo "${0}: unsupported platform ${platform} (too old)"
832 exit 1
833 fi
834 ;;
835
[1]836 FreeBSD/* )
837 test -z "$verbose" || echo " FreeBSD system detected"
[59]838 if test -f /etc/rc.subr; then
839 DVER="FreeBSD"
840 rc_main=${DESTDIR}/etc/rc.d
841 rc_dirz=
842 rc_inst="chmod 755 /etc/rc.d/@install_name@"
843 rc_uinst="rm -f /etc/rc.d/@install_name@"
844 else
845 DVER="Solaris"
846 rc_main=${DESTDIR}/usr/local/etc/rc.d
847 rc_dirz=
848 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"
849 rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh"
850 fi
[1]851 if test x"$act" = xboot
852 then
853 if [ ! -d ${rc_main} ]; then
854 test x"$act" = xboot && mkdir ${rc_main}
855 fi
[59]856 if test "x$DVER" = "xSolaris"; then
[1]857 ( . /etc/defaults/rc.conf
858 . /etc/rc.conf
859 found=0
860 for p in ${local_startup-x}; do
861 if test "x$p" = "x${rc_main}"; then
862 found=1
863 break
864 fi
865 done
866 if test "x$found" = x0; then
867 cp -p /etc/rc.conf /etc/rc.conf.bak
868 (
869 grep -v local_startup /etc/rc.conf.bak
870 echo "local_startup=\"${rc_main} $local_startup\""
871 ) >/etc/rc.conf
872 fi
873 )
[59]874 fi
875 fi
[1]876 ;;
[59]877
[1]878 SunOS/5.* )
879 DVER="Solaris"
[59]880 DVER_REAL="Solaris"
[1]881 test -z "$verbose" || echo " Solaris system detected"
882 rc_dirz=
883 rc_main=${DESTDIR}/etc/init.d
884 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@; )"
885 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@"
886 ;;
[59]887
[1]888 Linux/*)
889 rlv="2 3 4 5"
890 linkopt="-f -s"
891 # find rc directories
892 if test -f /usr/lib/lsb/install_initd && test -d /etc/init.d
893 then
894 test -z "$verbose" || echo " Linux Standard Base system detected"
895 DVER=LSB
896 if test x"$DESTDIR" = x
897 then
898 rc_main=/etc/init.d
899 rc_dirz=
900 rc_inst="/usr/lib/lsb/install_initd /etc/init.d/@install_name@"
901 rc_uinst="/usr/lib/lsb/remove_initd /etc/init.d/@install_name@"
902 else
903 rc_inst=
904 rc_uinst=
905 rc_main=${DESTDIR}/etc/init.d
906 rc_dirz=
907 # test -d /etc/init.d/rc2.d && rc_dirz=${DESTDIR}/etc/init.d/rc
908 # test -d /etc/rc.d/rc2.d && rc_dirz=${DESTDIR}/etc/rc.d/rc
909 # test -d /etc/rc2.d && rc_dirz=${DESTDIR}/etc/rc
910 fi
911 elif test -f /etc/SuSE-release
912 then
913 test -z "$verbose" || echo " SuSE system detected"
914 DVER="Linux"
915 rc_inst=
916 rc_uinst=
917 if test -d /sbin/init.d && test -d /sbin/init.d/rc2.d
918 then
919 test -z "$verbose" || echo " SuSE 6.x system detected"
920 rc_main=${DESTDIR}/sbin/init.d
921 rc_dirz=${DESTDIR}/sbin/init.d/rc
922 elif test -d /etc/init.d && test -d /etc/init.d/rc2.d
923 then
924 test -z "$verbose" || echo " SuSE 7.x or newer detected"
925 rc_main=${DESTDIR}/etc/init.d
926 rc_dirz=${DESTDIR}/etc/init.d/rc
927 else
928 echo "${0}: unknown system"
929 exit 1
930 fi
931 elif test -d /sbin/init.d && test -d /sbin/init.d/rc2.d
932 then
933 DVER="Linux"
934 rc_inst=
935 rc_uinst=
936 test -z "$verbose" || echo " SuSE 5.x system detected"
937 rc_main=${DESTDIR}/sbin/init.d
938 rc_dirz=${DESTDIR}/sbin/init.d/rc
939 elif test -f /etc/debian_version
940 then
941 DVER="Linux"
942 test -z "$verbose" || echo " Debian based system detected"
943 if test x"$DESTDIR" = x
944 then
945 rc_main=/etc/init.d
946 rc_dirz=
947 rc_uinst="/usr/sbin/update-rc.d -f @install_name@ remove"
948 rc_inst="/usr/sbin/update-rc.d @install_name@ defaults 99 10"
949 else
950 rc_inst=
951 rc_uinst=
952 rc_main=${DESTDIR}/etc/init.d
953 # rc_dirz=${DESTDIR}/etc/rc
954 rc_dirz=
955 fi
956 elif test -f /etc/redhat-release
957 then
958 DVER="Linux"
959 test -z "$verbose" || echo " Redhat based system detected"
960 rc_uinst=
961 rc_inst=
962 rc_main=${DESTDIR}/etc/rc.d/init.d
963 rc_dirz=${DESTDIR}/etc/rc.d/rc
964 elif test -f /etc/mandrake-release
965 then
966 DVER="Linux"
967 test -z "$verbose" || echo " Mandrake based system detected"
968 rc_uinst=
969 rc_inst=
970 rc_main=${DESTDIR}/etc/rc.d/init.d
971 rc_dirz=${DESTDIR}/etc/rc.d/rc
972 elif test -f /etc/yellowdog-release
973 then
974 DVER="Linux"
975 test -z "$verbose" || echo " Yellow Dog based system detected"
976 rc_uinst=
977 rc_inst=
978 rc_main=${DESTDIR}/etc/rc.d/init.d
979 rc_dirz=${DESTDIR}/etc/rc.d/rc
980 elif test -f /etc/slackware-version && test -f /etc/rc.d/rc.sysvinit
981 then
982 DVER="Linux"
983 test -z "$verbose" || echo " Slackware based system detected"
984 rc_uinst=
985 rc_inst=
986 rc_main=${DESTDIR}/etc/rc.d
987 rc_dirz=${DESTDIR}/etc/rc.d/rc
988 elif test -f /etc/gentoo-release
989 then
990 DVER="Gentoo"
991 test -z "$verbose" || echo " Gentoo based system detected"
992 rc_uinst="/sbin/rc-update del @install_name@"
993 rc_inst="/sbin/rc-update add @install_name@ default"
994 rc_main=${DESTDIR}/etc/init.d
995 rc_dirz=
996 else
997 echo "${0}: unknown Linux distribution"
998 rc_uinst=
999 rc_inst=
1000 rc_main=
1001 rc_dirz=
1002 for ff in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
1003 if test -d $ff; then
1004 rc_main="$ff"
1005 break
1006 fi
1007 done
1008 for fg in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
1009 if test -d $fg; then
1010 rc_dirz="`echo $fg | sed -e 's,2.*,,'`"
1011 break
1012 fi
1013 done
1014 if [ x"${rc_dirz}" = x ]; then
1015 echo "${0}: no install directory for runlevel scripts found"
1016 exit 1
1017 fi
1018 if [ x"${rc_main}" = x ]; then
1019 echo "${0}: no install directory for runlevel scripts found"
1020 exit 1
1021 fi
1022 DVER="Linux"
1023 rc_main="${DESTDIR}${rc_main}"
1024 rc_dirz="${DESTDIR}${rc_dirz}"
1025 fi
1026 ;;
1027
1028 *)
1029 echo "${0}: unsupported platform ${platform}"
1030 exit 1
1031 ;;
1032 esac
1033
1034 if test x"${rc_main}" = x
1035 then
1036 echo "${0}: no install directory for runlevel scripts found"
1037 exit 1
1038 fi
1039
1040 if test x"${act}" = xboot
1041 then
1042
1043 startscript=NONE
1044 if test -f init/samhain.start${DVER}
1045 then
1046 startscript=`eval echo init/samhain.start${DVER}`
1047 elif test -f samhain.start${DVER}
1048 then
1049 startscript=`eval echo samhain.start${DVER}`
1050 else
1051 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1052 exit 1
1053 fi
1054
1055 if test "x${startscript}" = xNONE; then
1056 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1057 exit 1
1058 else
1059 if test -f ${rc_main}/${samhain} && test x"$force" != xyes
1060 then
1061 echo " ${rc_main}/${samhain} exists ... not overwritten (or use --force)"
1062 else
1063 if test x"$DESTDIR" = x
1064 then
1065 :
1066 else
1067 ${mkinstalldirs} ${rc_main}
1068 #
[59]1069 if test x"${DVER_REAL}" = xSolaris; then
[1]1070 ${mkinstalldirs} ${DESTDIR}/etc/rc0.d
1071 ${mkinstalldirs} ${DESTDIR}/etc/rc1.d
1072 ${mkinstalldirs} ${DESTDIR}/etc/rc3.d
1073 fi
1074 #
1075 fi
1076 test -z "$verbose" || echo " ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}"
1077 if test -f "@INSTALL@"; then
1078 ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}
1079 else
1080 cp ${startscript} ${rc_main}/${samhain} && chmod 0700 ${rc_main}/${samhain}
1081 fi
1082 fi
1083 fi
1084
1085
1086 if test x"${rc_dirz}" != x
1087 then
1088 for ff in $rlv
1089 do
1090 if test x"${DESTDIR}" = x
1091 then
1092 rldir="${rc_dirz}${ff}.d/"
1093 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain}"
1094 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain})
1095 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain}"
1096 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain})
1097 else
1098 :
1099 # ${mkinstalldirs} ${rc_dirz}${ff}.d
1100 fi
1101
1102
1103 done
1104 fi
1105
1106 if test x"${rc_inst}" != x
1107 then
1108 if test x"${DESTDIR}" = x
1109 then
1110 test -z "$verbose" || echo " ${rc_inst}"
1111 eval ${rc_inst}
1112 fi
1113 fi
1114 echo "installing init scripts completed"
1115 fi
1116
1117 if test x"${act}" = xuboot
1118 then
1119 if test x"${rc_uinst}" != x
1120 then
1121 test -z "$verbose" || echo " ${rc_uinst}"
1122 echo
1123 eval ${rc_uinst}
1124 fi
1125
1126 if test x"${rc_dirz}" != x
1127 then
1128 for ff in $rlv
1129 do
1130 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1131 rm -f ${rc_dirz}${ff}.d/S99${samhain}
1132 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1133 rm -f ${rc_dirz}${ff}.d/K10${samhain}
1134 done
1135 fi
1136
1137 test -z "$verbose" || echo " rm -f ${rc_main}/${samhain}"
1138 rm -f ${rc_main}/${samhain}
1139
1140 echo " uninstalling init scripts completed"
1141 fi
1142
1143 # boot_install|boot_uninstall completed
1144 exit 0
1145fi
1146
1147if test x"${act}" = xulkm
1148then
1149 RVER=`uname -r`
1150 if test "x@sh_lkm@" != "x"; then
1151 if test -d /lib/modules/$RVER; then
1152 MODDIR="/lib/modules/$RVER"
1153 elif test -d /lib/modules/misc; then
1154 MODDIR="/lib/modules/misc"
1155 elif test -d /lib/modules; then
1156 MODDIR="/lib/modules/misc"
1157 fi
1158 # -- NEW --
1159 ALLMODS="@sh_lkm@"
1160 for p in $ALLMODS; do
1161 test -z "$verbose" || echo " rm -f ${DESTDIR}${MODDIR}/`echo $p|sed '
1162s%samhain%@install_name@%'`"
1163 rm -f ${DESTDIR}${MODDIR}/`echo $p|sed 's%samhain%@install_name@%'`
1164 done
1165 fi
1166fi
1167
1168if test x"${act}" = xuprogram
1169then
1170 PROGRAMS="@setpwd_prg@ @stegin_prg@ @yulectl_prg@ @sh_main_prg@"
1171 for p in $PROGRAMS; do
1172 test -z "$verbose" || echo " rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"
1173 rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`
1174 done
1175 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sbindir} ... $ECHO_C"
1176 ${SH_RMDIR} ${DESTDIR}${sbindir} >/dev/null 2>&1
1177 if test x$? = x0; then
1178 test -z "$verbose" || echo "${ECHO_T}done"
1179 else
1180 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1181 fi
1182 exit 0
1183fi
1184
1185if test x"${act}" = xuman
1186then
1187 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man8/@install_name@.8"
1188 rm -f ${DESTDIR}${mandir}/man8/@install_name@.8
1189 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5"
1190 rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5
1191
1192 OLD_IFS=${IFS}
1193 IFS=':'; export IFS
1194 for ff in ${MANPATH}; do
1195 if test x"$ff/man8" = x"${DESTDIR}${mandir}/man8"; then
1196 echo " man directory ${DESTDIR}${mandir} is in your MANPATH"
1197 echo " -- will not try to remove"
1198 IFS=${OLD_IFS}; export IFS
1199 exit 0
1200 fi
1201 done
1202 IFS=${OLD_IFS}; export IFS
1203
1204 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man8 ... $ECHO_C"
1205 ${SH_RMDIR} ${DESTDIR}${mandir}/man8 >/dev/null 2>&1
1206 if test x$? = x0; then
1207 test -z "$verbose" || echo "${ECHO_T}done"
1208 else
1209 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1210 fi
1211
1212 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man5 ... $ECHO_C"
1213 ${SH_RMDIR} ${DESTDIR}${mandir}/man5 >/dev/null 2>&1
1214 if test x$? = x0; then
1215 test -z "$verbose" || echo "${ECHO_T}done"
1216 else
1217 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1218 fi
1219
1220 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir} ... $ECHO_C"
1221 ${SH_RMDIR} ${DESTDIR}${mandir} >/dev/null 2>&1
1222 if test x$? = x0; then
1223 test -z "$verbose" || echo "${ECHO_T}done"
1224 else
1225 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1226 fi
1227
1228 exit 0
1229fi
1230
1231if test x"${act}" = xudata
1232then
1233 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`"
1234 rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`
1235 test -z "$verbose" || echo " rm -f ${DESTDIR}${pid_file}"
1236 rm -f ${DESTDIR}${pid_file}
1237 test -z "$verbose" || echo " rm -f ${DESTDIR}${mylogfile}"
1238 rm -f ${DESTDIR}${mylogfile}
1239 test -z "$verbose" || echo " rm -f ${DESTDIR}${myhtmlfile}"
1240 rm -f ${DESTDIR}${myhtmlfile}
1241
1242 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${pid_dir} ... $ECHO_C"
1243 ${SH_RMDIR} ${DESTDIR}${pid_dir} >/dev/null 2>&1
1244 if test x$? = x0; then
1245 test -z "$verbose" || echo "${ECHO_T}done"
1246 else
1247 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1248 fi
1249
1250 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mylogdir} ... $ECHO_C"
1251 ${SH_RMDIR} ${DESTDIR}${mylogdir} >/dev/null 2>&1
1252 if test x$? = x0; then
1253 test -z "$verbose" || echo "${ECHO_T}done"
1254 else
1255 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1256 fi
1257
1258 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${data_root} ... $ECHO_C"
1259 ${SH_RMDIR} ${DESTDIR}${data_root} >/dev/null 2>&1
1260 if test x$? = x0; then
1261 test -z "$verbose" || echo "${ECHO_T}done"
1262 else
1263 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1264 fi
1265
1266 if test x"$force" = "xyes"
1267 then
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 elif test x"$purge" = "xyes"
1271 then
1272 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1273 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1274 elif test x"$express" = x; then
1275 echo " Do you want to remove the configuration file [y/n] ?"
1276 while [ "1" = "1" ]; do
1277 read ff
1278 case "$ff" in
1279 Y* | y* )
1280 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1281 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1282 break
1283 ;;
1284 N* | n* )
1285 test -z "$verbose" || echo " ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` NOT removed"
1286 break
1287 ;;
1288 *)
1289 echo " Enter y[es] or n[o]"
1290 ;;
1291 esac
1292 done
1293 else
1294 test -z "$verbose" || echo " NOT REMOVED: config file ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` (use --force to remove)"
1295 fi
1296
1297 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sysconfdir} ... $ECHO_C"
1298 ${SH_RMDIR} ${DESTDIR}${sysconfdir} >/dev/null 2>&1
1299 if test x$? = x0; then
1300 test -z "$verbose" || echo "${ECHO_T}done"
1301 else
1302 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1303 fi
1304
1305 exit 0
1306fi
1307
1308if test x"${act}" = xdata
1309then
1310 STEGIN=@stegin_prg@
1311 CONVERT=
1312
1313 GPGPATH=@mygpg@
[191]1314 TARGETKEYID=@mykeyid@
1315 KEYTAG=@mykeytag@
[1]1316
1317 NTEST=@mytclient@
1318
1319 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1320 then
1321 RCFILE=yulerc
1322 if test -f $RCFILE
1323 then
1324 :
1325 else
1326 if test -f yulerc.template
1327 then
1328 cp yulerc.template $RCFILE
1329 fi
1330 fi
1331 else
1332 RCFILE=samhainrc
1333 IN_RCFILE=samhainrc.@selectconfig@
1334
1335 if test -f ${RCFILE}
1336 then
1337 :
1338 else
1339 if test -f ${IN_RCFILE}
1340 then
1341 test -z "$verbose" || echo " cp ${IN_RCFILE} ${RCFILE}"
1342 cp ${IN_RCFILE} ${RCFILE}
1343 fi
1344 fi
1345 fi
1346
1347 if test -f $RCFILE
1348 then
1349 :
1350 else
1351 echo "${0}: cannot find configuration file $RCFILE"
1352 exit 1
1353 fi
1354
1355 if test x"${GPGPATH}" != x
1356 then
1357 echo
1358 echo "You need to sign the config file now"
1359 echo
[191]1360 test -z "$verbose" || echo " ${GPGPATH} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE"
[1]1361 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1362 then
1363 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1364 grep "^${samhain}:" | awk -F: '{ print $3; }'`
1365 if test x"${myident_uid}" != x
1366 then
1367 DOT_GNUPG=`eval echo ~${samhain}/.gnupg`
1368 test -z "$verbose" || echo " using --homedir ${DOT_GNUPG}"
[191]1369 ${GPGPATH} --homedir ${DOT_GNUPG} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE
[1]1370 else
[191]1371 ${GPGPATH} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE
[1]1372 fi
1373 else
[191]1374 ${GPGPATH} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE
[1]1375 fi
1376
1377 if test -f ${RCFILE}.asc
1378 then
1379 test -z "$verbose" || echo " mv -f ${RCFILE}.asc samhainrc.pre"
1380 mv -f ${RCFILE}.asc samhainrc.pre
1381 else
1382 echo "**********************************************************"
1383 echo
1384 echo "${0}: ERROR: cannot find signed file ${RCFILE}.asc"
1385 echo
1386 echo " --- You need to sign the configuration file ---"
1387 echo
1388 echo "**********************************************************"
1389 cp ${RCFILE} samhainrc.pre
1390 fi
1391 else
1392 test -z "$verbose" || echo " cp $RCFILE samhainrc.pre"
1393 cp $RCFILE samhainrc.pre
1394 fi
1395
1396 if test x"${STEGIN}" != x
1397 then
1398 test -z "$verbose" || echo " searching for ImageMagick convert utility"
1399 OPATH=${PATH}
1400 PATH="/usr/local/bin:/usr/X11R6/bin:"${PATH}
1401
1402 OIFS=${IFS}
1403 IFS=":"
1404
1405 for dd in ${PATH}
1406 do
1407 if test -f "${dd}/convert"
1408 then
1409 "${dd}/convert" --help | grep ImageMagick >/dev/null 2>&1 && \
1410 CONVERT="${dd}/convert"
1411 test -z "$verbose" || echo " CONVERT=${dd}/convert"
1412 fi
1413 done
1414
1415 IFS=${OIFS}
1416
[203]1417 if test -f stealth_template.ps
[1]1418 then
[203]1419 PATH=${OPATH}
1420 else
1421 if test x"${CONVERT}" = x
1422 then
1423 echo "${0}: cannot find ImageMagick convert utility in PATH=${PATH}"
1424 exit 1
1425 fi
[1]1426
[203]1427 PATH=${OPATH}
[1]1428
[203]1429 if test -f stealth_template.jpg
1430 then
1431 test -z "$verbose" || echo " ${CONVERT} +compress stealth_template.jpg stealth_template.ps"
1432 "${CONVERT}" +compress stealth_template.jpg stealth_template.ps
1433 else
1434 echo "${0}: cannot find file stealth_template.jpg"
1435 exit 1
1436 fi
1437 fi
[1]1438
1439
1440 if test -f stealth_template.ps
1441 then
1442 :
1443 else
1444 echo "${0}: file stealth_template.ps not created"
1445 exit 1
1446 fi
1447
1448 if test -f samhainrc.pre
1449 then
1450 :
1451 else
1452 echo "${0}: cannot find configuration file samhainrc.pre"
1453 exit 1
1454 fi
1455
1456 if test -f ./samhain_stealth
1457 then
1458 :
1459 else
1460 echo "${0}: cannot find utility ./samhain_stealth"
1461 exit 1
1462 fi
1463
1464 ccount=`./samhain_stealth -o samhainrc.pre 2>&1 | awk '{ print $1 }'`
1465 mcount=`./samhain_stealth -i stealth_template.ps 2>&1 | awk '{ print $7 }'`
1466
1467 if test ${mcount} -lt ${ccount}
1468 then
1469 echo "${0}: configuration file samhainrc too big,"
1470 echo " need a larger image stealth_template.jpg to store"
1471 exit 1
1472 fi
1473
1474 test -z "$verbose" || echo " ./samhain_stealth -s stealth_template.ps samhainrc.pre"
1475 ./samhain_stealth -s stealth_template.ps samhainrc.pre
1476
1477 test -z "$verbose" || echo " mv -f stealth_template.ps samhainrc.install"
1478 mv -f stealth_template.ps samhainrc.install
1479 else
1480 test -z "$verbose" || echo " mv -f samhainrc.pre samhainrc.install"
1481 mv -f samhainrc.pre samhainrc.install
1482 fi
1483
1484 tmp_configfile=`echo ${configfile} | sed 's%^REQ_FROM_SERVER%%'`
1485
1486 if test x"${tmp_configfile}" = x
1487 then
1488 echo " No local configfile to install."
1489 exit 0
1490 fi
1491
1492 if test -f ${DESTDIR}${tmp_configfile} && test x"$force" = x
1493 then
1494 echo " ${DESTDIR}${tmp_configfile} exists ... not overwritten (or use --force)"
1495 else
1496 test -z "$verbose" || echo " ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}"
1497 ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}
1498 fi
1499
1500 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1501 then
1502 test -z "$verbose" || echo " chown @myident@ ${DESTDIR}${tmp_configfile}"
1503 chown @myident@ ${DESTDIR}${tmp_configfile}
1504 fi
1505
1506 #
1507 # Changed: don't check if DESTDIR is set, as these are not
1508 # the true install locations anyway
1509 #
1510 if test -f trustfile && test x"${DESTDIR}" = x
1511 then
1512 test -z "$verbose" || echo " checking whether paths are trustworthy"
1513 RESULT=`./trustfile ${DESTDIR}${tmp_configfile} 2>&1`
1514 if test x$? != x0
1515 then
1516 echo
1517 ./trustfile ${DESTDIR}${tmp_configfile}
1518 echo
1519 else
1520 test -z "$verbose" || echo " configuration file ${DESTDIR}${tmp_configfile} ... OK"
1521 fi
1522
1523 RESULT=`./trustfile ${DESTDIR}${pid_dir} >/dev/null 2>&1`
1524 if test x$? != x0
1525 then
1526 echo
1527 ./trustfile ${DESTDIR}${pid_dir}
1528 echo
1529 else
1530 test -z "$verbose" || echo " state directory ${DESTDIR}${pid_dir} ... OK"
1531 fi
1532
1533 RESULT=`./trustfile ${DESTDIR}${mylogdir} >/dev/null 2>&1`
1534 if test x$? != x0
1535 then
1536 echo
1537 ./trustfile ${DESTDIR}${mylogdir}
1538 echo
1539 else
1540 test -z "$verbose" || echo " state directory ${DESTDIR}${mylogdir} ... OK"
1541 fi
1542
1543 RESULT=`./trustfile ${DESTDIR}${data_root} >/dev/null 2>&1`
1544 if test x$? != x0
1545 then
1546 echo
1547 ./trustfile ${DESTDIR}${data_root}
1548 echo
1549 else
1550 test -z "$verbose" || echo " data directory ${DESTDIR}${data_root} ... OK"
1551 fi
1552 fi
1553 # install_data
1554 exit 0
1555fi
1556
1557
Note: See TracBrowser for help on using the repository browser.