X-Git-Url: https://iankelling.org/git/?p=buildscripts;a=blobdiff_plain;f=tor-browser;h=f9a6e45bbf2c7faac604fc72810ce0e6d6d9a1a5;hp=9b3212cbc7330e7081bb9319f37894e3a5d38e25;hb=HEAD;hpb=6d5364acaf732814110b7ab98ef1d266276f64ee diff --git a/tor-browser b/tor-browser index 9b3212c..923c4e3 100755 --- a/tor-browser +++ b/tor-browser @@ -1,5 +1,12 @@ #!/bin/bash -# Copyright (C) 2016 Ian Kelling +# I, Ian Kelling, follow the GNU license recommendations at +# https://www.gnu.org/licenses/license-recommendations.en.html. They +# recommend that small programs, < 300 lines, be licensed under the +# Apache License 2.0. This file contains or is part of one or more small +# programs. If a small program grows beyond 300 lines, I plan to switch +# its license to GPL. + +# Copyright 2024 Ian Kelling # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,6 +20,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi @@ -39,42 +47,51 @@ vers=($(printf "%s\n" "$c" | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' cd /a/opt -ver=${vers[0]} dl() { - f=tor-browser-linux64-${ver}_en-US.tar.xz + f=tor-browser-linux64-${ver}_ALL.tar.xz if [[ -e $f ]]; then timestamp=$(stat -c %Y $f) else timestamp=0 fi + ret=0 echo wget -nv -N https://www.torproject.org/dist/torbrowser/$ver/$f wget -nv -N https://www.torproject.org/dist/torbrowser/$ver/$f || ret=$? } -dl -# 8 is return code for 404. for a new release, they might not have released to linux yet. -if [[ $ret == 8 ]]; then - ver=${vers[1]} + +# some releases are for specific non-gnu oses +for ((i=0; i<${#vers[@]}; i++)); do + ver=${vers[i]} dl -fi + # 8 is return code for 404. + if [[ $ret != 8 ]]; then + break + fi +done new_timestamp=$(stat -c %Y $f) -if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser_en-US/Browser/start-tor-browser ]]; then +if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser/Browser/start-tor-browser ]]; then # not already installed - rm -rf tor-browser_en-US + rm -rf tor-browser tar Jxf $f + + ## begin handlers customization - dest=/a/opt/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/handlers.json - orig=/p/c/tor-handlers-orig.json - src=/p/c/tor-handlers.json - if diff -q $src $dest; then - echo "Error: handlers file changed. adjust based on upstream" - exit 1 - fi - cp $src $dest + ## the default file doesn't exist anymore. i customized it to open magnet links, + ## it might work with removing the default stuff and keeping the magnet link part, + ## but I'd have to test and I don't care that much. + # dest=/a/opt/tor-browser/Browser/TorBrowser/Data/Browser/profile.default/handlers.json + # orig=/p/c/tor-handlers-orig.json + # src=/p/c/tor-handlers.json + # if ! diff -q $src $dest &>/dev/null; then + # echo "Error: handlers file changed. adjust based on upstream" + # exit 1 + # fi + # cp $src $dest ## end handlers customization - cp /p/c/tor-user.js /a/opt/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/user.js + cp /p/c/tor-user.js /a/opt/tor-browser/Browser/TorBrowser/Data/Browser/profile.default/user.js fi