extract function "is-installed"

This commit is contained in:
Chai Feng 2018-10-06 21:40:21 +08:00
parent 1fe82b9560
commit 099f49653c
No known key found for this signature in database
GPG Key ID: 2DCD9A24E523FFD2

View File

@ -257,7 +257,7 @@ function ufw-docker--raw-command() {
}
function ufw-docker--install() {
if ! grep "^# BEGIN UFW AND DOCKER\$" /etc/ufw/after.rules &>/dev/null; then
if ! ufw-docker--is-installed; then
err "Back up /etc/ufw/after.rules"
cp /etc/ufw/after.rules /etc/ufw/after.rules-ufw-docker~"$(date '+%Y-%m-%d-%H%M%S').bak"
cat <<-\EOF | tee -a /etc/ufw/after.rules
@ -286,6 +286,10 @@ function ufw-docker--install() {
fi
}
function ufw-docker--is-installed() {
grep "^# BEGIN UFW AND DOCKER\$" /etc/ufw/after.rules &>/dev/null
}
function ufw-docker--help() {
cat <<-EOF >&2
Usage:
@ -371,7 +375,7 @@ case "$ufw_action" in
shift || true
"ufw-docker--$ufw_action" "$@"
;;
status|install)
status|install|is-installed)
ufw-docker--"$ufw_action"
;;
*)