summaryrefslogtreecommitdiff
path: root/pcr/openrc-net/ufw-2.initd
diff options
context:
space:
mode:
authorOmar Vega Ramos <ovruni@gnu.org.pe>2015-08-28 20:17:06 -0500
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2015-09-22 16:14:58 -0300
commit90cdef590d9a809d8aaa379d7b7af0a7be21669a (patch)
tree58687b5da505377ea94028d9e6498061dafcf932 /pcr/openrc-net/ufw-2.initd
parent34e667f817febcd3589e20b9d0dcb8cbf6c95fd7 (diff)
downloadabslibre-90cdef590d9a809d8aaa379d7b7af0a7be21669a.tar.gz
abslibre-90cdef590d9a809d8aaa379d7b7af0a7be21669a.tar.bz2
abslibre-90cdef590d9a809d8aaa379d7b7af0a7be21669a.zip
openrc-net-20150828-1: updating version
Diffstat (limited to 'pcr/openrc-net/ufw-2.initd')
-rw-r--r--pcr/openrc-net/ufw-2.initd137
1 files changed, 0 insertions, 137 deletions
diff --git a/pcr/openrc-net/ufw-2.initd b/pcr/openrc-net/ufw-2.initd
deleted file mode 100644
index 1ffd1c596..000000000
--- a/pcr/openrc-net/ufw-2.initd
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/sbin/runscript
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-firewall/ufw/files/ufw-2.initd,v 1.2 2012/06/13 21:14:52 thev00d00 Exp $
-
-depend() {
- before net
- provide firewall
-}
-
-start() {
- ebegin "Starting ufw"
- _source_file || { eend $?; return $?; }
-
- local enabled_in_cfg ret
- _check_if_enabled_in_cfg
- enabled_in_cfg=$?
-
- # Avoid "Firewall already started, use 'force-reload'" message that
- # appears if `ufw enable' had been run before start().
- if _status_quiet; then
- eend 0
- return
- fi
-
- # The ufw_start function does the same: if ufw is disabled using `ufw disable',
- # ufw_start would not start ufw and return 0, so let's handle this case.
- case $enabled_in_cfg in
- 0)
- ufw_start
- ret=$?
- eend $ret "Failed to start ufw."
- ;;
- 1)
- # see /etc/conf.d/<name>
- if [ "${ufw_nonfatal_if_disabled:-no}" != "yes" ]; then
- ret=1
- eend $ret "Not starting firewall (not enabled), use \"ufw enable\" first."
- else
- ret=0
- eend 0
- fi
- ;;
- 2)
- ret=1
- eend $ret "Failed to start ufw."
- ;;
- esac
-
- return $ret
-}
-
-stop() {
- ebegin "Stopping ufw"
- _source_file || { eend $?; return $?; }
- local enabled_in_cfg ret
- _check_if_enabled_in_cfg
- enabled_in_cfg=$?
-
- # Same as above (unless --force is passed to ufw_stop).
- case $enabled_in_cfg in
- 0)
- ufw_stop
- ret=$?
- ;;
- 1)
- einfo "INFO: ufw is configured to be disabled"
- ufw_stop --force
- ret=$?
- ;;
- 2)
- ret=1
- ;;
- esac
-
- eend $ret "Failed to stop ufw."
- return $ret
-}
-
-_status_quiet() {
- # return values: 0 - started, 1 - stopped, 2 - error
- # Does not execute _source_file.
- local ret
- ufw_status > /dev/null
- ret=$?
- # Return values for ufw_status come from /usr/share/ufw/ufw-init-functions.
- case $ret in
- 0) return 0 ;;
- 3) return 1 ;;
- *) return 2 ;;
- esac
-}
-
-_source_file() {
- local sourced_f="/usr/share/ufw/ufw-init-functions"
- if [ ! -f "$sourced_f" ]; then
- eerror "Cannot find file $sourced_f!"
- return 1
- fi
-
- local _path=$PATH
- if ! . "$sourced_f"; then
- # PATH can be broken here, fix it...
- PATH=$_path
- eerror "Error sourcing file $sourced_f"
- return 1
- fi
-
- if [ -z "$PATH" ]; then
- PATH=$_path
- else
- PATH="${PATH}:${_path}"
- fi
- return 0
-}
-
-_check_if_enabled_in_cfg() {
- # Check if user has enabled the firewall with "ufw enable".
- # Return 0 if firewall enabled in configuration file, 1 otherwise, 2 on error.
-
- local sourced_f="/etc/ufw/ufw.conf"
- if [ ! -f "$sourced_f" ]; then
- eerror "Cannot find file $sourced_f!"
- return 2
- fi
-
- if ! . "$sourced_f"; then
- eerror "Error sourcing file $sourced_f"
- return 2
- fi
-
- if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
- return 0
- else
- return 1
- fi
-}