Blob Blame History Raw
#!/bin/sh
#
# firewalld	Startup script for the firewall daemon
#
# chkconfig: - 08 92
# description:	The firewall deamon manages the firewall and handles dynamic
#               firewall changes.
#
# config:	/etc/firewalld
# pidfile:      /var/run/firewalld.pid
#

### BEGIN INIT INFO
# Provides:  firewalld
# Required-Start: $syslog $local_fs messagebus
# Required-Stop: 
# Should-Start: 
# Should-Stop: 
# Default-Start: 
# Default-Stop: 
# Short-Description: 
# Description: 
### END INIT INFO

# Source function library.
. /etc/init.d/functions

exec="/usr/sbin/firewalld"
prog="firewalld"
#config="/etc/firewalld/firewalld.conf"

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

user_check() {
    if [ $UID -ne 0 ] ; then
        echo "User has insufficient privilege."
        exit 4
    fi
}

start() {
    user_check
    [ -x $exec ] || exit 5
#    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    daemon $exec $FIREWALLD_ARGS
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
}

stop() {
    user_check
    echo -n $"Stopping $prog: "
    killproc $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
}

restart() {
    stop
    start
}

reload() {
    user_check
    echo -n $"Reloading firewall: "
    firewall-cmd --reload
    retval=$?
    [ $retval -eq 0 ] && success || failure
    echo
}

force_reload() {
    restart
}

rh_status() {
    user_check
    # run checks to determine if the service is running or use generic status
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

usage() {
    echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
}

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
        ;;
    usage)
        usage
        exit 0
        ;;
    *)
        usage
        exit 2
esac
exit $?