2020-05-20 05:34:10 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-08-14 12:42:25 +00:00
|
|
|
FF_USER_DIRECTORY=""
|
|
|
|
CHROME_DIRECTORY=""
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME=""
|
2020-08-14 12:42:25 +00:00
|
|
|
|
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
|
|
|
|
2020-08-21 21:40:06 +00:00
|
|
|
# Backup user.js instead of overwriting it
|
2020-08-21 22:58:29 +00:00
|
|
|
if [ -e "${CHROME_DIRECTORY}/../user.js" ]
|
2020-08-21 21:40:06 +00:00
|
|
|
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}"
|
2020-08-21 21:40:06 +00:00
|
|
|
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
|
2020-08-14 12:42:25 +00:00
|
|
|
echo "░█▀▄░█░░░█░█░█▀▄░█▀▄░█▀▀░█▀▄"
|
|
|
|
echo "░█▀▄░█░░░█░█░█▀▄░█▀▄░█▀▀░█░█"
|
|
|
|
echo "░▀▀░░▀▀▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀░"
|
|
|
|
echo "┏━┛┏━┃┃ ┃"
|
|
|
|
echo "┏━┛┃ ┃ ┛ "
|
|
|
|
echo "┛ ━━┛┛ ┛"
|
2020-08-15 07:35:58 +00:00
|
|
|
message "blurredfox successfully installed! Enjoy!"
|
2020-05-20 05:34:10 +00:00
|
|
|
}
|
|
|
|
|
2020-08-14 12:42:25 +00:00
|
|
|
function check_profile() {
|
2020-08-16 04:33:22 +00:00
|
|
|
# Check OSTYPE
|
|
|
|
case "$OSTYPE" in
|
|
|
|
msys*)
|
2020-08-16 11:35:02 +00:00
|
|
|
# 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})"
|
|
|
|
;;
|
2020-08-16 04:20:00 +00:00
|
|
|
esac
|
2020-08-14 12:42:25 +00:00
|
|
|
}
|
|
|
|
|
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"
|
2020-08-14 12:42:25 +00:00
|
|
|
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"
|
2020-08-14 12:42:25 +00:00
|
|
|
echo ""
|
|
|
|
echo "Defaults to 'stable' if empty."
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check args
|
2020-08-16 04:33:22 +00:00
|
|
|
if [[ ! -z "${@}" ]] && [[ ! -z "${1}" ]];
|
2020-08-14 12:42:25 +00:00
|
|
|
then
|
|
|
|
|
|
|
|
if [[ "${1}" == "dev" ]];
|
|
|
|
then
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME="Developer Edition"
|
2020-08-14 12:42:25 +00:00
|
|
|
check_profile "dev-edition-default"
|
|
|
|
elif [[ "${1}" == "beta" ]];
|
|
|
|
then
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME="Beta"
|
2020-08-14 12:42:25 +00:00
|
|
|
check_profile "default-beta"
|
|
|
|
elif [[ "${1}" == "nightly" ]];
|
|
|
|
then
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME="Nightly"
|
2020-08-14 12:42:25 +00:00
|
|
|
check_profile "default-nightly"
|
|
|
|
elif [[ "${1}" == "stable" ]];
|
|
|
|
then
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME="Stable"
|
2020-08-14 12:42:25 +00:00
|
|
|
check_profile "default-release"
|
|
|
|
elif [[ "${1}" == "esr" ]];
|
|
|
|
then
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME="ESR"
|
2020-08-14 12:42:25 +00:00
|
|
|
check_profile "default-esr"
|
|
|
|
elif [[ "${1}" == "help" ]];
|
|
|
|
then
|
2020-08-16 04:33:22 +00:00
|
|
|
print_help
|
2020-08-14 12:42:25 +00:00
|
|
|
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
|
2020-08-14 12:42:25 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# check_profile "(dev-edition|default)-(release|beta|nightly|default|esr)"
|
2020-08-15 06:54:26 +00:00
|
|
|
RELEASE_NAME="Stable"
|
2020-08-14 12:42:25 +00:00
|
|
|
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..."
|
2020-08-14 12:42:25 +00:00
|
|
|
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
|
2020-09-12 09:28:13 +00:00
|
|
|
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/..."
|
2020-08-14 12:42:25 +00:00
|
|
|
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..."
|
2020-08-14 12:42:25 +00:00
|
|
|
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-09-12 09:28:13 +00:00
|
|
|
|
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
|