forked from TheCase/IPMIView.app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
63 lines (55 loc) · 2.25 KB
/
script.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -
DOWNLOAD_URL="https://www.supermicro.com/wdl/utility/IPMIView/Linux/"
LOCAL_DOWNLOAD_LOCATION="./SM_download"
if which wget >/dev/null; then
echo "Downloading latest version of IPMIView from [${DOWNLOAD_URL}]..."
wget \
--timestamping \
--recursive \
--level=1 \
-q \
--show-progress \
--directory-prefix="${LOCAL_DOWNLOAD_LOCATION}/" \
--no-parent \
--no-directories \
--reject index.html,index.html.tmp,robots.txt,robots.txt.tmp \
"${DOWNLOAD_URL}"
# Check SHA-256
EXPECTED_SHA256=$(\grep -A3 "tar.gz" "${LOCAL_DOWNLOAD_LOCATION}/CheckSum.txt" | grep SHA-256 | cut -d':' -f2 | tr -d "[:space:]" | tr '[:upper:]' '[:lower:]')
ACTUAL_SHA256=$(shasum -a 256 "${LOCAL_DOWNLOAD_LOCATION}"/IPMIView*.tar* | cut -d' ' -f1 | tr -d "[:space:]" | tr '[:upper:]' '[:lower:]')
if ! diff <(echo "${EXPECTED_SHA256}") <(echo "${ACTUAL_SHA256}"); then
echo "SHA-256 is not as expected; download corrupted."
echo "Expected: [${EXPECTED_SHA256}]"
echo "Actual: [${ACTUAL_SHA256}]"
echo "Exiting."
exit 1
fi
else
echo "WARNING: 'wget' CLI not found."
echo
echo "Please visit ${DOWNLOAD_URL} to download the latest version of IPMIView and copy the archive into $(pwd)/${LOCAL_DOWNLOAD_LOCATION}/"
echo
# shellcheck disable=SC2034,SC2162
echo "Press [Enter] to continue" && read answer
fi
echo "Extracting contents of downloaded IPMIView archive..."
if [[ -d Contents/Resources/IPMIView ]]; then
rm -rf Contents/Resources/IPMIView
fi
mkdir -p Contents/Resources/IPMIView/Contents/Home/bin
tar -zxf "${LOCAL_DOWNLOAD_LOCATION}"/IPMIView*.tar* --strip=1 -C ./Contents/Resources/IPMIView/. ||
{ echo "Something went wrong, check download of IPMIView archive" && exit 1; }
echo "Linking 'java' and 'jre'..."
ln -s /usr/bin/java Contents/Resources/IPMIView/Contents/Home/bin/java
rm -rf Contents/Resources/IPMIView/jre/*
pushd Contents/Resources/IPMIView/jre/ >/dev/null &&
ln -s ../Contents . &&
popd >/dev/null || exit
echo "Copying IPMIView.app over to ~/Applications directory..."
pushd .. >/dev/null &&
rsync -ar --exclude=.git --exclude=Contents/Resources/IPMIView/jre IPMIView.app ~/Applications &&
popd >/dev/null || exit
echo "Completed."
echo
echo "You can now open ~/Applications/IPMIView.app"