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

Last change on this file since 551 was 550, checked in by katerina, 5 years ago

Fix for ticket #442 (support for OpenBSD signify).

File size: 42.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
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="test -f /etc/init.d/@install_name@ && /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 rc_systemd=
1035 if command -v pkg-config >/dev/null 2>&1
1036 then
1037 if pkg-config --exists systemd >/dev/null 2>&1
1038 then
1039 rc_systemd=`pkg-config --variable=systemdsystemunitdir systemd`
1040 fi
1041 fi
1042
1043 if test x"${act}" = xboot
1044 then
1045
1046 startscript=NONE
1047 if test -f init/samhain.start${DVER}
1048 then
1049 startscript=`eval echo init/samhain.start${DVER}`
1050 elif test -f samhain.start${DVER}
1051 then
1052 startscript=`eval echo samhain.start${DVER}`
1053 else
1054 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1055 exit 1
1056 fi
1057
1058 if test "x${startscript}" = xNONE; then
1059 echo "${0}: cannot find samhain.start${DVER} in ./ or ./init"
1060 exit 1
1061 else
1062 if test -f ${rc_main}/${samhain} && test x"$force" != xyes
1063 then
1064 echo " ${rc_main}/${samhain} exists ... not overwritten (or use --force)"
1065 else
1066 if test x"$DESTDIR" = x
1067 then
1068 :
1069 else
1070 ${mkinstalldirs} ${rc_main}
1071 #
1072 if test x"${DVER_REAL}" = xSolaris; then
1073 ${mkinstalldirs} ${DESTDIR}/etc/rc0.d
1074 ${mkinstalldirs} ${DESTDIR}/etc/rc1.d
1075 ${mkinstalldirs} ${DESTDIR}/etc/rc3.d
1076 fi
1077 #
1078 fi
1079 test -z "$verbose" || echo " ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}"
1080 if test -f "@INSTALL@"; then
1081 ${INSTALL_SHELL} ${startscript} ${rc_main}/${samhain}
1082 else
1083 cp ${startscript} ${rc_main}/${samhain} && chmod 0700 ${rc_main}/${samhain}
1084 fi
1085 fi
1086 fi
1087
1088
1089 if test x"${rc_dirz}" != x
1090 then
1091 for ff in $rlv
1092 do
1093 if test x"${DESTDIR}" = x
1094 then
1095 rldir="${rc_dirz}${ff}.d/"
1096 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain}"
1097 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} S99${samhain})
1098 test -z "$verbose" || echo " cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain}"
1099 (cd ${rldir} && ln ${linkopt} ${rc_main}/${samhain} K10${samhain})
1100 else
1101 :
1102 # ${mkinstalldirs} ${rc_dirz}${ff}.d
1103 fi
1104
1105
1106 done
1107 fi
1108
1109 if test x"${rc_inst}" != x
1110 then
1111 if test x"${DESTDIR}" = x
1112 then
1113 test -z "$verbose" || echo " ${rc_inst}"
1114 eval ${rc_inst}
1115 fi
1116 fi
1117
1118 if test x"${rc_systemd}" != x
1119 then
1120 if test x"$DESTDIR" = x
1121 then
1122 :
1123 else
1124 ${mkinstalldirs} ${DESTDIR}/${rc_systemd}
1125 fi
1126 if test -f init/samhain.startSystemd
1127 then
1128 servicescript=init/samhain.startSystemd
1129 elif test -f samhain.startSystemd
1130 then
1131 servicescript=samhain.startSystemd
1132 else
1133 echo "${0}: cannot find samhain.startSystemd in ./ or ./init"
1134 fi
1135 if test -f ${DESTDIR}/${rc_systemd}/${samhain}.service && test x"$force" != xyes
1136 then
1137 echo " ${DESTDIR}/${rc_systemd}/${samhain}.service exists ... not overwritten (or use --force)"
1138 else
1139 ${INSTALL_DATA} ${servicescript} "${DESTDIR}/${rc_systemd}/${samhain}.service"
1140 fi
1141 fi
1142
1143 echo "installing init scripts completed"
1144 fi
1145
1146 if test x"${act}" = xuboot
1147 then
1148 if test x"${rc_uinst}" != x
1149 then
1150 test -z "$verbose" || echo " ${rc_uinst}"
1151 echo
1152 eval ${rc_uinst}
1153 fi
1154
1155 if test x"${rc_dirz}" != x
1156 then
1157 for ff in $rlv
1158 do
1159 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1160 rm -f "${rc_dirz}${ff}.d/S99${samhain}"
1161 test -z "$verbose" || echo " rm -f ${rc_dirz}${ff}.d/S99${samhain}"
1162 rm -f "${rc_dirz}${ff}.d/K10${samhain}"
1163 done
1164 fi
1165
1166 test -z "$verbose" || echo " rm -f ${rc_main}/${samhain}"
1167 rm -f "${rc_main}/${samhain}"
1168
1169 if test x"${rc_systemd}" != x
1170 then
1171 test -z "$verbose" || echo " rm -f ${rc_systemd}/${samhain}.service"
1172 rm -f "${rc_systemd}/${samhain}.service"
1173 fi
1174
1175 echo " uninstalling init scripts completed"
1176 fi
1177
1178 # boot_install|boot_uninstall completed
1179 exit 0
1180fi
1181
1182if test x"${act}" = xuprogram
1183then
1184 PROGRAMS="@setpwd_prg@ @stegin_prg@ @yulectl_prg@ @sh_main_prg@ @samhainadmin_prg@"
1185 for p in $PROGRAMS; do
1186 test -z "$verbose" || echo " rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'|sed 's%.*/%%'`"
1187 rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'|sed 's%.*/%%'`
1188 done
1189 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sbindir} ... $ECHO_C"
1190 ${SH_RMDIR} ${DESTDIR}${sbindir} >/dev/null 2>&1
1191 if test x$? = x0; then
1192 test -z "$verbose" || echo "${ECHO_T}done"
1193 else
1194 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1195 fi
1196 exit 0
1197fi
1198
1199if test x"${act}" = xuman
1200then
1201 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man8/@install_name@.8"
1202 rm -f ${DESTDIR}${mandir}/man8/@install_name@.8
1203 test -z "$verbose" || echo " rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5"
1204 rm -f ${DESTDIR}${mandir}/man5/@install_name@rc.5
1205
1206 OLD_IFS=${IFS}
1207 IFS=':'; export IFS
1208 for ff in ${MANPATH}; do
1209 if test x"$ff/man8" = x"${DESTDIR}${mandir}/man8"; then
1210 echo " man directory ${DESTDIR}${mandir} is in your MANPATH"
1211 echo " -- will not try to remove"
1212 IFS=${OLD_IFS}; export IFS
1213 exit 0
1214 fi
1215 done
1216 IFS=${OLD_IFS}; export IFS
1217
1218 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man8 ... $ECHO_C"
1219 ${SH_RMDIR} ${DESTDIR}${mandir}/man8 >/dev/null 2>&1
1220 if test x$? = x0; then
1221 test -z "$verbose" || echo "${ECHO_T}done"
1222 else
1223 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1224 fi
1225
1226 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir}/man5 ... $ECHO_C"
1227 ${SH_RMDIR} ${DESTDIR}${mandir}/man5 >/dev/null 2>&1
1228 if test x$? = x0; then
1229 test -z "$verbose" || echo "${ECHO_T}done"
1230 else
1231 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1232 fi
1233
1234 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mandir} ... $ECHO_C"
1235 ${SH_RMDIR} ${DESTDIR}${mandir} >/dev/null 2>&1
1236 if test x$? = x0; then
1237 test -z "$verbose" || echo "${ECHO_T}done"
1238 else
1239 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1240 fi
1241
1242 exit 0
1243fi
1244
1245if test x"${act}" = xudata
1246then
1247 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`"
1248 rm -f ${DESTDIR}`echo ${mydatafile}|sed s%REQ_FROM_SERVER%%`
1249 test -z "$verbose" || echo " rm -f ${DESTDIR}${pid_file}"
1250 rm -f ${DESTDIR}${pid_file}
1251 test -z "$verbose" || echo " rm -f ${DESTDIR}${mylogfile}"
1252 rm -f ${DESTDIR}${mylogfile}
1253 test -z "$verbose" || echo " rm -f ${DESTDIR}${myhtmlfile}"
1254 rm -f ${DESTDIR}${myhtmlfile}
1255
1256 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${pid_dir} ... $ECHO_C"
1257 ${SH_RMDIR} ${DESTDIR}${pid_dir} >/dev/null 2>&1
1258 if test x$? = x0; then
1259 test -z "$verbose" || echo "${ECHO_T}done"
1260 else
1261 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1262 fi
1263
1264 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${mylogdir} ... $ECHO_C"
1265 ${SH_RMDIR} ${DESTDIR}${mylogdir} >/dev/null 2>&1
1266 if test x$? = x0; then
1267 test -z "$verbose" || echo "${ECHO_T}done"
1268 else
1269 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1270 fi
1271
1272 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${data_root} ... $ECHO_C"
1273 ${SH_RMDIR} ${DESTDIR}${data_root} >/dev/null 2>&1
1274 if test x$? = x0; then
1275 test -z "$verbose" || echo "${ECHO_T}done"
1276 else
1277 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1278 fi
1279
1280
1281 if test -d /etc/logrotate.d; then
1282 if test -f /etc/logrotate.d/@install_name@; then
1283 test -z "$verbose" || echo $ECHO_N " rm -f /etc/logrotate.d/@install_name@ ... $ECHO_C"
1284 rm -f /etc/logrotate.d/@install_name@;
1285 if test x$? = x0; then
1286 test -z "$verbose" || echo "${ECHO_T}done"
1287 else
1288 test -z "$verbose" || echo "${ECHO_T}failed"
1289 fi
1290 fi
1291 fi
1292
1293 if test x"$force" = "xyes"
1294 then
1295 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1296 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1297 elif test x"$purge" = "xyes"
1298 then
1299 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1300 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1301 elif test x"$express" = x; then
1302 echo " Do you want to remove the configuration file [y/n] ?"
1303 while [ "1" = "1" ]; do
1304 read ff
1305 case "$ff" in
1306 Y* | y* )
1307 test -z "$verbose" || echo " rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`"
1308 rm -f ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%`
1309 break
1310 ;;
1311 N* | n* )
1312 test -z "$verbose" || echo " ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` NOT removed"
1313 break
1314 ;;
1315 *)
1316 echo " Enter y[es] or n[o]"
1317 ;;
1318 esac
1319 done
1320 else
1321 test -z "$verbose" || echo " NOT REMOVED: config file ${DESTDIR}`echo ${configfile}|sed s%REQ_FROM_SERVER%%` (use --force to remove)"
1322 fi
1323
1324 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sysconfdir} ... $ECHO_C"
1325 ${SH_RMDIR} ${DESTDIR}${sysconfdir} >/dev/null 2>&1
1326 if test x$? = x0; then
1327 test -z "$verbose" || echo "${ECHO_T}done"
1328 else
1329 test -z "$verbose" || echo "${ECHO_T}failed (not empty ?)"
1330 fi
1331
1332 exit 0
1333fi
1334
1335if test x"${act}" = xdata
1336then
1337 STEGIN=@stegin_prg@
1338 CONVERT=
1339
1340 GPGPATH=@mygpg@
1341 SIGNIFY_PATH=@mysignify@
1342 TARGETKEYID=@mykeyid@
1343 KEYTAG=@mykeytag@
1344
1345 NTEST=@mytclient@
1346
1347 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1348 then
1349 RCFILE=yulerc
1350 if test -f $RCFILE
1351 then
1352 :
1353 else
1354 if test -f yulerc.template
1355 then
1356 cp yulerc.template $RCFILE
1357 fi
1358 fi
1359 else
1360 RCFILE=samhainrc
1361 IN_RCFILE=samhainrc.@selectconfig@
1362
1363 if test -f ${RCFILE}
1364 then
1365 :
1366 else
1367 if test -f ${IN_RCFILE}
1368 then
1369 test -z "$verbose" || echo " cp ${IN_RCFILE} ${RCFILE}"
1370 cp ${IN_RCFILE} ${RCFILE}
1371 fi
1372 fi
1373 fi
1374
1375 if test -f $RCFILE
1376 then
1377 :
1378 else
1379 echo "${0}: cannot find configuration file $RCFILE"
1380 exit 1
1381 fi
1382
1383 if test x"${GPGPATH}" != x
1384 then
1385 echo
1386 echo "You need to sign the config file now"
1387 echo
1388 test -z "$verbose" || echo " ${GPGPATH} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE"
1389 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1390 then
1391 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1392 grep "^${samhain}:" | awk -F: '{ print $3; }'`
1393 if test x"${myident_uid}" != x
1394 then
1395 DOT_GNUPG=`eval echo ~${samhain}/.gnupg`
1396 test -z "$verbose" || echo " using --homedir ${DOT_GNUPG}"
1397 ${GPGPATH} --homedir ${DOT_GNUPG} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE
1398 else
1399 ${GPGPATH} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE
1400 fi
1401 else
1402 ${GPGPATH} -a ${KEYTAG} ${TARGETKEYID} --clearsign $RCFILE
1403 fi
1404
1405 if test -f ${RCFILE}.asc
1406 then
1407 test -z "$verbose" || echo " mv -f ${RCFILE}.asc samhainrc.pre"
1408 mv -f ${RCFILE}.asc samhainrc.pre
1409 else
1410 echo "**********************************************************"
1411 echo
1412 echo "${0}: ERROR: cannot find signed file ${RCFILE}.asc"
1413 echo
1414 echo " --- You need to sign the configuration file ---"
1415 echo
1416 echo "**********************************************************"
1417 cp ${RCFILE} samhainrc.pre
1418 fi
1419 elif test x"${SIGNIFY_PATH}" != x
1420 then
1421 echo
1422 echo "You need to sign the config file now"
1423 echo
1424 test -z "$verbose" || echo " ${SIGNIFY_PATH} -Se -s ~/.signify/samhain.sec -m $RCFILE"
1425 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1426 then
1427 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1428 grep "^${samhain}:" | awk -F: '{ print $3; }'`
1429 if test x"${myident_uid}" != x
1430 then
1431 DOT_SIGNIFY=`eval echo ~${samhain}/.signify`
1432 test -z "$verbose" || echo " using home directory ${DOT_SIGNIFY}"
1433 ${SIGNIFY_PATH} -Se -s ${DOT_GNUPG}/samhain.sec $RCFILE
1434 else
1435 ${SIGNIFY_PATH} -Se -s ~/.signify/samhain.sec -m $RCFILE
1436 fi
1437 else
1438 ${SIGNIFY_PATH} -Se -s ~/.signify/samhain.sec -m $RCFILE
1439 fi
1440
1441 if test -f ${RCFILE}.sig
1442 then
1443 test -z "$verbose" || echo " mv -f ${RCFILE}.sig samhainrc.pre"
1444 mv -f ${RCFILE}.sig samhainrc.pre
1445 else
1446 echo "**********************************************************"
1447 echo
1448 echo "${0}: ERROR: cannot find signed file ${RCFILE}.sig"
1449 echo
1450 echo " --- You need to sign the configuration file ---"
1451 echo
1452 echo "**********************************************************"
1453 cp ${RCFILE} samhainrc.pre
1454 fi
1455 else
1456 test -z "$verbose" || echo " cp $RCFILE samhainrc.pre"
1457 cp $RCFILE samhainrc.pre
1458 fi
1459
1460 if test x"${STEGIN}" != x
1461 then
1462 test -z "$verbose" || echo " searching for ImageMagick convert utility"
1463 OPATH=${PATH}
1464 PATH="/usr/local/bin:/usr/X11R6/bin:"${PATH}
1465
1466 OIFS=${IFS}
1467 IFS=":"
1468
1469 for dd in ${PATH}
1470 do
1471 if test -f "${dd}/convert"
1472 then
1473 "${dd}/convert" --help | grep ImageMagick >/dev/null 2>&1 && \
1474 CONVERT="${dd}/convert"
1475 test -z "$verbose" || echo " CONVERT=${dd}/convert"
1476 fi
1477 done
1478
1479 IFS=${OIFS}
1480
1481 if test -f stealth_template.ps
1482 then
1483 PATH=${OPATH}
1484 else
1485 if test x"${CONVERT}" = x
1486 then
1487 echo "${0}: cannot find ImageMagick convert utility in PATH=${PATH}"
1488 exit 1
1489 fi
1490
1491 PATH=${OPATH}
1492
1493 if test -f stealth_template.jpg
1494 then
1495 test -z "$verbose" || echo " ${CONVERT} +compress stealth_template.jpg stealth_template.ps"
1496 "${CONVERT}" +compress stealth_template.jpg stealth_template.ps
1497 else
1498 echo "${0}: cannot find file stealth_template.jpg"
1499 exit 1
1500 fi
1501 fi
1502
1503
1504 if test -f stealth_template.ps
1505 then
1506 :
1507 else
1508 echo "${0}: file stealth_template.ps not created"
1509 exit 1
1510 fi
1511
1512 if test -f samhainrc.pre
1513 then
1514 :
1515 else
1516 echo "${0}: cannot find configuration file samhainrc.pre"
1517 exit 1
1518 fi
1519
1520 if test -f ./samhain_stealth
1521 then
1522 :
1523 else
1524 echo "${0}: cannot find utility ./samhain_stealth"
1525 exit 1
1526 fi
1527
1528 ccount=`./samhain_stealth -o samhainrc.pre 2>&1 | awk '{ print $1 }'`
1529 mcount=`./samhain_stealth -i stealth_template.ps 2>&1 | awk '{ print $7 }'`
1530
1531 if test ${mcount} -lt ${ccount}
1532 then
1533 echo "${0}: configuration file samhainrc too big,"
1534 echo " need a larger image stealth_template.jpg to store"
1535 exit 1
1536 fi
1537
1538 test -z "$verbose" || echo " ./samhain_stealth -s stealth_template.ps samhainrc.pre"
1539 ./samhain_stealth -s stealth_template.ps samhainrc.pre
1540
1541 test -z "$verbose" || echo " mv -f stealth_template.ps samhainrc.install"
1542 mv -f stealth_template.ps samhainrc.install
1543 else
1544 test -z "$verbose" || echo " mv -f samhainrc.pre samhainrc.install"
1545 mv -f samhainrc.pre samhainrc.install
1546 fi
1547
1548 tmp_configfile=`echo ${configfile} | sed 's%^REQ_FROM_SERVER%%'`
1549
1550 if test x"${tmp_configfile}" = x
1551 then
1552 echo " No local configfile to install."
1553 exit 0
1554 fi
1555
1556 if test -f ${DESTDIR}${tmp_configfile} && test x"$force" = x
1557 then
1558 echo " ${DESTDIR}${tmp_configfile} exists ... not overwritten (or use --force)"
1559 else
1560 test -z "$verbose" || echo " ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}"
1561 ${INSTALL_DATA} samhainrc.install ${DESTDIR}${tmp_configfile}
1562 fi
1563
1564 if test x"${NTEST}" = "x-DSH_WITH_SERVER"
1565 then
1566 test -z "$verbose" || echo " chown @myident@ ${DESTDIR}${tmp_configfile}"
1567 chown @myident@ ${DESTDIR}${tmp_configfile}
1568 fi
1569
1570 #
1571 # Changed: don't check if DESTDIR is set, as these are not
1572 # the true install locations anyway
1573 #
1574 if test -f trustfile && test x"${DESTDIR}" = x
1575 then
1576 test -z "$verbose" || echo " checking whether paths are trustworthy"
1577 RESULT=`./trustfile ${DESTDIR}${tmp_configfile} 2>&1`
1578 if test x$? != x0
1579 then
1580 echo
1581 ./trustfile ${DESTDIR}${tmp_configfile}
1582 echo
1583 else
1584 test -z "$verbose" || echo " configuration file ${DESTDIR}${tmp_configfile} ... OK"
1585 fi
1586
1587 RESULT=`./trustfile ${DESTDIR}${pid_dir} >/dev/null 2>&1`
1588 if test x$? != x0
1589 then
1590 echo
1591 ./trustfile ${DESTDIR}${pid_dir}
1592 echo
1593 else
1594 test -z "$verbose" || echo " state directory ${DESTDIR}${pid_dir} ... OK"
1595 fi
1596
1597 RESULT=`./trustfile ${DESTDIR}${mylogdir} >/dev/null 2>&1`
1598 if test x$? != x0
1599 then
1600 echo
1601 ./trustfile ${DESTDIR}${mylogdir}
1602 echo
1603 else
1604 test -z "$verbose" || echo " state directory ${DESTDIR}${mylogdir} ... OK"
1605 fi
1606
1607 RESULT=`./trustfile ${DESTDIR}${data_root} >/dev/null 2>&1`
1608 if test x$? != x0
1609 then
1610 echo
1611 ./trustfile ${DESTDIR}${data_root}
1612 echo
1613 else
1614 test -z "$verbose" || echo " data directory ${DESTDIR}${data_root} ... OK"
1615 fi
1616 fi
1617 # install_data
1618 exit 0
1619fi
1620
1621
Note: See TracBrowser for help on using the repository browser.