-
Notifications
You must be signed in to change notification settings - Fork 5
/
update-check.sh
27 lines (20 loc) · 994 Bytes
/
update-check.sh
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
#!/bin/bash
# You need to install JQ: https://github.com/stedolan/jq/
# Get a Personal Access Token for yourself from https://gitlab.com/profile/personal_access_tokens
gitlab_private_token="xxxxxxxxxxxxxxxxxxxxx"
tezos_dir="/home/tezos/tezos/"
# Don't change anything from here down
current=$(curl -s --header "PRIVATE-TOKEN: $gitlab_private_token" "https://gitlab.com/api/v4/projects/tezos%2Ftezos/repository/commits/?ref_name=mainnet" | jq -r '.[0].id')
myinstall=$(cd $tezos_dir && git rev-parse HEAD)
if [ -z "$current" ]; then
# API call failed, retrieve API version from the last successful call
current=$(<lastcurrentversion.txt)
else
# API call worked, store hash for future use
echo $current > lastcurrentversion.txt
fi
if [ "$current" == "$myinstall" ]; then
echo "Your tezos install is up to date or the API didn't respond."
else
echo "Your tezos install is behind: repo commit hash is $current, your install is $myinstall."
fi