btbytes (owner)

Revisions

gist: 146105 Download_button fork
public
Description:
Init script for Plone on Debian
Public Clone URL: git://gist.github.com/146105.git
Embed All Files: show embed
plone_init_script.sh #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh -e
# Start/stop Zope/Plone server instance
#
# REF: http://plone.org/documentation/how-to/simple-etc-rc-d-init-d-script-for-zeocluster
# Adapted for Debian paths, current Plone 3.2.2+ version and LSB compliance.
# This init script works for a default 'stand-alone' Plone unified installer
# installation (on a single Zope instance)
#
# create as: /etc/init.d/Plone
# to activate it, run: update-rc.d Plone defaults
 
### BEGIN INIT INFO
# Provides: Plone
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop Zope/Plone server instance
### END INIT INFO
 
# LSB Source function library
. /lib/lsb/init-functions
 
RETVAL=0
 
# this is for the default install path for Plone
plonepath="/usr/local/Plone/zeocluster/bin"
prog="Plone"
 
start() {
    echo -n $"Starting $prog: "
    output=`${plonepath}/plonectl start`
    # the return status of plonectl is not reliable, we need to parse
    # its output via substring match
    if echo $output | grep -q "start"; then
            # success
            touch /var/lock/$prog
            log_success_msg "Plone started successfully"
            echo
RETVAL=0
    else
            # failed
            log_failure_msg "Plone failed to start or was already started"
            echo
RETVAL=1
    fi
return $RETVAL
}
 
stop() {
    echo -n $"Stopping $prog: "
    output=`${plonepath}/plonectl stop`
 
    if echo $output | grep -q "stop"; then
            # success
            rm /var/lock/$prog
            log_success_msg "Plone stopped successfully"
            echo
RETVAL=0
    else
            # failed
            log_failure_msg "Plone failed to stop or was already stopped"
            echo
RETVAL=1
    fi
return $RETVAL
}
 
restart() {
   stop
   start
}
 
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    echo "Plone Server:"
    output=`${plonepath}/plonectl status`
    echo $output
    ;;
  restart)
    restart
    ;;
  condrestart)
    [ -e /var/lock/$prog ] && restart
    ;;
  force-reload)
    echo "Plone doesn't support force-reload, use restart instead."
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart}"
    RETVAL=2
esac
 
exit $RETVAL