add confirmation dialog before initializing template

This commit is contained in:
Maximilian Keßler 2022-02-16 12:00:42 +01:00
parent bcdd4124cb
commit 46af218046

22
init.sh
View file

@ -4,12 +4,30 @@ if [[ $(pwd) == *template* ]]
then then
echo "Don't run this in the template directory!" echo "Don't run this in the template directory!"
echo "Rename the current folder or edit init.sh to do this anyways" echo "Rename the current folder or edit init.sh to do this anyways"
exit echo "The folder name must not contain the name 'template' or build will be aborted"
exit 1
fi
source config
# More safety second
echo "--------------------------------------------------------"
echo "THIS SCRIPT WILL NOW IRREVOCABLY DESTROY THIS TEMPLATE "
echo "REPOSITORY AND REPLACE IT WITH A NEW ONE WITH YOUR GIVEN"
echo "PARAMETERS IN 'config'. "
echo "ALL PRIOR DATA, INCLUDING BUT NOT LIMITED TO THE GIT "
echo "HISTORY IN THIS DIRECTORY AND ALL ITS SUBDIRECTORIES "
echo "WILL BE LOST. "
echo " "
read -p "ARE YOU SURE YOU WANT TO CONTINUE? (y/n) " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi fi
{ ## DO NOT REMOVE THIS OR EVERYTHING BLOWS UP { ## DO NOT REMOVE THIS OR EVERYTHING BLOWS UP
cat config cat config
source config
cd template cd template
find -type f | xargs sed -i "s/\$mainfile/$(printf '%s\n' "$mainfile" | sed -e 's/[\/&]/\\&/g')/g" find -type f | xargs sed -i "s/\$mainfile/$(printf '%s\n' "$mainfile" | sed -e 's/[\/&]/\\&/g')/g"
find -type f | xargs sed -i "s/\$course/$(printf '%s\n' "$course" | sed -e 's/[\/&]/\\&/g')/g" find -type f | xargs sed -i "s/\$course/$(printf '%s\n' "$course" | sed -e 's/[\/&]/\\&/g')/g"