-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.sh
48 lines (46 loc) · 1.39 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
prompt_configuration()
{
printf "\t${BOLD}Configuration${NC}\n\n"
printf "The project directory (default: ../pipex): "
read project_directory
if [ -z "$project_directory" ]
then
project_directory="../pipex"
fi
if [ -z "$project_directory" ]
then
project_directory="../pipex"
fi
printf "\n"
printf "Would you like to check for updates on run ?\nThis option is recommended as the tester is still actively updated\n"
check_update=-1
while [ $check_update -ne 0 ] && [ $check_update -ne 1 ]
do
printf "Check for update on run [Y/n] "
read -N 1 -r check_update
[[ "$check_update" != $'\n' ]] && echo
case "$check_update" in
[nN]) check_update=0 ;;
[yY$'\n']) check_update=1 ;;
esac
if [ "$check_update" != "0" ] && [ "$check_update" != "1" ]
then
printf "${YELLOW}Unexpected answer. Please retry...${NC}\n"
check_update=-1
fi
done
if ! touch config.vars > /dev/null 2>&1 && ! [ -w config.vars ]
then
printf "${YELLOW}Unable to create the configuration file as your user...${NC}\n"
PROJECT_DIRECTORY=$project_directory
CHECK_UPDATE=$check_update
READ_CONFIG=0
else
echo "# This file was automatically generated by the pipex-tester" > config.vars
echo "# https://github.com/vfurmane/pipex-tester" >> config.vars
echo >> config.vars
echo "PROJECT_DIRECTORY='$project_directory'" >> config.vars
echo "CHECK_UPDATE=$check_update" >> config.vars
fi
}