mirror of
https://github.com/mitchell/dotfiles.git
synced 2025-12-17 20:37:22 +00:00
Add fwl, fix pkm & vm_inst, update debian_preseed & provision_linux
This commit is contained in:
parent
7f0d7d6f6f
commit
351d4c0574
5 changed files with 152 additions and 86 deletions
54
.config/fish/functions/fwl.fish
Normal file
54
.config/fish/functions/fwl.fish
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
function fwl -d 'Function to simplify interacting with firewalld'
|
||||
argparse --ignore-unknown \
|
||||
p/permanent \
|
||||
r/reset \
|
||||
'z/zone=' \
|
||||
'o/policy=' \
|
||||
's/service=' \
|
||||
-- $argv
|
||||
|
||||
if set -q _flag_reset
|
||||
echo 'Resetting fwl ...'
|
||||
_fwl_reset
|
||||
return
|
||||
end
|
||||
|
||||
if set -q _flag_permanent
|
||||
if set -q _fwl_perm
|
||||
set -ge _fwl_perm
|
||||
else
|
||||
set -g _fwl_perm --permanent
|
||||
end
|
||||
end
|
||||
|
||||
if set -q _flag_zone
|
||||
set -g _fwl_mode "--zone=$_flag_z"
|
||||
else if set -q _flag_policy
|
||||
set -g _fwl_mode "--policy=$_flag_o"
|
||||
else if set -q _flag_service
|
||||
set -g _fwl_mode "--service=$_flag_s"
|
||||
end
|
||||
|
||||
echo fwl_mode={$_fwl_perm} $_fwl_mode
|
||||
|
||||
test -z "$argv"; and return
|
||||
|
||||
switch $argv
|
||||
case i info
|
||||
set argv --list-all
|
||||
case a all
|
||||
set argv --list-all-zones
|
||||
case on all-on
|
||||
set argv --get-active-zones
|
||||
case s services
|
||||
set argv --get-services
|
||||
end
|
||||
|
||||
sudo firewall-cmd {$_fwl_perm} {$_fwl_mode} $argv
|
||||
end
|
||||
|
||||
function _fwl_reset -d 'Reset fwl global variables'
|
||||
set -ge _fwl_mode
|
||||
set -ge _fwl_perm
|
||||
return 0
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue