mirror of https://github.com/lukechilds/umbrel.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
854 B
26 lines
854 B
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
RELEASE=$1
|
|
UMBREL_ROOT=$2
|
|
first_run=$3
|
|
|
|
MIN_RAM=2000000
|
|
|
|
# Abort on low memory devices
|
|
memory="$(awk '/MemTotal/{printf "%d\n", $2}' /proc/meminfo)"
|
|
if ((memory<MIN_RAM)); then
|
|
if [[ "${first_run}" == "firstrun" ]]; then
|
|
cat <<EOF > "$UMBREL_ROOT"/statuses/update-status.json
|
|
{"state": "installing", "progress": 20, "description": "Checking device memory", "updateTo": "${RELEASE}"}
|
|
EOF
|
|
# Sleep for a few seconds so the user has been redirected to the update screen
|
|
sleep 10
|
|
memory_error="Sorry, this update isn't compatible with your device, it requires at least $((MIN_RAM/1000000))GB RAM."
|
|
echo "${memory_error}"
|
|
cat <<EOF > "$UMBREL_ROOT"/statuses/update-status.json
|
|
{"state": "failed", "progress": 100, "description": "${memory_error}", "updateTo": "${RELEASE}"}
|
|
EOF
|
|
fi
|
|
exit 1
|
|
fi
|
|
|