#!/bin/sh # Initialization: . /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs echo osp $@ >> /tmp/osplog usage() { cat <<-! usage: $0 {start|stop|status|monitor|meta-data|validate-all} ! } meta_data() { cat < 1.0 Resource Agent for the osp SIP Proxy. osp resource agent IP Address of the osp Instance. This is only used for monitoring. IP Address Port of the osp Instance. This is only used for monitoring. Port END } osp_Status() { if [ $( curl --connect-timeout 1 -sL -w "%{http_code}" http://localhost:3001/subscriber/health -o /dev/null ) -eq "200" ] then return $OCF_SUCCESS else return $OCF_NOT_RUNNING fi } osp_Monitor( ) { osp_Status } osp_Start( ) { if osp_Status then ocf_log info "osp already running." return $OCF_SUCCESS else return $OCF_ERR_PERM /etc/init.d/osp start >/dev/null rc=$? if [ $rc -ne 0 ] then return $OCF_ERR_PERM else return $OCF_SUCCESS fi fi } osp_Stop( ) { /etc/init.d/osp stop >/dev/null return $OCF_SUCCESS } osp_Validate_All( ) { return $OCF_SUCCESS } if [ $# -ne 1 ]; then usage exit $OCF_ERR_ARGS fi case $1 in meta-data) meta_data exit $OCF_SUCCESS ;; start) osp_Start ;; stop) osp_Stop ;; monitor) osp_Monitor ;; status) osp_Status ;; validate-all) osp_Validate_All ;; notify) exit $OCF_SUCCESS ;; promote) exit $OCF_SUCCESS ;; demote) exit $OCF_SUCCESS ;; usage) usage exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_ARGS ;; esac exit $?