-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathscript-for-using-latest-version.sh
More file actions
executable file
·37 lines (28 loc) · 1.04 KB
/
script-for-using-latest-version.sh
File metadata and controls
executable file
·37 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -o errexit
#set -o pipefail
set -o nounset
IFS=$'\n\t'
# ------------------------------------------------------------------
# based on the script Kenichi Nagai https://github.com/keni-n/
# https://github.com/joergi/MagPiDownloader/blob/main/linux_mac/magpi-issue-downloader-latest.sh
# ------------------------------------------------------------------
# VERSION=0.1
# you don't need to run this script
# this is running automatically on Github each date to update the latest issues
TARGET_URL="https://hackspace.raspberrypi.com/"
BASEDIR=$(dirname "$0")
#printf -v page_url "$TARGET_URL/issues"
page_url=$(printf '%s\n' "$TARGET_URL/issues")
latest_issue=$(curl -sf "$page_url" | grep "Get PDF" | head -n 1 | sed 's/^.*issues\///' | sed 's/\/pdf.*$//')
echo "Latest Issue is " "$latest_issue"
file="issues.txt";
if bash hackspace-downloader.sh -f "$latest_issue" -l "$latest_issue"; then
echo "Download was successful."
echo "$latest_issue" > "$file"
else
echo "Download failed."
rm issues/HS_"$latest_issue".pdf
fi
exit 0
exit 0