mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
Refactor
This commit is contained in:
parent
cb40353563
commit
f24fd0e3ae
@ -35,27 +35,33 @@ function downloadUpdate {
|
|||||||
|
|
||||||
# Auto update the agent
|
# Auto update the agent
|
||||||
|
|
||||||
if curl -s -f -k -m 5 -o "${TMP}" https://raw.githubusercontent.com/kroese/virtual-dsm/master/agent/agent.sh; then
|
if ! curl -s -f -k -m 5 -o "${TMP}" https://raw.githubusercontent.com/kroese/virtual-dsm/master/agent/agent.sh; then
|
||||||
if [ -f "${TMP}" ]; then
|
echo "$HEADER: update error: $?" && return
|
||||||
line=$(head -1 "${TMP}")
|
|
||||||
if [ "$line" == "#!/usr/bin/env bash" ]; then
|
|
||||||
SCRIPT=$(readlink -f ${BASH_SOURCE[0]})
|
|
||||||
if ! cmp --silent -- "${TMP}" "${SCRIPT}"; then
|
|
||||||
mv -f "${TMP}" "${SCRIPT}"
|
|
||||||
chmod +x "${SCRIPT}"
|
|
||||||
echo "$HEADER: succesfully installed update."
|
|
||||||
else
|
|
||||||
echo "$HEADER: Update not needed."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "$HEADER: update error, invalid header: $line"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "$HEADER: update error, file not found.."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "$HEADER: update error, curl error: $?"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "${TMP}" ]; then
|
||||||
|
echo "$HEADER: update error, file not found.." && return
|
||||||
|
fi
|
||||||
|
|
||||||
|
line=$(head -1 "${TMP}")
|
||||||
|
|
||||||
|
if [ "$line" != "#!/usr/bin/env bash" ]; then
|
||||||
|
echo "$HEADER: update error, invalid header: $line" && return
|
||||||
|
fi
|
||||||
|
|
||||||
|
SCRIPT=$(readlink -f ${BASH_SOURCE[0]})
|
||||||
|
|
||||||
|
if ! cmp --silent -- "${TMP}" "${SCRIPT}"; then
|
||||||
|
|
||||||
|
mv -f "${TMP}" "${SCRIPT}"
|
||||||
|
chmod +x "${SCRIPT}"
|
||||||
|
|
||||||
|
echo "$HEADER: succesfully installed update."
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "$HEADER: Update not needed."
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function installPackages {
|
function installPackages {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user