2018-07-19 20:42:50 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -euo pipefail
|
|
|
|
|
2020-08-05 10:43:49 +01:00
|
|
|
function get_default_url {
|
|
|
|
process=$1
|
|
|
|
version=$2
|
|
|
|
echo $(wget -O - "${VERSION_SERVER_URL}/processes/${process}/${version}/url?os=linux&arch=${GOARCH}")
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_binary {
|
|
|
|
binary=$1
|
|
|
|
url=$2
|
|
|
|
wget -O - ${url} | unzip -p - > /app/${binary}
|
|
|
|
chmod u+x /app/${binary}
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ ! -f "storagenode-updater" ]]; then
|
|
|
|
echo "downloading storagenode-updater"
|
|
|
|
get_binary storagenode-updater $(get_default_url storagenode-updater minimum)
|
|
|
|
|
|
|
|
if ./storagenode-updater should-update storagenode-updater \
|
|
|
|
--binary-location /app/storagenode-updater \
|
|
|
|
--identity-dir identity \
|
|
|
|
--version.server-address=${VERSION_SERVER_URL} 2>/dev/null
|
|
|
|
then
|
|
|
|
echo "updating storagenode-updater"
|
|
|
|
get_binary storagenode-updater $(get_default_url storagenode-updater suggested)
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f "storagenode" ]]; then
|
|
|
|
echo "downloading storagenode"
|
|
|
|
|
|
|
|
if ./storagenode-updater should-update storagenode \
|
|
|
|
--identity-dir identity \
|
|
|
|
--version.server-address=${VERSION_SERVER_URL} 2>/dev/null
|
|
|
|
then
|
|
|
|
get_binary storagenode $(get_default_url storagenode suggested)
|
|
|
|
else
|
|
|
|
get_binary storagenode $(get_default_url storagenode minimum)
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-04-23 16:51:04 +01:00
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --config-dir config"
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --identity-dir identity"
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --metrics.app-suffix=-alpha"
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --metrics.interval=30m"
|
2019-08-29 16:47:43 +01:00
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --console.address=:14002"
|
2018-08-16 19:03:15 +01:00
|
|
|
|
2020-08-05 10:43:49 +01:00
|
|
|
if [[ -n "${VERSION_SERVER_URL:-}" ]]; then
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --version.server-address=${VERSION_SERVER_URL}"
|
|
|
|
fi
|
|
|
|
if [[ -n "${ADDRESS:-}" ]]; then
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --contact.external-address=${ADDRESS}"
|
|
|
|
fi
|
|
|
|
if [[ -n "${EMAIL:-}" ]]; then
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --operator.email=${EMAIL}"
|
|
|
|
fi
|
|
|
|
if [[ -n "${WALLET:-}" ]]; then
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --operator.wallet=${WALLET}"
|
|
|
|
fi
|
|
|
|
if [[ -n "${STORAGE:-}" ]]; then
|
|
|
|
RUN_PARAMS="${RUN_PARAMS:-} --storage.allocated-disk-space=${STORAGE}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${AUTO_UPDATE:-}" != "true" ]]; then
|
|
|
|
AUTO_UPDATE="false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${SETUP:-}" == "true" ]]; then
|
|
|
|
exec ./storagenode setup $RUN_PARAMS ${*}
|
|
|
|
else
|
|
|
|
# install supervisor
|
|
|
|
if ! apk list supervisor 2>/dev/null | grep "supervisor"; then
|
|
|
|
echo "installing supervisor"
|
|
|
|
mkdir -p /var/log/supervisor
|
|
|
|
# permorm installation during runtime to not use dockerfile RUN directive to support arch-independent build process
|
|
|
|
apk add --no-cache --repositories-file=/dev/null /var/lib/apk-supervisor/*.apk
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
"s#^command=/app/storagenode-updater\$#command=/app/storagenode-updater run --binary-location /app/storagenode ${RUN_PARAMS} ${*}#" \
|
|
|
|
/etc/supervisord.conf
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
"s#^command=/app/storagenode\$#command=/app/storagenode run ${RUN_PARAMS} ${*}#" \
|
|
|
|
/etc/supervisord.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec /usr/bin/supervisord -c /etc/supervisord.conf
|
|
|
|
fi
|