~cbehrens/agent-smith/hostname-trunc

« back to all changes in this revision

Viewing changes to agent-smith.redhat.init.in

  • Committer: Antony Messerli
  • Date: 2011-01-28 18:11:47 UTC
  • mfrom: (103.1.1 redhat-initscript)
  • Revision ID: amesserl@rackspace.com-20110128181147-denqm2409m4plrqt
Added redhat initscript infile

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# agent-smith   Startup script for cloud servers guest agent
 
4
#
 
5
# chkconfig: 2345 7 93
 
6
# description: agent-smith is a agent meant to run on linux guest instances \
 
7
#              on Citrix XenServer for manipulating the guest through \
 
8
#              xenstore.
 
9
# processname: agent-smith
 
10
# pidfile: /var/run/agent-smith.pid
 
11
 
 
12
# Source function library.
 
13
. /etc/rc.d/init.d/functions
 
14
 
 
15
prefix=@prefix@
 
16
exec_prefix=@exec_prefix@
 
17
datarootdir=@datarootdir@
 
18
datadir=@datadir@
 
19
sbindir=@sbindir@
 
20
 
 
21
scriptdir=${datadir}/agent-smith
 
22
asbindir=${sbindir}
 
23
updatename="/var/run/agent-smith.tar"
 
24
pidfile="/var/run/agent-smith.pid"
 
25
 
 
26
apply_update() {
 
27
  if [ -e $updatename -o -e ${updatename}.gz ]; then
 
28
    if [ -e ${updatename}.gz ] ; then
 
29
      updatename="${updatename}.gz"
 
30
      tarargs="z"
 
31
    else
 
32
      tarargs=""
 
33
    fi
 
34
 
 
35
    if tar -t${tarargs}f $updatename > /dev/null 2>&1 ; then
 
36
      cat ${scriptdir}/filelist | while read f ; do
 
37
        test -f "$f" && rm -f "$f"
 
38
      done
 
39
      tar -x${tarargs}C / -f $updatename
 
40
    else
 
41
      echo "Ignoring broken update archive"
 
42
    fi
 
43
    rm -f $updatename ${updatename}.gz
 
44
  fi
 
45
}
 
46
 
 
47
do_start() {
 
48
  apply_update
 
49
  ${asbindir}/agent-smith ${scriptdir}/dispatcher.sh
 
50
}
 
51
 
 
52
do_stop() {
 
53
  kill `cat ${pidfile}`
 
54
  rm -f ${pidfile}
 
55
}
 
56
 
 
57
case "$1" in
 
58
  start)
 
59
        do_start
 
60
        ;;
 
61
  stop)
 
62
        do_stop
 
63
        ;;
 
64
  restart)
 
65
        do_stop
 
66
    do_start
 
67
        ;;
 
68
  *)
 
69
        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
 
70
        exit 3
 
71
        ;;
 
72
esac
 
73
 
 
74
: