improve script

This commit is contained in:
Gerome Matilla 2020-08-15 14:54:26 +08:00
parent 29e3673f87
commit 2cc40239e5

View File

@ -2,6 +2,7 @@
FF_USER_DIRECTORY="" FF_USER_DIRECTORY=""
CHROME_DIRECTORY="" CHROME_DIRECTORY=""
RELEASE_NAME=""
message() { message() {
printf "%s\n" "$*" >&2; printf "%s\n" "$*" >&2;
@ -53,6 +54,9 @@ function check_profile() {
} }
function print_args() { function print_args() {
echo "Usage:"
echo ""
echo "help - Show this message"
echo "stable - Firefox Stable Build" echo "stable - Firefox Stable Build"
echo "dev - Firefox Developer Edition" echo "dev - Firefox Developer Edition"
echo "beta - Firefox Beta" echo "beta - Firefox Beta"
@ -60,8 +64,9 @@ function print_args() {
echo "esr - Firefox Extended Support Release" echo "esr - Firefox Extended Support Release"
echo "" echo ""
echo "Example:" echo "Example:"
echo "./install stable" echo "$ ./install stable"
echo "./install dev" echo "$ ./install dev"
echo "$ curl -fsSL https://raw.githubusercontent.com/manilarome/blurredfox/script/install.sh | bash -s -- stable"
echo "" echo ""
echo "Defaults to 'stable' if empty." echo "Defaults to 'stable' if empty."
} }
@ -72,30 +77,36 @@ then
if [[ "${1}" == "dev" ]]; if [[ "${1}" == "dev" ]];
then then
RELEASE_NAME="Developer Edition"
check_profile "dev-edition-default" check_profile "dev-edition-default"
elif [[ "${1}" == "beta" ]]; elif [[ "${1}" == "beta" ]];
then then
RELEASE_NAME="Beta"
check_profile "default-beta" check_profile "default-beta"
elif [[ "${1}" == "nightly" ]]; elif [[ "${1}" == "nightly" ]];
then then
RELEASE_NAME="Nightly"
check_profile "default-nightly" check_profile "default-nightly"
elif [[ "${1}" == "stable" ]]; elif [[ "${1}" == "stable" ]];
then then
RELEASE_NAME="Stable"
check_profile "default-release" check_profile "default-release"
elif [[ "${1}" == "esr" ]]; elif [[ "${1}" == "esr" ]];
then then
RELEASE_NAME="ESR"
check_profile "default-esr" check_profile "default-esr"
elif [[ "${1}" == "help" ]]; elif [[ "${1}" == "help" ]];
then then
print_args print_args
exit exit
else else
echo -ne "Invalid!\n\n" echo -ne "Invalid parameter!\n"
print_args print_args
exit exit
fi fi
else else
# check_profile "(dev-edition|default)-(release|beta|nightly|default|esr)" # check_profile "(dev-edition|default)-(release|beta|nightly|default|esr)"
RELEASE_NAME="Stable"
check_profile "default-release" check_profile "default-release"
fi fi
@ -103,7 +114,7 @@ if [[ -n $FF_USER_DIRECTORY ]];
then then
message "[>>] Firefox user profile directory located..." message "[>>] Firefox user profile directory located..."
CHROME_DIRECTORY="$(find "$FF_USER_DIRECTORY/" -maxdepth 1 -type d -name 'chrome')" CHROME_DIRECTORY="$(find "$FF_USER_DIRECTORY/" -maxdepth 1 -type d -name 'chrome')"
if [[ -n $CHROME_DIRECTORY ]]; if [[ -n "$CHROME_DIRECTORY" ]];
then then
# Check if the chrome folder contains files # Check if the chrome folder contains files
shopt -s nullglob dotglob shopt -s nullglob dotglob
@ -130,6 +141,7 @@ then
message "[>>] Chrome directory does not exist! Creating one..." message "[>>] Chrome directory does not exist! Creating one..."
mkdir "${FF_USER_DIRECTORY}/chrome" mkdir "${FF_USER_DIRECTORY}/chrome"
# Check if backup folder exist
if [[ $? -eq 0 ]]; if [[ $? -eq 0 ]];
then then
CHROME_DIRECTORY="${FF_USER_DIRECTORY}/chrome" CHROME_DIRECTORY="${FF_USER_DIRECTORY}/chrome"
@ -142,6 +154,6 @@ then
fi fi
else else
message "[!!] No firefox user profile directory found. Make sure to run firefox atleast once! Terminating..." message "[!!] No Firefox ${RELEASE_NAME} user profile detected! Make sure to run Firefox ${RELEASE_NAME} atleast once! Terminating..."
exit 1; exit 1;
fi fi