From 0ce95ca7df0d741374cd8e12917ba457512e311a Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 18 Sep 2023 18:11:21 +0200 Subject: [PATCH 1/5] try to fix rc -r --- TODO | 1 - src/completions.sh | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index caa4105..622b3ab 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -- fix the 3 mode commands to use -m so completion works correctly - vnet ipv6 doesnt work anymore UPDATE: with auto_linklocal seems to work after some seconds - on reboot, no pf will be started diff --git a/src/completions.sh b/src/completions.sh index 2cc6723..45fd4d6 100644 --- a/src/completions.sh +++ b/src/completions.sh @@ -21,6 +21,15 @@ reply_version() { COMPREPLY=( $(compgen -W "${versions[*]}" -- "$cur") ) } +reply_rcscripts() { + local jail=${COMP_WORDS[2]} + local scripts=$(jaildk _get_rc_scripts $jail | sed 's|.*/||') + scripts=${scripts//$'\n'/ } + scripts=${scripts//$'\r'/} + echo "[jail=$jail] [cur=$cur] [scripts=${scripts[*]}]" > debug.log + COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) +} + functions='mount,ports,mtree,pf' modes='start,stop,status,restart' @@ -69,7 +78,7 @@ subcmd_opts_status=(-v) subcmd_args_status=@jail ### sub cmd rc -subcmd_opts_rc=(-m:$modes -r) +subcmd_opts_rc=(-m:$modes -r:@rcscripts) subcmd_args_rc=@jail ### sub cmd ipfw From cbac202c38017fc201ddcd136288909d07f11d9b Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 18 Sep 2023 18:15:56 +0200 Subject: [PATCH 2/5] sub completion still fails, revert --- src/completions.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/completions.sh b/src/completions.sh index 45fd4d6..3d536ca 100644 --- a/src/completions.sh +++ b/src/completions.sh @@ -21,14 +21,14 @@ reply_version() { COMPREPLY=( $(compgen -W "${versions[*]}" -- "$cur") ) } -reply_rcscripts() { - local jail=${COMP_WORDS[2]} - local scripts=$(jaildk _get_rc_scripts $jail | sed 's|.*/||') - scripts=${scripts//$'\n'/ } - scripts=${scripts//$'\r'/} - echo "[jail=$jail] [cur=$cur] [scripts=${scripts[*]}]" > debug.log - COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) -} +# reply_rcscripts() { +# local jail=${COMP_WORDS[2]} +# local scripts=$(jaildk _get_rc_scripts $jail | sed 's|.*/||') +# scripts=${scripts//$'\n'/ } +# scripts=${scripts//$'\r'/} +# echo "[jail=$jail] [cur=$cur] [scripts=${scripts[*]}]" > debug.log +# COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) +# } functions='mount,ports,mtree,pf' modes='start,stop,status,restart' @@ -78,7 +78,7 @@ subcmd_opts_status=(-v) subcmd_args_status=@jail ### sub cmd rc -subcmd_opts_rc=(-m:$modes -r:@rcscripts) +subcmd_opts_rc=(-m:$modes -r) subcmd_args_rc=@jail ### sub cmd ipfw From f43da7f0b099eaa8ed96f4e9ac63dc8f0c68fdeb Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 19 Sep 2023 16:59:11 +0200 Subject: [PATCH 3/5] finally fix https://github.com/adoyle-h/bash-completor/discussions/2 by just using the rc-scripts directly --- src/completions.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/completions.sh b/src/completions.sh index 3d536ca..ee64dba 100644 --- a/src/completions.sh +++ b/src/completions.sh @@ -21,14 +21,16 @@ reply_version() { COMPREPLY=( $(compgen -W "${versions[*]}" -- "$cur") ) } -# reply_rcscripts() { -# local jail=${COMP_WORDS[2]} -# local scripts=$(jaildk _get_rc_scripts $jail | sed 's|.*/||') -# scripts=${scripts//$'\n'/ } -# scripts=${scripts//$'\r'/} -# echo "[jail=$jail] [cur=$cur] [scripts=${scripts[*]}]" > debug.log -# COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) -# } +# we're taking the easy path here. There might be cases where the +# $name_enable variable doesn't match the actual rc-Script, which +# we will not catch the way we're doing it here, but these are rare +# and the user can specify something manually as well. Also this +# method is way faster than executing rcorder inside the jail +reply_rcscripts() { + local jail=${COMP_WORDS[2]} + local scripts=$(ls $JAILDIR/run/$jail/usr/local/etc/rc.d) + COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) +} functions='mount,ports,mtree,pf' modes='start,stop,status,restart' @@ -78,7 +80,7 @@ subcmd_opts_status=(-v) subcmd_args_status=@jail ### sub cmd rc -subcmd_opts_rc=(-m:$modes -r) +subcmd_opts_rc=(-m:$modes -r:@rcscripts) subcmd_args_rc=@jail ### sub cmd ipfw From 2151ad6cc82402dfcbb8e36554399e98f63f1efc Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Thu, 21 Sep 2023 12:02:30 +0200 Subject: [PATCH 4/5] fix #16: call `jaildk_start` with `-m` interanally as well --- src/jaildk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jaildk.sh b/src/jaildk.sh index 77528cd..ef19eb4 100755 --- a/src/jaildk.sh +++ b/src/jaildk.sh @@ -1344,7 +1344,7 @@ jaildk_jail() { case $mode in *) service jail $mode $jail - jaildk_ipfw $jail $mode + jaildk_ipfw $jail -m $mode ;; esac fi From 20f95781d9c1d8b37a6f811a9628f0c679a1bc66 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 17 Sep 2024 13:58:42 +0200 Subject: [PATCH 5/5] fix makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3729d1b..f55a9a2 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ all: rm -f src/_jaildk-completion.bash install: - sh jaildk setup $JAILDIR + sh jaildk setup $(JAILDIR) clean: rm -f jaildk