config version check

This commit is contained in:
timerix 2022-09-09 21:43:26 +06:00
parent e20733c173
commit 018f34f15d
3 changed files with 29 additions and 8 deletions

View File

@ -15,4 +15,4 @@ bash cbuild/chmod_scripts.sh
make make
``` ```
You can create your own default config. Put it in project directory and name default.config.sh You can create your own default config. Put it in project directory and name default.config

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
CONFIG_VER=2
PROJECT=some_project PROJECT=some_project
CMP_C=gcc CMP_C=gcc

34
init.sh
View File

@ -3,15 +3,35 @@
source cbuild/colors.sh source cbuild/colors.sh
source cbuild/functions.sh source cbuild/functions.sh
#config function create_default_config(){
if [ -f "default.config" ]; then
cp default.config .config
else
cp cbuild/default.config .config
fi
print "${YELLOW}Default config created.\nEdit it.\n"
}
#.config
if [ ! -f ".config" ]; then if [ ! -f ".config" ]; then
print "${YELLOW}./.config doesn't exist\n" print "${YELLOW}./.config doesn't exist\n"
if [ -f "default.config.sh" ]; then create_default_config
cp default.config.sh .config
else
cp cbuild/default.config.sh .config
fi
print "${YELLOW}Default config created.\nEdit it's values.\n"
exit exit
fi fi
source .config source .config
#version check
if [ ! $CONFIG_VER -eq 2 ]; then
print "${RED}Your config version isn't correct"
while true; do
print "${WHITE}Backup current config and create default one? (y/n) "
read answ
case $answ in
[Yy] )
cp .config .config.backup
create_default_config
exit;;
[Nn] ) exit;;
* ) print "${RED}incorrect answer\n";;
esac
done
fi