Commit cf7eb6fb authored by Tails developers's avatar Tails developers

Don't run the update frontend unless there's enough memory available.

The actual limit was determined experimentally, and may have to change a bit in
the future.
parent 85474ff3
#!/bin/sh
CMD=$(basename ${0})
. gettext.sh
TEXTDOMAIN="tails"
export TEXTDOMAIN
TORDATE_DIR=/var/run/tordate
TORDATE_DONE_FILE="${TORDATE_DIR}/done"
INOTIFY_TIMEOUT=60
MIN_MEMFREE=$((200 * 1024))
MIN_TOTAL_MEMFREE=$((500 * 1024))
### Functions
error () {
local cli_text="${CMD}: `gettext \"error:\"` ${@}"
local dialog_text="<b><big>`gettext \"Error\"`</big></b>
${@}"
echo "${cli_text}" >&2
zenity --error --title "" --text "${dialog_text}"
exit 1
}
check_free_memory () {
local min_memfree min_total_memfree memfree buffers cached total_memfree
min_memfree="$1"
min_total_memfree="$2"
memfree=$(awk '/^MemFree:/{print $2}' /proc/meminfo)
buffers=$(awk '/^Buffers:/{print $2}' /proc/meminfo)
cached=$(awk '/^Cached:/{print $2}' /proc/meminfo)
total_memfree=$(($memfree + $buffers + $cached))
if [ "$memfree" -lt "$MIN_MEMFREE" ] ; then
error "`gettext \"Only $memfree MemFree, while $MIN_MEMFREE is needed.\"`"
fi
if [ "$total_memfree" -lt "$MIN_TOTAL_MEMFREE" ] ; then
error "`gettext \"Only $total_memfree MemFree + Buffers + Cached, while $MIN_TOTAL_MEMFREE is needed.\"`"
fi
}
### Main
# wait for the $TORDATE_DIR directory to appear
while [ ! -d "$TORDATE_DIR" ]; do
......@@ -14,4 +56,6 @@ while ! [ -e "$TORDATE_DONE_FILE" ]; do
inotifywait -q -t "$INOTIFY_TIMEOUT" -e create --format %w%f "$TORDATE_DIR"
done
check_free_memory "$MIN_MEMFREE" "$MIN_TOTAL_MEMFREE"
exec /usr/bin/tails-update-frontend "$@"
......@@ -8,7 +8,8 @@ PERL_PROGS="/usr/local/bin/gpgApplet /usr/local/bin/tails-security-check \
/usr/local/bin/tails-virt-notify-user"
PYTHON_PROGS="/etc/whisperback/config.py /usr/local/bin/shutdown_helper_applet \
/usr/local/bin/tails-about /usr/local/sbin/tails-additional-software"
SHELL_PROGS="/usr/local/sbin/unsafe-browser /usr/share/tails/truecrypt-wrapper.disabled"
SHELL_PROGS="/usr/local/bin/tails-update-frontend-wrapper \
/usr/local/sbin/unsafe-browser /usr/share/tails/truecrypt-wrapper.disabled"
LANGUAGES=$(for po in po/*.po ; do rel="${po%.po}" ; echo "${rel#po/}"; done)
LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
......
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