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".
This commit is contained in:
d.biryukov
2025-01-12 01:15:14 +07:00
parent a9a02c387e
commit 7cc49f1e6e

17
ex.sh
View File

@@ -708,9 +708,24 @@ then
conf_file=$2 conf_file=$2
if [ -v $conf_file ] if [ -v $conf_file ]
then then
echo -e "${red}no config is given${normal}" 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 exit 1
fi 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 ] if [ ! -f $conf_file ]
then then
echo -e "${red}file ${conf_file} does not exist${normal}" echo -e "${red}file ${conf_file} does not exist${normal}"