-
-
Notifications
You must be signed in to change notification settings - Fork 40
Install script: Error handling, shellcheck, shellfmt, various minor fixes, prefer rsync over cp. #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vertana
wants to merge
2
commits into
EliverLara:master
Choose a base branch
from
Vertana:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Install script: Error handling, shellcheck, shellfmt, various minor fixes, prefer rsync over cp. #35
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,84 @@ | ||
| #!/bin/bash | ||
|
|
||
| THEMEDIRECTORY=$(cd `dirname $0` && cd .. && pwd) | ||
| FIREFOXFOLDER=~/.mozilla/firefox/ | ||
| THEMEDIRECTORY=$(cd "$(dirname "$0")" && cd ../ && pwd) | ||
| FIREFOXFOLDER="$HOME/.mozilla/firefox" | ||
| PROFILENAME="" | ||
| GNOMISHEXTRAS=false | ||
|
|
||
| # Get options. | ||
| while getopts 'f:p:g' flag; do | ||
| case "${flag}" in | ||
| f) FIREFOXFOLDER="${OPTARG}" ;; | ||
| p) PROFILENAME="${OPTARG}" ;; | ||
| g) GNOMISHEXTRAS=true ;; | ||
| case "${flag}" in | ||
| f) FIREFOXFOLDER="${OPTARG}" ;; | ||
| p) PROFILENAME="${OPTARG}" ;; | ||
| g) GNOMISHEXTRAS=true ;; | ||
| *) echo "Incorrect flag used" && exit 1 ;; | ||
| esac | ||
| done | ||
|
|
||
| # Define profile folder path. | ||
| if test -z "$PROFILENAME" | ||
| then | ||
| PROFILEFOLDER="$FIREFOXFOLDER/*.default" | ||
| if test -z "$PROFILENAME"; then | ||
| pattern="$FIREFOXFOLDER/*.default*" | ||
|
|
||
| # Tried to use mapfile and read -a, but didn't get desired results. Disabling shellcheck on this one. | ||
| # shellcheck disable=SC2206 | ||
| files=($pattern) | ||
|
|
||
| if [ -d "${files[0]}" ]; then | ||
| PROFILEFOLDER="${files[0]}" | ||
| else | ||
| echo "${files[0]} detected as firefox profile, but the directory wasn't found." && exit 1 | ||
| fi | ||
| else | ||
| if [ -d "$FIREFOXFOLDER/$PROFILENAME" ]; then | ||
| PROFILEFOLDER="$FIREFOXFOLDER/$PROFILENAME" | ||
| else | ||
| echo "$FIREFOXFOLDER/$PROFILENAME was not found." && exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Enter Firefox profile folder. | ||
| cd $PROFILEFOLDER | ||
| echo "Installing theme in $PWD" | ||
| if cd "$PROFILEFOLDER"; then | ||
| echo "Installing theme in $PWD" | ||
| else | ||
| echo "We could not enter ${PROFILEFOLDER}. Exiting." && exit 1 | ||
| fi | ||
|
|
||
| # Create a chrome directory if it doesn't exist. | ||
| mkdir -p chrome | ||
| cd chrome | ||
| mkdir -p ./chrome || { | ||
| echo "We could not create ./chrome. Exiting." | ||
| exit 1 | ||
| } | ||
| cd ./chrome || { | ||
| echo "We could not enter ./chrome. Exiting." | ||
| exit 1 | ||
| } | ||
|
|
||
| # Copy theme repo inside | ||
| echo "Coping repo in $PWD" | ||
| cp -R $THEMEDIRECTORY $PWD | ||
| echo "Copying files to $PWD" | ||
|
|
||
| # If rsync is in $PATH, we should use that to avoid copying entire git repos into our theme folder | ||
| if [ -x "$(command -v rsync)" ]; then | ||
| rsync -aq --progress "$THEMEDIRECTORY" "$PWD" --exclude ".git" | ||
| else | ||
| cp -R "$THEMEDIRECTORY" "$PWD" | ||
| fi | ||
|
|
||
| # Create single-line user CSS files if non-existent or empty. | ||
| [[ -s userChrome.css ]] || echo >> userChrome.css | ||
| [[ -s userChrome.css ]] || echo >>userChrome.css | ||
|
|
||
| # Import this theme at the beginning of the CSS files. | ||
| sed -i '1s/^/@import "firefox-sweet-theme\/userChrome.css";\n/' userChrome.css | ||
|
|
||
| # If GNOMISH extras enabled, import it in customChrome.css. | ||
| if [ "$GNOMISHEXTRAS" = true ] ; then | ||
| if [ "$GNOMISHEXTRAS" = true ]; then | ||
| echo "Enabling GNOMISH extra features" | ||
| [[ -s customChrome.css ]] || echo >> firefox-sweet-theme/customChrome.css | ||
| [[ -s customChrome.css ]] || echo >>firefox-sweet-theme/customChrome.css | ||
| sed -i '1s/^/@import "theme\/hide-single-tab.css";\n/' firefox-sweet-theme/customChrome.css | ||
| sed -i '2s/^/@import "theme\/matching-autocomplete-width.css";\n/' firefox-sweet-theme/customChrome.css | ||
| fi | ||
|
|
||
| # Symlink user.js to firefox-sweet-theme one. | ||
| echo "Set configuration user.js file" | ||
| ln -s chrome/firefox-sweet-theme/configuration/user.js ../user.js | ||
| ln -sf ./chrome/firefox-sweet-theme/configuration/user.js ../user.js | ||
|
|
||
| echo "Done." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.