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

Last change on this file since 579 was 556, checked in by katerina, 4 years ago

Fix for ticket #445 (portable binary installer)

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