1- # SPDX-FileCopyrightText: 2018 Sebastian Wagner
1+ # SPDX-FileCopyrightText: 2018-2020 nic.at GmbH, 2025 Institute for Common Good Technology
22#
33# SPDX-License-Identifier: AGPL-3.0-or-later
44# bash completion for intelmqctl -*- shell-script -*-
@@ -18,6 +18,9 @@ _intelmqctl ()
1818 return 0
1919 fi
2020
21+ which yq >& /dev/null
22+ misses_yq=$?
23+
2124 # echo "posice: $COMP_CWORD $COMP_WORDS";
2225 case $COMP_CWORD in
2326 1)
@@ -26,19 +29,20 @@ _intelmqctl ()
2629 return 0
2730 ;;
2831 2)
29- pipeline =' /opt/intelmq/etc/pipeline.conf ' ;
30- [ -f ${pipeline } ] || pipeline =' /etc/intelmq/pipeline.conf ' ;
32+ runtime =' /opt/intelmq/etc/runtime.yaml ' ;
33+ [ -f ${runtime } ] || runtime =' /etc/intelmq/runtime.yaml ' ;
3134 case " ${COMP_WORDS[1]} " in
3235 start | stop | restart | status | reload | log | run | enable | disable)
33- runtime=' /opt/intelmq/etc/runtime.conf' ;
34- [ -f ${runtime} ] || runtime=' /etc/intelmq/runtime.conf' ;
35- local bots=$( jq ' keys[]' $runtime ) ;
36+ [[ " $misses_yq " -eq 1 ]] && return 0
37+ local bots=$( yq ' keys[]' $runtime | grep -v ' ^global$' ) ;
3638 COMPREPLY=($( compgen -W " ${bots} " -- ${cur} ) );
3739 return 0
3840 ;;
3941 clear)
40- local bots=$( jq ' .[] | .["source-queue"]' $pipeline | grep -v ' ^null$' ; jq ' .[] | .["destination-queues"]' $pipeline | grep -v ' ^null$' | jq ' .[]' ) ;
41- COMPREPLY=($( compgen -W " ${bots} " -- ${cur} ) );
42+ [[ " $misses_yq " -eq 1 ]] && return 0
43+ local destination_queues=$( yq ' .[] | .["parameters"] | .["destination_queues"] | .[] | .[]' $runtime ) ;
44+ local source_queues=$( yq ' keys[]' $runtime | grep -v ' ^global$' | while read line; do echo " $line -queue" ; done)
45+ COMPREPLY=($( compgen -W " ${source_queues} ${destination_queues} " -- ${cur} ) );
4246 return 0
4347 ;;
4448 list)
0 commit comments