tails-upgrade-frontend-wrapper 1.85 KB
Newer Older
1 2
#!/bin/sh

3 4 5 6 7 8
CMD=$(basename ${0})

. gettext.sh
TEXTDOMAIN="tails"
export TEXTDOMAIN

9 10 11
TORDATE_DIR=/var/run/tordate
TORDATE_DONE_FILE="${TORDATE_DIR}/done"
INOTIFY_TIMEOUT=60
12 13
MIN_MEMFREE=$((200 * 1024))
MIN_TOTAL_MEMFREE=$((500 * 1024))
14
RUN_AS_USER=tails-upgrade-frontend
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

### 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
30
   local errormsg
31 32 33 34 35 36 37 38 39

   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))

Tails developers's avatar
Tails developers committed
40
   errormsg="`gettext \"<b>Not enough memory available to check for upgrades.</b>
41

Tails developers's avatar
Tails developers committed
42
Make sure this system satisfies the requirements for running Tails.
43
See file:///usr/share/doc/tails/website/doc/about/requirements.en.html.
Tails developers's avatar
Tails developers committed
44

Tails developers's avatar
Tails developers committed
45
Try to restart Tails to check for upgrades again.
Tails developers's avatar
Tails developers committed
46 47 48

Or do a manual upgrade.
See https://tails.boum.org/doc/first_steps/upgrade#manual\"`"
49

50
   if [ "$memfree" -lt "$MIN_MEMFREE" ] ; then
51 52
      echo "Only $memfree MemFree, while $MIN_MEMFREE is needed." >&2
      error "$errormsg"
53 54 55
   fi

   if [ "$total_memfree" -lt "$MIN_TOTAL_MEMFREE" ] ; then
56 57
      echo "Only $total_memfree MemFree + Buffers + Cached, while $MIN_TOTAL_MEMFREE is needed." >&2
      error "$errormsg"
58 59 60 61
   fi
}

### Main
62

63 64
while ! sudo -n -u debian-tor /usr/local/sbin/tor-has-bootstrapped ; do
   sleep 10
65 66
done

67
sleep 30
68

69 70
check_free_memory "$MIN_MEMFREE" "$MIN_TOTAL_MEMFREE"

71
xhost +SI:localuser:"$RUN_AS_USER"
72
gksudo -u "$RUN_AS_USER" "/usr/bin/tails-upgrade-frontend $@"
73
xhost -SI:localuser:"$RUN_AS_USER"