IchHabRecht icon

[BASH] CentOS service script for Redmine

IchHabRecht | PRO | 01/10/15 12:26:52 AM UTC | 0 ⭐ | 413 👁️ | Never ⏰ | []
Bash |

2.42 KB

|

None

|

0 👍

/

0 👎

#!/bin/sh
#
# redmine          Start/Stop the redmine webrick daemon.
#
# chkconfig: 2345 90 60
# description: Redmine is a flexible project management web application \
#              written using Ruby on Rails framework.
 
### BEGIN INIT INFO
# Provides: redmine
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start:  2345
# Default-Stop: 90
# Short-Description: run redmine daemon
# Description: Redmine is a flexible project management web application \
#              written using Ruby on Rails framework.
### END INIT INFO
 
[ -f /var/www/vhosts/redmine/script/rails ] || {
    [ "$1" = "status" ] && exit 4 || exit 6
}
 
RETVAL=0
prog="redmine"
exec=/usr/local/bin/ruby
exec_args="/var/www/vhosts/redmine/script/rails server webrick -e production -d"
pid_file=/var/www/vhosts/redmine/tmp/pids/server.pid
 
# Source function library.
. /etc/rc.d/init.d/functions
 
[ $UID -eq 0 ] && [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
start() {
    if [ $UID -ne 0 ] ; then
        echo "User has insufficient privilege."
        exit 4
    fi
    [ -x $exec ] || exit 5
    echo -n $"Starting $prog: "
    daemon --pidfile $pid_file $exec $exec_args
    retval=$?
    echo
}
 
stop() {
    if [ $UID -ne 0 ] ; then
        echo "User has insufficient privilege."
        exit 4
    fi
    echo -n $"Stopping $prog: "
    pid=$(cat $pid_file)
    if [ -n "$pid" ]; then
        killproc -p $pid_file $pid
        RETVAL=3
    else
        failure $"Stopping $prog"
    fi
    retval=$?
    echo
}
 
restart() {
    rh_status_q && stop
    start
}
 
reload() {
    restart
}
 
force_reload() {
    restart
}
 
rh_status() {
    # run checks to determine if the service is running or use generic status
    status -p $pid_file $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎