This repository has been archived on 2021-01-21. You can view files and clone it, but cannot push or open issues or pull requests.
blurredfox-nord/install.sh

183 lines
4.7 KiB
Bash
Raw Normal View History

2020-05-20 05:34:10 +00:00
#!/usr/bin/env bash
FF_USER_DIRECTORY=""
CHROME_DIRECTORY=""
2020-08-15 06:54:26 +00:00
RELEASE_NAME=""
2020-07-08 08:11:11 +00:00
message() {
printf "%s\n" "$*" >&2;
}
2020-05-20 05:34:10 +00:00
download_bf() {
2020-07-08 08:11:11 +00:00
message "[>>] Downloading theme..."
2020-05-20 05:34:10 +00:00
2020-07-08 08:11:11 +00:00
curl -LJ0 https://github.com/manilarome/blurredfox/archive/master.tar.gz | tar -xz -C /tmp/
2020-05-20 05:34:10 +00:00
2020-08-16 04:33:22 +00:00
# Download success!
if [[ $? -eq 0 ]];
2020-07-08 08:11:11 +00:00
then
message "[>>] Copying..."
2020-05-20 05:34:10 +00:00
2020-07-08 08:11:11 +00:00
FF_THEME="/tmp/blurredfox-master/"
cp -r "${FF_THEME}"* "${CHROME_DIRECTORY}"
2020-05-20 05:34:10 +00:00
# Backup user.js instead of overwriting it
2020-08-21 22:58:29 +00:00
if [ -e "${CHROME_DIRECTORY}/../user.js" ]
then
2020-08-21 22:58:29 +00:00
message "[>>] Existing user.js detected! Creating backup to user-prefs-backup/..."
user_pref_backup_dir="${CHROME_DIRECTORY}/../user-prefs-backup"
2020-08-21 23:08:23 +00:00
if [[ ! -d "${user_pref_backup_dir}" ]];
2020-08-21 22:58:29 +00:00
then
message "[>>] user-prefs-backup/ folder does not exist! Creating..."
2020-08-21 23:08:23 +00:00
mkdir "${user_pref_backup_dir}"
2020-08-21 22:58:29 +00:00
fi
2020-08-21 23:08:23 +00:00
mv --backup=t "${CHROME_DIRECTORY}/../user.js" "${user_pref_backup_dir}"
fi
2020-08-15 07:41:05 +00:00
# Move user.js to the main profile directory
2020-08-21 22:58:29 +00:00
mv "${CHROME_DIRECTORY}/user.js" "${CHROME_DIRECTORY}/../"
2020-08-15 07:41:05 +00:00
2020-07-08 08:11:11 +00:00
if [[ $? -eq 0 ]];
then
rm -rf "/tmp/blurredfox-master"
else
message " [!!] There was a problem while copying the files. Terminating..."
2020-08-16 04:33:22 +00:00
exit
2020-07-08 08:11:11 +00:00
fi
else
2020-08-16 04:33:22 +00:00
# Download failed
2020-08-21 22:58:29 +00:00
message " [!!] There was a problem while downloading the theme. Terminating..."
2020-08-16 04:33:22 +00:00
exit
2020-07-08 08:11:11 +00:00
fi
echo "░█▀▄░█░░░█░█░█▀▄░█▀▄░█▀▀░█▀▄"
echo "░█▀▄░█░░░█░█░█▀▄░█▀▄░█▀▀░█░█"
echo "░▀▀░░▀▀▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀░"
echo "┏━┛┏━┃┃ ┃"
echo "┏━┛┃ ┃ ┛ "
echo "┛ ━━┛┛ ┛"
message "blurredfox successfully installed! Enjoy!"
2020-05-20 05:34:10 +00:00
}
function check_profile() {
2020-08-16 04:33:22 +00:00
# Check OSTYPE
case "$OSTYPE" in
msys*)
# Untested on WSL
# FF_USER_DIRECTORY="$(find "${HOME}AppData\Roaming\Mozilla\firefox" -maxdepth 1 -type d -regextype egrep -regex '.*[a-zA-Z0-9]+.'${1})"
2020-08-16 04:33:22 +00:00
;;
*)
FF_USER_DIRECTORY="$(find "${HOME}/.mozilla/firefox/" -maxdepth 1 -type d -regextype egrep -regex '.*[a-zA-Z0-9]+.'${1})"
;;
esac
}
2020-08-16 04:33:22 +00:00
function print_help() {
2020-08-15 06:54:26 +00:00
echo "Usage:"
echo ""
echo "help - Show this message"
echo "stable - Firefox Stable Build"
echo "dev - Firefox Developer Edition"
echo "beta - Firefox Beta"
echo "nightly - Firefox Nightly"
echo "esr - Firefox Extended Support Release"
echo ""
echo "Example:"
2020-08-15 06:54:26 +00:00
echo "$ ./install stable"
echo "$ ./install dev"
echo "$ curl -fsSL https://raw.githubusercontent.com/manilarome/blurredfox/script/install.sh | bash -s -- stable"
echo ""
echo "Defaults to 'stable' if empty."
}
# Check args
2020-08-16 04:33:22 +00:00
if [[ ! -z "${@}" ]] && [[ ! -z "${1}" ]];
then
if [[ "${1}" == "dev" ]];
then
2020-08-15 06:54:26 +00:00
RELEASE_NAME="Developer Edition"
check_profile "dev-edition-default"
elif [[ "${1}" == "beta" ]];
then
2020-08-15 06:54:26 +00:00
RELEASE_NAME="Beta"
check_profile "default-beta"
elif [[ "${1}" == "nightly" ]];
then
2020-08-15 06:54:26 +00:00
RELEASE_NAME="Nightly"
check_profile "default-nightly"
elif [[ "${1}" == "stable" ]];
then
2020-08-15 06:54:26 +00:00
RELEASE_NAME="Stable"
check_profile "default-release"
elif [[ "${1}" == "esr" ]];
then
2020-08-15 06:54:26 +00:00
RELEASE_NAME="ESR"
check_profile "default-esr"
elif [[ "${1}" == "help" ]];
then
2020-08-16 04:33:22 +00:00
print_help
exit
else
2020-08-15 06:54:26 +00:00
echo -ne "Invalid parameter!\n"
2020-08-16 04:33:22 +00:00
print_help
exit
fi
else
# check_profile "(dev-edition|default)-(release|beta|nightly|default|esr)"
2020-08-15 06:54:26 +00:00
RELEASE_NAME="Stable"
check_profile "default-release"
fi
2020-08-16 04:33:22 +00:00
if [[ -n "$FF_USER_DIRECTORY" ]];
2020-05-20 05:34:10 +00:00
then
2020-07-08 08:11:11 +00:00
message "[>>] Firefox user profile directory located..."
CHROME_DIRECTORY="$(find "$FF_USER_DIRECTORY/" -maxdepth 1 -type d -name 'chrome')"
2020-08-15 06:54:26 +00:00
if [[ -n "$CHROME_DIRECTORY" ]];
2020-07-08 08:11:11 +00:00
then
2020-08-16 04:33:22 +00:00
# Check if the chrome folder is not empty
shopt -s nullglob dotglob
2020-07-08 08:11:11 +00:00
content="${CHROME_DIRECTORY}/"
# If there's a current theme, make a backup
if [ ${#content[@]} -gt 0 ];
then
2020-08-21 23:08:23 +00:00
message "[>>] Existing chrome folder detected! Creating a backup to chrome-backup/..."
backup_dir="${CHROME_DIRECTORY}-backup"
# Create backup folder
if [[ ! -d "${backup_dir}" ]];
then
2020-08-21 23:08:23 +00:00
message "[>>] chrome-backup/ folder does not exist! Creating..."
mkdir "${backup_dir}"
fi
2020-08-21 23:08:23 +00:00
mv --backup=t "${CHROME_DIRECTORY}" "${backup_dir}"
2020-07-08 08:11:11 +00:00
mkdir "${CHROME_DIRECTORY}"
fi
2020-08-16 04:33:22 +00:00
# Download theme
2020-07-08 08:11:11 +00:00
download_bf
else
2020-08-16 04:33:22 +00:00
message "[>>] Chrome folder does not exist! Creating one..."
2020-07-08 08:11:11 +00:00
mkdir "${FF_USER_DIRECTORY}/chrome"
2020-08-15 06:54:26 +00:00
# Check if backup folder exist
2020-07-08 08:11:11 +00:00
if [[ $? -eq 0 ]];
then
CHROME_DIRECTORY="${FF_USER_DIRECTORY}/chrome"
2020-08-16 04:33:22 +00:00
# Download theme
2020-07-08 08:11:11 +00:00
download_bf
else
2020-08-21 23:08:23 +00:00
message "[!!] There was a problem while creating the directory. Terminating..."
2020-07-08 08:11:11 +00:00
exit 1;
fi
fi
2020-05-20 05:34:10 +00:00
else
2020-08-15 06:54:26 +00:00
message "[!!] No Firefox ${RELEASE_NAME} user profile detected! Make sure to run Firefox ${RELEASE_NAME} atleast once! Terminating..."
2020-07-08 08:11:11 +00:00
exit 1;
2020-05-20 05:34:10 +00:00
fi