101 lines
3.1 KiB
Bash
Raw Normal View History

2016-12-19 04:36:27 +03:00
#!/bin/sh
2017-01-22 15:14:13 +03:00
# Copyright (c) 2013-2017, The PurpleI2P Project
#
# This file is part of Purple i2pd project and licensed under BSD3
#
# See full license text in LICENSE file at top of project tree
2016-12-19 04:36:27 +03:00
arch=$(uname -m)
language=$(echo $LANG | cut -c-5 | sed s/_/-/g)
2017-03-14 15:03:30 +03:00
version="45.8.0esr"
2016-12-19 04:36:27 +03:00
application="firefox"
2017-03-23 16:34:35 +03:00
ftpmirror="https://ftp.mozilla.org/pub/$application/releases/$version"
2016-12-19 04:36:27 +03:00
2017-02-26 21:49:43 +03:00
curlfind=$(which curl)
2017-02-15 20:17:48 +03:00
if [ -z $curlfind ]; then
2017-03-14 15:03:30 +03:00
echo "Can't find 'cURL' installed. That script needs it!";
2017-02-15 20:17:48 +03:00
exit 1;
fi
2016-12-19 04:36:27 +03:00
echo "This script prepearing $application $version for use with I2Pd"
file="$application-$version.tar.bz2"
2017-03-23 16:34:35 +03:00
filepath="linux-$arch/$language/$file"
2016-12-19 04:36:27 +03:00
echo "Downloading $application..."
2017-03-23 16:34:35 +03:00
curl -L -f -# -O $ftpmirror/$filepath
2016-12-19 04:36:27 +03:00
if [ $? -ne 0 ]; then # Not found error, trying to cut language variable
2017-02-26 21:49:43 +03:00
echo "[TRY 2] I'll try download Firefox with shortener language code";
2016-12-19 04:36:27 +03:00
language=$(echo $language | cut -c-2)
# re-create variable with cutted lang
2017-03-23 16:34:35 +03:00
filepath="linux-$arch/$language/$file"
curl -L -f -# -O $ftpmirror/$filepath
if [ $? -ne 0 ]; then # Not found error, trying to download english version
2017-03-14 15:03:30 +03:00
echo "[TRY 3] I'll try download Firefox with English language code";
language="en_US"
# re-create lang variable
2017-03-23 16:34:35 +03:00
filepath="linux-$arch/$language/$file"
curl -L -f -# -O $ftpmirror/$filepath
if [ $? -ne 0 ]; then # After that i can say only that user haven't internet connection
echo "[Error] Can't download file. Check your internet connectivity."
exit 1;
fi
fi
2017-02-26 21:49:43 +03:00
fi
2017-03-23 16:34:35 +03:00
2016-12-19 04:36:27 +03:00
if [ ! -f $file ]; then
2017-03-23 16:34:35 +03:00
echo "[Error] Can't find downloaded file. Is it really exists?"
exit 1;
fi
echo "Downloading checksum file and checking SHA512 checksum"
curl -L -f -# -O $ftpmirror/SHA512SUMS
recv_sum=$(grep "$filepath" SHA512SUMS | cut -c-128)
file_sum=$(sha512sum $file | cut -c-128)
if [ $recv_sum != $file_sum ]; then
echo "[Error] File checksum failed!"
2016-12-19 04:36:27 +03:00
exit 1;
2017-03-23 16:34:35 +03:00
else
echo "Checksum correct."
rm SHA512SUMS
2016-12-19 04:36:27 +03:00
fi
2017-02-26 21:49:43 +03:00
2016-12-19 04:36:27 +03:00
echo "Extracting archive, please wait..."
tar xfj $file
rm $file
2017-02-07 16:32:31 +03:00
mv $application ../app
mkdir ../data
2016-12-19 04:36:27 +03:00
# Deleting some not needed files
2017-02-07 16:32:31 +03:00
rm ../app/crashreporter*
rm ../app/removed-files
rm ../app/run-mozilla.sh
rm ../app/update*
rm ../app/browser/blocklist.xml
rm -r ../app/dictionaries
# And edit some places
2017-02-07 16:32:31 +03:00
sed -i 's/Enabled=1/Enabled=0/g' ../app/application.ini
sed -i 's/ServerURL=.*/ServerURL=-/' ../app/application.ini
sed -i 's/Enabled=1/Enabled=0/g' ../app/webapprt/webapprt.ini
sed -i 's/ServerURL=.*/ServerURL=-/' ../app/webapprt/webapprt.ini
# Done!
2016-12-19 04:36:27 +03:00
echo "Downloading NoScript extension..."
2017-02-07 16:32:31 +03:00
curl -L -f -# -O https://addons.mozilla.org/firefox/downloads/latest/noscript/addon-722-latest.xpi
mv addon-722-latest.xpi ../app/browser/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi
2016-12-19 04:36:27 +03:00
echo "Adding standart configs..."
2017-02-07 16:32:31 +03:00
cp configs/* ../data/
2016-12-19 04:36:27 +03:00
2017-02-07 16:32:31 +03:00
echo '#!/bin/sh' > "../${application}-portable"
echo 'dir=${0%/*}' >> "../${application}-portable"
echo 'if [ "$dir" = "$0" ]; then' >> "../${application}-portable"
echo ' dir="."' >> "../${application}-portable"
echo 'fi' >> "../${application}-portable"
echo 'cd "$dir/app"' >> "../${application}-portable"
echo './firefox -profile ../data -no-remote' >> "../${application}-portable"
2016-12-19 04:36:27 +03:00
2017-02-07 16:32:31 +03:00
chmod +x "../$application-portable"
2016-12-19 04:36:27 +03:00
echo ... finished