add mu, fix tor
[buildscripts] / tor-browser
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -eE -o pipefail
17 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
18
19
20 # stable version is shown on:
21 # https://dist.torproject.org/torbrowser/
22
23 ver=$(curl -s https://dist.torproject.org/torbrowser/ \
24 | sed -rn 's/.*href="([0-9]+\.[0-9]+[.0-9]*)\/.*/\1/p' \
25 | sort -Vr | head -n 1)
26
27
28 # by default it has perms for just 1 non-root user, which is ok for now.
29
30 cd /a/opt
31
32 f=tor-browser-linux64-${ver}_en-US.tar.xz
33 timestamp=$(stat -c %Y $f) ||:
34 wget -N https://www.torproject.org/dist/torbrowser/$ver/$f
35 new_timestamp=$(stat -c %Y $f) ||:
36 if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser_en-US/Browser/start-tor-browser ]]; then
37 # not already installed
38 rm -rf tor-browser_en-US
39 ex $f
40 fi
41
42 for x in tor-*.tar.xz; do
43 # cleanup old tarballs
44 [[ -e $x ]] || break
45 [[ $x != $f ]] || continue
46 command rm -f $x
47 done
48 s lnf /a/opt/tor-browser_en-US/Browser/start-tor-browser /usr/local/bin