Add fwl, fix pkm & vm_inst, update debian_preseed & provision_linux

This commit is contained in:
mitchell 2022-01-31 15:03:55 -05:00
parent 7f0d7d6f6f
commit 351d4c0574
5 changed files with 152 additions and 86 deletions

View 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

View file

@ -26,6 +26,7 @@ end
function _pacman_commander -a pkm command
set -l args $argv[3..]
set pkm (string split ' ' $pkm)
switch $command
case i install
@ -48,6 +49,7 @@ end
function _apt_commander -a pkm command
set -l args $argv[3..]
set pkm (string split ' ' $pkm)
switch $command
case i install

View file

@ -1,35 +1,24 @@
function vm_inst -a name os_variant install_source
argparse \
--ignore-unknown \
'm/memory=' \
'c/cpus=' \
'd/disk-size=' \
'b/bridge=' \
s/backing_store \
'b/bridge=?' \
s/backing-store \
i/import \
n/netboot \
--ignore-unknown \
-- $argv
or return
set -l memory 4096
set -l memory 2048
set -l vcpus 2
set -l disk_size 40
set -l disk_size 10
set -l bridge_iface br0
if test -n "$_flag_m"
set memory $_flag_m
end
if test -n "$_flag_c"
set vcpus $_flag_c
end
if test -n "$_flag_d"
set disk_size $_flag_d
end
if test -n "$_flag_b"
set bridge_iface $_flag_b
end
set -q "$_flag_memory"; and set memory $_flag_m
set -q "$_flag_cpus"; and set vcpus $_flag_c
set -q "$_flag_disk_size"; and set disk_size $_flag_d
set -q "$_flag_bridge"; and not math $_flag_b &>/dev/null; or set bridge_iface $_flag_b
set -l inst_args \
--name $name \
@ -37,20 +26,20 @@ function vm_inst -a name os_variant install_source
--vcpus $vcpus \
--os-variant $os_variant
if test -n "$_flag_b"
if set -q "$_flag_bridge"
set inst_args $inst_args \
--network bridge=$bridge_iface
end
if test -n "$_flag_i"
if test -n "$_flag_import"
set inst_args $inst_args \
--disk $install_source \
--import
else if test -n "$_flag_s"
else if test -n "$_flag_backing_store"
set inst_args $inst_args \
--disk size=$disk_size,sparse=yes,backing_store=$install_source \
--import
else if test -n "$_flag_n"
else if test -n "$_flag_netboot"
set inst_args $inst_args \
--disk size=$disk_size,sparse=yes \
--pxe
@ -60,5 +49,5 @@ function vm_inst -a name os_variant install_source
--cdrom $install_source
end
virt-install $inst_args $argv
virt-install $inst_args $argv[4..-1]
end