View | Details | Raw Unified | Return to bug 24340
Collapse All | Expand All

(-)a/debian/docs/koha-sip.xml (-1 / +8 lines)
Lines 27-32 Link Here
27
      <arg><option>--start</option>|<option>--stop</option>|<option>--restart</option></arg>
27
      <arg><option>--start</option>|<option>--stop</option>|<option>--restart</option></arg>
28
      <arg><option>--status</option></arg>
28
      <arg><option>--status</option></arg>
29
      <arg><option>--enable</option></arg>
29
      <arg><option>--enable</option></arg>
30
      <arg><option>--disable</option></arg>
30
      <arg><option>--verbose</option>|<option>-v</option></arg>
31
      <arg><option>--verbose</option>|<option>-v</option></arg>
31
      <arg><option>-h</option>|<option>--help</option></arg>
32
      <arg><option>-h</option>|<option>--help</option></arg>
32
    </cmdsynopsis>
33
    </cmdsynopsis>
Lines 56-65 Link Here
56
    <varlistentry>
57
    <varlistentry>
57
      <term><option>--enable</option></term>
58
      <term><option>--enable</option></term>
58
      <listitem>
59
      <listitem>
59
        <para>Copies the default SIP configuration file (/etc/koha/SIPconfig.xml) to the instance's configuration directory (/etc/koha/sites/)</para>
60
          <para>Enables the Koha SIP server, installing a default config at /etc/koha/sites/instance/SIPconfig.xml if it doesn't already exist.</para>
60
      </listitem>
61
      </listitem>
61
    </varlistentry>
62
    </varlistentry>
62
    <varlistentry>
63
    <varlistentry>
64
      <term><option>--disable</option></term>
65
      <listitem>
66
        <para>Disables the SIP server and shuts down running SIP processes.</para>
67
      </listitem>
68
  </varlistentry>
69
    <varlistentry>
63
      <term><option>--status</option></term>
70
      <term><option>--status</option></term>
64
      <listitem>
71
      <listitem>
65
        <para>Show status information about the SIP server for the specified Koha instances.</para>
72
        <para>Show status information about the SIP server for the specified Koha instances.</para>
(-)a/debian/scripts/koha-functions.sh (-1 / +1 lines)
Lines 139-145 is_sip_enabled() Link Here
139
{
139
{
140
    local instancename=$1
140
    local instancename=$1
141
141
142
    if [ -e /etc/koha/sites/$instancename/SIPconfig.xml ]; then
142
    if [ -e /var/lib/koha/$instancename/sip.enabled ]; then
143
        return 0
143
        return 0
144
    else
144
    else
145
        return 1
145
        return 1
(-)a/debian/scripts/koha-sip (-22 / +54 lines)
Lines 45-50 Usage: Link Here
45
$scriptname [--start|--stop|--restart] instancename1 [instancename2...]
45
$scriptname [--start|--stop|--restart] instancename1 [instancename2...]
46
$scriptname -h|--help
46
$scriptname -h|--help
47
47
48
    --enable              Enable the Koha SIP server.
49
    --disable             Disable and stop the Koha SIP server.
48
    --start               Start the SIP server for the specified instance(s)
50
    --start               Start the SIP server for the specified instance(s)
49
    --stop                Stop the SIP server for the specified instance(s)
51
    --stop                Stop the SIP server for the specified instance(s)
50
    --restart             Restart the SIP server for the specified instance(s)
52
    --restart             Restart the SIP server for the specified instance(s)
Lines 62-78 start_sip() Link Here
62
    _check_and_fix_perms $name
64
    _check_and_fix_perms $name
63
65
64
    if ! is_sip_running $name; then
66
    if ! is_sip_running $name; then
65
67
        if [ ! -f "/etc/koha/sites/${name}/SIPconfig.xml" ] || [ ! -f "/var/lib/koha/${name}/sip.enabled" ] ; then
66
        adjust_paths_dev_install $name
68
            echo "SIP is disabled, or you do not have a SIPconfig.xml file."
67
        export KOHA_HOME PERL5LIB
68
69
        if [ "$DEV_INSTALL" = "" ]; then
70
            LIBDIR=$KOHA_HOME/lib
71
        else
69
        else
72
            LIBDIR=$KOHA_HOME
70
            adjust_paths_dev_install $name
73
        fi
71
            export KOHA_HOME PERL5LIB
74
72
75
        DAEMONOPTS="--name=${name}-koha-sip \
73
            if [ "$DEV_INSTALL" = "" ]; then
74
                LIBDIR=$KOHA_HOME/lib
75
            else
76
                LIBDIR=$KOHA_HOME
77
            fi
78
79
            DAEMONOPTS="--name=${name}-koha-sip \
76
                    --errlog=/var/log/koha/${name}/sip-error.log \
80
                    --errlog=/var/log/koha/${name}/sip-error.log \
77
                    --stdout=/var/log/koha/${name}/sip.log \
81
                    --stdout=/var/log/koha/${name}/sip.log \
78
                    --output=/var/log/koha/${name}/sip-output.log \
82
                    --output=/var/log/koha/${name}/sip-output.log \
Lines 82-99 start_sip() Link Here
82
                    --pidfiles=/var/run/koha/${name} \
86
                    --pidfiles=/var/run/koha/${name} \
83
                    --user=${name}-koha.${name}-koha"
87
                    --user=${name}-koha.${name}-koha"
84
88
85
        SIP_PARAMS="$LIBDIR/C4/SIP/SIPServer.pm \
89
            SIP_PARAMS="$LIBDIR/C4/SIP/SIPServer.pm \
86
                    /etc/koha/sites/${name}/SIPconfig.xml"
90
                    /etc/koha/sites/${name}/SIPconfig.xml"
87
91
88
        [ "$verbose" != "no" ] && \
92
            [ "$verbose" != "no" ] && \
89
            log_daemon_msg "Starting SIP server for ${name}"
93
                log_daemon_msg "Starting SIP server for ${name}"
90
94
91
        if daemon $DAEMONOPTS -- perl $SIP_PARAMS; then
95
            if daemon $DAEMONOPTS -- perl $SIP_PARAMS; then
92
            ([ "$verbose" != "no" ] && \
96
                ([ "$verbose" != "no" ] && \
93
                log_end_msg 0) || return 0
97
                    log_end_msg 0) || return 0
94
        else
98
            else
95
            ([ "$verbose" != "no" ] && \
99
                ([ "$verbose" != "no" ] && \
96
                log_end_msg 1) || return 1
100
                    log_end_msg 1) || return 1
101
            fi
97
        fi
102
        fi
98
    else
103
    else
99
        if [ "$verbose" != "no" ]; then
104
        if [ "$verbose" != "no" ]; then
Lines 176-181 sip_status() Link Here
176
enable_sip()
181
enable_sip()
177
{
182
{
178
    local name=$1
183
    local name=$1
184
    local libdir=/var/lib/koha/${name}
179
185
180
    sipfile=/etc/koha/sites/${name}/SIPconfig.xml
186
    sipfile=/etc/koha/sites/${name}/SIPconfig.xml
181
187
Lines 183-194 enable_sip() Link Here
183
        echo "Warning: SIP server already enabled for ${name}"
189
        echo "Warning: SIP server already enabled for ${name}"
184
    else
190
    else
185
        echo "Enabling SIP server for ${name} - edit ${sipfile} to configure"
191
        echo "Enabling SIP server for ${name} - edit ${sipfile} to configure"
186
        cp -v /etc/koha/SIPconfig.xml ${sipfile}
192
        touch $libdir/sip.enabled
187
        chown ${name}-koha:${name}-koha ${sipfile}
193
        if [[ ! -f "/etc/koha/sites/${name}/SIPconfig.xml" ]]; then
188
        chmod 600 ${sipfile}
194
            cp -v /etc/koha/SIPconfig.xml ${sipfile}
195
            chown ${name}-koha:${name}-koha ${sipfile}
196
            chmod 600 ${sipfile}
197
            echo "This is the first time SIP has been enabled. Please check the configurations in /etc/koha/sites/${name}/SIPconfig.xml"
198
        fi
199
    fi
200
}
201
202
disable_sip()
203
{
204
    local name=$1
205
    local libdir=/var/lib/koha/${name}
206
207
    if is_sip_enabled ${name}; then
208
        # SIP is enabled, we should disable it
209
        echo "Stopping running SIP"
210
        stop_sip ${name}
211
        rm ${libdir}/sip.enabled
212
        echo "Information: SIP server disabled for ${name}"
213
    else
214
        echo " SIP server for ${name} not enabled - use koha-sip --enable <instance> to enable."
189
    fi
215
    fi
190
}
216
}
191
217
218
192
_check_and_fix_perms()
219
_check_and_fix_perms()
193
{
220
{
194
    local name=$1
221
    local name=$1
Lines 262-267 while [ $# -gt 0 ]; do Link Here
262
        --enable)
289
        --enable)
263
            set_action "enable"
290
            set_action "enable"
264
            shift ;;
291
            shift ;;
292
        --disable)
293
            set_action "disable"
294
            shift ;;
265
        -*)
295
        -*)
266
            die "Error: invalid option switch ($1)" ;;
296
            die "Error: invalid option switch ($1)" ;;
267
        *)
297
        *)
Lines 294-299 if [ $# -gt 0 ]; then Link Here
294
                    ;;
324
                    ;;
295
                "enable")
325
                "enable")
296
                    enable_sip $name
326
                    enable_sip $name
327
                    ;;
328
                "disable")
329
                    disable_sip $name
297
            esac
330
            esac
298
331
299
        else
332
        else
300
- 

Return to bug 24340