From 7cc49f1e6e366953b904a52551e42383bf950ef8 Mon Sep 17 00:00:00 2001 From: "d.biryukov" Date: Sun, 12 Jan 2025 01:15:14 +0700 Subject: [PATCH] modify default behaviour of "./ex.sh link" command When executed without a "conf_file" argument, generate the client-link pair from each config file and write it to "conf/client_links.txt". --- ex.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ex.sh b/ex.sh index aeeb14e..88d2261 100755 --- a/ex.sh +++ b/ex.sh @@ -708,8 +708,23 @@ then conf_file=$2 if [ -v $conf_file ] then - echo -e "${red}no config is given${normal}" - exit 1 + if ! ls -U conf/config_client_*.json 1> /dev/null 2>&1; then + echo -e "${red}no config is given, and there are no any client configs${normal}" + exit 1 + fi + echo -e "${yellow}no config is given, a list of client-link pairs is +written to \033[33;3mconf/client_links.txt${yellow} from the following files:${normal}" + file="conf/client_links.txt" + : > $file + for conf_file in conf/config_client_*.json; do + echo -e "\033[33;3m - ${conf_file}${normal}" + basename=$(basename $conf_file .json) + client=${basename#config_client_} + link=$(generate_link $conf_file) + echo -e "${client}\n$link\n" >> $file + done + sed -i '$d' $file + exit 0 fi if [ ! -f $conf_file ] then