To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 1f3ad74a authored by Axel Beckert's avatar Axel Beckert

Try to use shasum locally if sha256sum is not found locally

Needed for macOS, suggested by Max Schlapfer.
parent 7eca4cd1
......@@ -54,7 +54,8 @@ Requirements
* `sh` (a bourne compatible shell like `ash` or `dash` suffices, `bash` is not needed.)
* `egrep`
* `test` (as `[`)
* `sha256sum`
* `sha256sum` (GNU Coreutils) or `shasum` (Perl, used on macOS)
* `which` to figure out which of the tools above to use.
* `awk` (`mawk` suffices, no `gawk` needed.)
* `scp` (needs to understand options `-q` and `-p`) and `ssh` (needs
to understand options `-a` and `-x`) — OpenSSH is known to work.
......@@ -64,7 +65,7 @@ Requirements
`ioc-local-check.pl` uses only these standard POSIX commands and Perl:
* Perl 5, no modules required.
* `sha256sum`
* `sha256sum` (always)
* `getent`
* `awk` (`mawk` suffices, no `gawk` needed.)
* `hostname`
......
......@@ -17,7 +17,18 @@ if [ -z "$hosts" ]; then
hosts=localhost
fi
hash=$(sha256sum ioc-local-check.pl | awk '{print $1}')
# Generate the local checksum
localhashsumtool=''
if which sha256sum > /dev/null; then
localhashsumtool=sha256sum
elif which shasum; then
localhashsumtool="shasum -a256"
else
echo "Neither sha256sum nor shasum locally found" 1>&2;
exit 255
fi
hash=$($localhashsumtool ioc-local-check.pl | awk '{print $1}')
for host in $hosts; do
scp -qp ioc-local-check.pl root@$host:/tmp/
ssh -ax root@$host '[ $(sha256sum /tmp/ioc-local-check.pl | awk '\''{print $1}'\'') = '"$hash"' ] && perl /tmp/ioc-local-check.pl '"$params"'; if [ $(sha256sum /tmp/ioc-local-check.pl | awk '\''{print $1}'\'') != '"$hash"' ]; then echo "$(hostname): WARNING: /tmp/ioc-local-check.pl modified, not deleting"; else rm /tmp/ioc-local-check.pl; fi'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment