Skip to content

Instantly share code, notes, and snippets.

@kspalaiologos
Created October 1, 2018 17:04
Show Gist options
  • Save kspalaiologos/fe74837776bbbf25a147ca9a49a68e76 to your computer and use it in GitHub Desktop.
Save kspalaiologos/fe74837776bbbf25a147ca9a49a68e76 to your computer and use it in GitHub Desktop.
Stupid script to build my things automatically.
#!/bin/sh
RED='\033[0;31m'
GREEN='\033[0;33m'
CLR='\033[2K'
NC='\033[0m'
function run {
c_time=$(sed -n 's/.*compile_delay *= *\([^ ]*.*\)/\1/p' < AUTOBUILD)
c_command=$(sed -n 's/.*compile_command *= *\([^ ]*.*\)/\1/p' < AUTOBUILD)
printf "Autobuild started.\n"
printf "Seconds between automatic builds: $c_time\n"
while [ true ]
do
eval $c_command
if [ $? != 0 ]
then
printf "$RED[`date +"%T"`]: "
printf "Build errored.\n$NC"
else
printf "$GREEN[`date +"%T"`]: "
printf "Build passed.\n$NC"
fi
sleep $c_time
done
}
function create {
echo "# Set delay between automatic compilations, in seconds." > AUTOBUILD
echo "compile_delay = 120" >> AUTOBUILD
echo "" >> AUTOBUILD
echo "# Set compilation command" >> AUTOBUILD
echo "compile_command = make clean all" >> AUTOBUILD
}
if [ -f AUTOBUILD ]
then
clear
run
else
printf "Creating configuration file..."
create
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment