aboutsummaryrefslogtreecommitdiff
path: root/network/firewalld/rc.FireWallD
blob: aa0d91b3dcbf44667205f6dd06c56eddf3fde904 (plain)
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
#!/bin/sh
# Start/stop/restart firewalld.

# Start firewalld:
firewalld_start() {
  [ -r /etc/default/firewalld ] && source /etc/default/firewalld
  echo -n "Starting FireWallD daemon:  /usr/sbin/firewalld "
  /usr/sbin/firewalld $FIREWALLD_ARGS
  echo
}

# Stop firewalld:
firewalld_stop() {
  echo -n "Stopping FireWallD daemon..."
  if [ -r /var/run/firewalld.pid ]; then
    kill -HUP $(cat /var/run/firewalld.pid)
    rm -f /var/run/firewalld.pid
  else
    killall -HUP -q firewalld
  fi
  echo
}

# Restart firewalld:
firewalld_restart() {
  firewalld_stop
  sleep 1
  firewalld_start
}

# Check if firewalld is running
firewalld_status() {
  if [ -e /var/run/firewalld.pid ]; then
    echo "firewalld is running as pid $(cat /var/run/firewalld.pid)."
  else 
    echo "firewalld is stopped."
    exit 1
  fi
}

case "$1" in
'start')
  firewalld_start
  ;;
'stop')
  firewalld_stop
  ;;
'restart')
  firewalld_restart
  ;;
'status')
  firewalld_status
  ;;
*)
  echo "usage $0 start|stop|restart|status"
esac