From 3a92c96ba66b256db30b5325267cb123cbe9b7b6 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Tue, 26 Jan 2016 02:27:24 -0500 Subject: Add function to bash-completion script to fix message "bad array subscript" --- etc/bash_completion.d/vyatta-op | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'etc') diff --git a/etc/bash_completion.d/vyatta-op b/etc/bash_completion.d/vyatta-op index c820305..47092a2 100644 --- a/etc/bash_completion.d/vyatta-op +++ b/etc/bash_completion.d/vyatta-op @@ -104,14 +104,14 @@ _vyatta_op_default_expand () local wc=${#COMP_WORDS[@]} if [[ "${COMP_WORDS[0]}" =~ "/" ]]; then # if we are looking for a directory on the first completion then do directory completions - _filedir_xspec + _filedir_xspec_vyos elif (( wc < 2 )) || [[ $COMP_CWORD -eq 0 ]] || [[ $1 == $2 ]]; then _vyatta_op_expand "$@" else # after the first word => cannot be vyatta command so use original default - _filedir_xspec + _filedir_xspec_vyos fi } @@ -599,6 +599,48 @@ _vyatta_set_comptype () done } +_filedir_xspec_vyos() +{ + local cur prev words cword + _init_completion || return + + _tilde "$cur" || return 0 + + local IFS=$'\n' xspec=${_xspec[${1##*/}]} tmp + local -a toks + + toks=( $( + compgen -d -- "$(quote_readline "$cur")" | { + while read -r tmp; do + printf '%s\n' $tmp + done + } + )) + + # Munge xspec to contain uppercase version too + # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306 + eval xspec="${xspec}" + local matchop=! + if [[ $xspec == !* ]]; then + xspec=${xspec#!} + matchop=@ + fi + xspec="$matchop($xspec|${xspec^^})" + + toks+=( $( + eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | { + while read -r tmp; do + [[ -n $tmp ]] && printf '%s\n' $tmp + done + } + )) + + if [[ ${#toks[@]} -ne 0 ]]; then + compopt -o filenames + COMPREPLY=( "${toks[@]}" ) + fi +} + nullglob_save=$( shopt -p nullglob ) shopt -s nullglob for f in ${vyatta_datadir}/vyatta-op/functions/allowed/* ; do -- cgit v1.2.3 From 6f9273fe6e5585b6a7e8e076916f9429d472a002 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 15 Sep 2017 09:19:23 +0200 Subject: T394: copy vyatta_* environment variables to vyos_* equivalents. --- etc/default/vyatta.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'etc') diff --git a/etc/default/vyatta.in b/etc/default/vyatta.in index 88940f5..3601f36 100644 --- a/etc/default/vyatta.in +++ b/etc/default/vyatta.in @@ -26,57 +26,73 @@ unset _vyatta_extglob if test -z "$vyatta_prefix" ; then if test -n "@prefix@" ; then declare -x -r vyatta_prefix=@prefix@ + declare -x -r vyos_prefix=@prefix@ else declare -x -r vyatta_prefix=/opt/vyatta + declare -x -r vyos_prefix=/opt/vyatta fi fi if test -z "$vyatta_exec_prefix" ; then if test -n "@exec_prefix@" ; then declare -x -r vyatta_prefix=@exec_prefix@ + declare -x -r vyos_prefix=@exec_prefix@ else declare -x -r vyatta_prefix=$vyatta_prefix + declare -x -r vyos_prefix=$vyatta_prefix fi fi if test -z "$vyatta_datarootdir" ; then if test -n "@datarootdir@" ; then declare -x -r vyatta_datarootdir=@datarootdir@ + declare -x -r vyos_datarootdir=@datarootdir@ else declare -x -r vyatta_datarootdir=$vyatta_prefix/share + declare -x -r vyos_datarootdir=$vyatta_prefix/share fi fi if test -z "$vyatta_bindir" ; then if test -n "@bindir@" ; then declare -x -r vyatta_bindir=@bindir@ + declare -x -r vyos_bindir=@bindir@ else declare -x -r vyatta_bindir=$vyatta_exec_prefix/bin + declare -x -r vyos_bindir=$vyatta_exec_prefix/bin fi fi if test -z "$vyatta_sbindir" ; then if test -n "@sbindir@" ; then declare -x -r vyatta_sbindir=@sbindir@ + declare -x -r vyos_sbindir=@sbindir@ else declare -x -r vyatta_sbindir=$vyatta_exec_prefix/sbin + declare -x -r vyos_sbindir=$vyatta_exec_prefix/sbin fi fi if test -z "$vyatta_libdir" ; then if test -n "@libdir@" ; then declare -x -r vyatta_libdir=@libdir@ + declare -x -r vyos_libdir=@libdir@ else declare -x -r vyatta_libdir=$vyatta_exec_prefix/lib + declare -x -r vyos_libdir=$vyatta_exec_prefix/lib fi fi if test -z "$vyatta_libexecdir" ; then if test -n "@libexecdir@" ; then declare -x -r vyatta_libexecdir=@libexecdir@ + declare -x -r vyos_libexecdir=@libexecdir@ else declare -x -r vyatta_libexecdir=$vyatta_exec_prefix/libexec + declare -x -r vyos_libexecdir=$vyatta_exec_prefix/libexec fi fi if test -z "$vyatta_datadir" ; then if test -n "@datadir@" ; then declare -x -r vyatta_datadir=@datadir@ + declare -x -r vyos_datadir=@datadir@ else declare -x -r vyatta_datadir=$vyatta_datarootdir + declare -x -r vyos_datadir=$vyatta_datarootdir fi fi if test -z "$vyatta_htmldir" ; then @@ -131,12 +147,15 @@ unset _vyatta_extglob if test -z "$vyatta_op_templates" ; then declare -x -r vyatta_op_templates=$vyatta_datadir/vyatta-op/templates + declare -x -r vyos_op_templates=$vyatta_datadir/vyatta-op/templates fi if test -z "$vyatta_cfg_templates" ; then declare -x -r vyatta_cfg_templates=$vyatta_datadir/vyatta-cfg/templates + declare -x -r vyos_cfg_templates=$vyatta_datadir/vyatta-cfg/templates fi if test -z "$vyatta_configdir" ; then declare -x -r vyatta_configdir=$vyatta_prefix/config + declare -x -r vyos_configdir=$vyatta_prefix/config fi for var in prefix exec_prefix datarootdir ; do -- cgit v1.2.3 From 1c911e9b090638abebb0f91b20e2f42e7ebe2a28 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 16 May 2018 15:47:37 +0200 Subject: T644: point vyos_* dirs to the /usr/ hierarchy intead of /opt/vyatta --- etc/default/vyatta.in | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'etc') diff --git a/etc/default/vyatta.in b/etc/default/vyatta.in index 3601f36..9841dc5 100644 --- a/etc/default/vyatta.in +++ b/etc/default/vyatta.in @@ -53,19 +53,15 @@ unset _vyatta_extglob if test -z "$vyatta_bindir" ; then if test -n "@bindir@" ; then declare -x -r vyatta_bindir=@bindir@ - declare -x -r vyos_bindir=@bindir@ else declare -x -r vyatta_bindir=$vyatta_exec_prefix/bin - declare -x -r vyos_bindir=$vyatta_exec_prefix/bin fi fi if test -z "$vyatta_sbindir" ; then if test -n "@sbindir@" ; then declare -x -r vyatta_sbindir=@sbindir@ - declare -x -r vyos_sbindir=@sbindir@ else declare -x -r vyatta_sbindir=$vyatta_exec_prefix/sbin - declare -x -r vyos_sbindir=$vyatta_exec_prefix/sbin fi fi if test -z "$vyatta_libdir" ; then @@ -80,10 +76,8 @@ unset _vyatta_extglob if test -z "$vyatta_libexecdir" ; then if test -n "@libexecdir@" ; then declare -x -r vyatta_libexecdir=@libexecdir@ - declare -x -r vyos_libexecdir=@libexecdir@ else declare -x -r vyatta_libexecdir=$vyatta_exec_prefix/libexec - declare -x -r vyos_libexecdir=$vyatta_exec_prefix/libexec fi fi if test -z "$vyatta_datadir" ; then @@ -161,7 +155,27 @@ unset _vyatta_extglob for var in prefix exec_prefix datarootdir ; do eval test -n \"\$_vyatta_save_$var\" \&\& $var=\$_vyatta_save_$var done - + + # It's not like we do, or should support installing VyOS at a different prefix + declare -x -r vyos_libexec_dir=/usr/libexec/vyos + declare -x -r vyos_bin_dir=/usr/bin + declare -x -r vyos_sbin_dir=/usr/sbin + + if test -z "$vyos_conf_scripts_dir" ; then + declare -x -r vyos_conf_scripts_dir=$vyos_libexec_dir/conf_mode + fi + + if test -z "$vyos_op_scripts_dir" ; then + declare -x -r vyos_op_scripts_dir=$vyos_libexec_dir/op_mode + fi + + if test -z "$vyos_completion__dir" ; then + declare -x -r vyos_completion_dir=$vyos_libexec_dir/completion + fi + + if test -z "$vyos_validators_dir" ; then + declare -x -r vyos_validators_dir=$vyos_libexec_dir/validators + fi } 2>/dev/null || : -- cgit v1.2.3 From b9c3925b1f68534b51f4d2f2b239ae7cdd2ef030 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 5 Jun 2018 20:48:32 +0200 Subject: T684: make the 'run show configuration commands' and the |commands pipe use the new implementation. --- etc/bash_completion.d/vyatta-op | 2 +- templates/show/configuration/commands/node.def | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'etc') diff --git a/etc/bash_completion.d/vyatta-op b/etc/bash_completion.d/vyatta-op index 47092a2..d917806 100644 --- a/etc/bash_completion.d/vyatta-op +++ b/etc/bash_completion.d/vyatta-op @@ -500,7 +500,7 @@ strip-private () commands () { if [ "$_OFR_CONFIGURE" != "" ]; then - ${vyatta_sbindir}/vyatta-config-gen-sets.pl - + ${vyos_libexec_dir}/commands-pipe.py else echo "commands pipe is not supported in operational mode" fi diff --git a/templates/show/configuration/commands/node.def b/templates/show/configuration/commands/node.def index a2d55cf..f2e047e 100644 --- a/templates/show/configuration/commands/node.def +++ b/templates/show/configuration/commands/node.def @@ -1,7 +1,7 @@ help: Show running configuration as set commands run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; then - ${vyatta_sbindir}/vyatta-config-gen-sets.pl + cli-shell-api showCfg --show-active-only | vyos-config-to-commands else echo Must be an admin user to run this command. fi -- cgit v1.2.3