Script to automate nightly installer download (windows / linux)

Hi,
Every morning I do:

  1. Go to https://kicad-downloads.s3.cern.ch/index.html?prefix=windows/nightly/ by using web browser (chrome);
  2. Download latest “kicad-msvc.*-x86_64-lite.exe” to my PC for archive purpose;
  3. Run installer (update kidcad to latest nightly).

How can I automate steps 1 and 2 by some kind of script?

I have access to usual windows (cmd.exe) and linux command line tools (cURL, wGet).

If I do plain curl https://kicad-downloads.s3.cern.ch/index.html?prefix=windows/nightly/,
I get blank html source, without dynamically loaded contents which I need. Actual links to “kicad-msvc.*-x86_64-lite.exe” are loaded dynamically by javascript. Is it possible to handle dynamic webpages without having additional tools installed on my OS?

This will give you list of files,

curl 'https://kicad-downloads.s3.cern.ch/?delimiter=/&prefix=windows/nightly/' | egrep -o 'kicad-msvc[a-zA-Z0-9._\-]*lite.exe'

To get a download url just add https://kicad-downloads.s3.cern.ch/windows/nightly/ prefix with awk/sed.

1 Like

Thank you for very qui1ck answer! :slight_smile:
Here is the script in case someone is willing to reuse. It is running with msys2 installed on my windows.

#!/bin/sh

FILE=$(curl --silent 'https://kicad-downloads.s3.cern.ch/?delimiter=/&prefix=windows/nightly/' | egrep -o 'kicad-msvc[a-zA-Z0-9._\-]*x86_64-lite.exe' | tail -1)

# Check curl success
if [ -z "$FILE" ];	then 
	{
		printf "curl fail, terminate\n";
		exit 1;
	}
fi

printf "Latest installer: $FILE \n"

if test -f "$FILE";
	then 
	{
		printf "Error: \"$FILE\" is already downloaded, terminate";
		exit 1;
	}
fi

# download installer
curl https://kicad-downloads.s3.cern.ch/windows/nightly/$FILE --output $FILE

# check curl error
res=$?
if test "$res" != "0";
	then
	{
		printf "Error: curl failed with: $res, terminate\n"
		exit 1;
	}
fi

start "" "$FILE" /B

Addition (run installer silently):
I could not run installer in silent mode (/S), so this workaround worked (last lines of the script):

# Not working in silent mode :/
# start "" "$FILE /S" /B
# So using this workaround:
cat > "last_installer_cmd.cmd" << EOF
@ECHO OFF
ECHO Installing Kicad...
@ECHO ON
${FILE} /S
exit
EOF

start "" "last_installer_cmd.cmd" /B

Why do you add linux in the mix here?

Whenever I feel like updating, I do a:

sudo apt update
sudo apt upgrade

and this handles both KiCad, KiCad-nightly and all other programs on my Linux box.

And the only reason I have to type those lines in a terminal is because I disabled the graphical GUI update thing that auto-starts somewhere in the boot process and partially does this in the background, and then nestles itself in the taskbar if it founds updates.

because I am on windows, but I feel that linux subsystem has more flexibility.

If for some reason you want a CLI method on Linux because you want to download at a quiet time, or like me in the bad old days when I had separate quotas for peak and off-peak hours, there is usually an option to the CLI package manager that says download but don’t install. Then later on in the day you will find the packages downloaded and will only take moments to install. You can also cronjob it, but you’ll have to do this as root, also because sudo requires a tty.