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

3 4
set -u

5 6 7 8 9 10
CMD=$(basename ${0})

. gettext.sh
TEXTDOMAIN="tails"
export TEXTDOMAIN

11 12 13
TORDATE_DIR=/var/run/tordate
TORDATE_DONE_FILE="${TORDATE_DIR}/done"
INOTIFY_TIMEOUT=60
14
MIN_REAL_MEMFREE=$((300 * 1024))
15
RUN_AS_USER=tails-upgrade-frontend
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 () {
30
   local min_real_memfree memfree buffers cached real_memfree
31
   local errormsg
32

33
   min_real_memfree="$1"
34 35 36 37

   memfree=$(awk '/^MemFree:/{print $2}' /proc/meminfo)
   buffers=$(awk '/^Buffers:/{print $2}' /proc/meminfo)
   cached=$(awk '/^Cached:/{print $2}' /proc/meminfo)
38 39
   tmpfs=$(df --type=tmpfs --local --output=used --total | tail -n1)
   real_memfree=$(($memfree + $buffers + $cached - $tmpfs))
40

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

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

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

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

51 52
   if [ "$real_memfree" -lt "$MIN_REAL_MEMFREE" ] ; then
      echo "Only $real_memfree MemFree + Buffers + Cached - usage of tmpfs, while $MIN_REAL_MEMFREE is needed." >&2
53
      error "$errormsg"
54 55 56 57
   fi
}

### Main
58

59
sleep 30
60

61
check_free_memory "$MIN_REAL_MEMFREE"
62

63 64 65 66 67
# Go to a place where everyone, especially Archive::Tar::Wrapper called by
# tails-install-iuk, can chdir back after it has chdir'd elsewhere to do
# its job.
cd /

68
xhost +SI:localuser:"$RUN_AS_USER"
69
sudo -u "$RUN_AS_USER" /usr/bin/tails-upgrade-frontend $@
70
xhost -SI:localuser:"$RUN_AS_USER"