Bash3lper/scripts/bashelper_list-script.sh

53 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Bash3lper.sh - Linux server tools
# Date: 2.2.2020
# Author : Erreur32
# - inspired by grabsysinfo.sh from Vivek Gite
# Define variables
LSB=/usr/bin/lsb_release
source bashelper_header
list_script (){
clear
write_header
write_header " Script Active LIST "
# set the prompt used by select, replacing "#?"
echo -e "\nPATH des scripts: $Bash3lper \n\n"
#echo -e "PATH Bscripts : $Bscripts "
#echo -e "PATH Bscript : $Bscript "
PS3="
Use '${GREEN}Number${NOC}' to select a ${RED}Script${NOC} or '${YELLOW}0${NOC}' to ${YELLOW}Return ${NOC}: "
#\\n Or Edit the Scripts with : 'edit'"
#if [[ "$REPLY" == edit ]]; then break; edit_script ; fi
#namescript="$Bscripts/"
namescript="scripts/"
#filename="${filename%.*}"
select filename in $namescript*.sh
do
# leave the loop if the user says '0'
if [[ "$REPLY" == 0 ]]; then break ; fi
# complain if no file was selected, and loop to ask again
if [[ "$filename" == "" ]]
then
echo "\n '$REPLY' is not a valid number"
continue
fi
# now we can use the selected file, trying to get it to run the shell script
# echo -e "Executing list_script $filename"
$filename
# it'll ask for another unless we leave the loop
# break
done
#And here's whats in one of the .sh files #export DIR="/script"
unset REPLY
echo -e "\n"
}
list_script