From 26984c39b8d30a7358ca1d931da334fbe5141e3d Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 27 Nov 2019 15:26:43 +0000 Subject: [PATCH] Add options to srslte_install_configs.sh to install clean configs. --- cmake/modules/SRSLTE_install_configs.sh.in | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/cmake/modules/SRSLTE_install_configs.sh.in b/cmake/modules/SRSLTE_install_configs.sh.in index 6f45a1e7c..5cbfbc66d 100755 --- a/cmake/modules/SRSLTE_install_configs.sh.in +++ b/cmake/modules/SRSLTE_install_configs.sh.in @@ -27,16 +27,43 @@ else exit fi +if [ "$2" == "--force" ] +then + echo "Force overwrite called. Overwritting any existing configuration files." + read -e -p "Is this OK? [y/n]: " choice + [[ "$choice" == [Yy]* ]] && force_install="true" || exit +elif [ "$2" == "--force-no-db" ] +then + echo "Force overwrite called. Overwritting all existing configuration files, except ue_db.csv." + read -e -p "Is this OK? [y/n]: " choice + if [[ "$choice" == [Yy]* ]] ; then force_install="true" && no_db="true"; else exit; fi +elif [ "$2" == "" ] +then + : #NOOP +else + echo "Invalid command line option provided." + exit +fi + + install_file(){ source_path="$SRSLTE_INSTALL_DIR/$1" dest_path=$(echo "$dest_folder/$1" | sed 's/\.[^.]*$//') # Strip .example from filename # Check if config file already exists in location if [ -f $dest_path ]; then - echo " - $dest_path already exists. Skipping it." - return + # If --force option is selected, overwrite file + if [ "$force_install" != "true" ] && [ "$no_db" != "true" ] ; then + echo " - $dest_path already exists. Skipping it." + return + fi + # If --force-no-db option is selected, overwrite file unless it ends in ".csv" + if [ "$force_install" == "true" ] && [ "$no_db" == "true" ] && [[ $dest_path =~ \.csv$ ]]; then + echo " - $dest_path already exists. Skipping it." + return + fi fi - + # Check if config file exists in source location if [ -f $source_path ]; then echo " - Installing $1 in $dest_path"