tails-upgrade-frontend-wrapper 1.79 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
MIN_REAL_MEMFREE=$((300 * 1024))
13
RUN_AS_USER=tails-upgrade-frontend
14 15 16 17 18 19 20 21 22 23 24 25 26 27

### 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 () {
28
   local min_real_memfree memfree buffers cached real_memfree
29
   local errormsg
30

31
   min_real_memfree="$1"
32 33 34 35

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

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

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

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

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

49 50
   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
51
      error "$errormsg"
52 53 54 55
   fi
}

### Main
56

57
sleep 30
58

59
check_free_memory "$MIN_REAL_MEMFREE"
60

61 62 63 64 65
# 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 /

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