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

Last change on this file since 586 was 586, checked in by katerina, 24 hours ago

Fix for ticket #474 (systemd warning message about service file permission).

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