#!/bin/bash

RED='\033[0;31m' # color for echo in terminal
BLUE='\033[0;34m'
NC='\033[0m'

which unzip 1>/dev/null 2>&1 
if [ $? -ne 0 ]
then
 echo -e "$RED missing package : \"unzip\".$NC install unzip and relaunch \"./clean.sh\" afterwards"
else
	echo -e "$BLUE cleaning previous download of jgs_install.zip and its content ...$NC"
	rm -f autobuild.sha256 launcher.sh install.sh check_pkg.sh jgs_install.zip
	echo -e "$BLUE downloading (overwriting) jgs_install.zip ...$NC"
	wget  https://jgs.nexgate.ch/download/jgs_install.zip -O jgs_install.zip
	if [ $? -ne  0 ]
	then
 		echo -e "$RED downloading jgs_install.zip failed $NC"
	else
 		unzip jgs_install.zip
 		./install.sh
	fi
fi

echo -e "$BLUE cleaning current download of jgs_install.zip and its content ...$NC"
rm -f autobuild.sha256 launcher.sh install.sh check_pkg.sh jgs_install.zip

