Skip to content
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

Automatic installation to profile folder #91

Closed
Shourai opened this issue Mar 12, 2018 · 17 comments · Fixed by #129
Closed

Automatic installation to profile folder #91

Shourai opened this issue Mar 12, 2018 · 17 comments · Fixed by #129

Comments

@Shourai
Copy link
Contributor

Shourai commented Mar 12, 2018

I have to think about issue #84 a little longer to come up with some suggestions which might be good to implement.

On the other hand, I was thinking about automatically "installing" ShadowFox under the default profile.
This would work if the user want their *.default profile to be the one where ShadowFox is applied to
which I think will be the case for most people, and those who don't will have more knowledge about
profiles and can adjust accordingly.

Something I use for example would be

profileID=$(ls "$HOME/Library/Application Support/Firefox/Profiles" | grep default | sed -n 's/\([[:alnum:]]*\).*/\1/p')
profile="$HOME/Library/Application Support/Firefox/Profiles/$profileID.default"

Now you have the path and profileID of the default profile, with which we can
adjust the mac updater script so the user only needs to download the updater script
and everything will be installed automatically.
Everything would only have to be prepended by $profile.
What do you think?

I would assume it's similar on linux, don't know about windows.

p.s.: I am learning a tonne on the regex department because of this project, thanks! haha

@overdodactyl
Copy link
Owner

Really like the idea!

That would really help simplify things.

Maybe we could expand it a bit by doing the following?

  • Check if the script is already inside a profile

    • If yes, continue to install in the current one (this would ensure no "breakage" occurs for people who already have the script installed in a profile other than default and might be nice for people using multiple profiles)

    • if not:

      • Do a quick check in ~/Library/Application Support/Firefox/Profiles/

        • if there's only one profile, automatically install in that one

        • if there's multiple, print out the profile names and ask the user which to install in

And I really appreciate all the regex help you've provided :)

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

Those additional checks are a good idea!
That should make updating/installing easier and smoother.

Also I think it would be a good idea to merge the linux/max updater scripts, they are quite similar.
For mac/linux specific commands one could use an if statement to check it's uname

if [ "$(uname)" == "Darwin" ]; then
    # Do something under Mac OS X platform        
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
    # Do something under GNU/Linux platform
fi

I don't know if there is a way to append flags to a command, i.e.
use -e flag in echo -e if on linux.

@overdodactyl
Copy link
Owner

Great idea!! I didn't think of doing that. The sed commands are (I think?) the only difference that I had to deal with

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

I did a few simple tests using gsed and it appears that sed under Darwin is a subset
of gsed and the commands that work under Darwin should work on Linux (not vice-versa!).
This is because gsed has some extensions, see
https://www.gnu.org/software/sed/manual/sed.html#BRE-syntax which mentions e.g.
\+ As *, but matches one or more. It is a GNU extension.

Also the newline 'problem' is easily bypassed by just echoing a blank line e.g.

echo "line 1"
echo ""

instead of echo "line 1\n"

@overdodactyl
Copy link
Owner

overdodactyl commented Mar 12, 2018

The only one that I was getting stuck on was replacing "in place"

sed -i '' replaces in place on mac, but on linux it tries to replace in a file named ''

I don't currently have a linux distro to test on, so I've only been able to go off what I found online and some error codes someone provided me when I originally had the two scripts together in #62.

Thanks for the link! I'll give it a look

Edit: could call on the echo command as well

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

I'll also have a look into sed -i and report back if I found something interesting, haven't used that before.
I don't have a linux distro around either, so can't test it on that unfortunately.

@overdodactyl
Copy link
Owner

overdodactyl commented Mar 12, 2018

Looks like this might be the way to go for sed -i:

https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux

Would just have to clean up the .bak files

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

Just stumbled upon on the same solution!

sed -i.bak '/--start-indicator-for-updater-scripts: black;/,/--end-indicator-for-updater-scripts: black;/{//!d;}' userContent.css

creates userContent.css.bak
and at the end of the script just remove those files explicitly and not use a wildcard.

rm userContent.css.bak

Well that at least makes it compatible across both platforms!

@overdodactyl
Copy link
Owner

According to one of the comments there it has to be sed -i.bak -e 's/foo/bar/' filename for at least macOS Sierra and higher.

Would have to find out if that also works on LInux and pre-Sierra OSs.

Might be best to just use the if statements you provided earlier and be safe if we can't test across all the OSs and versions

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

Currently I am on high sierra and I don't need the -e flag.

sed -i.bak '/--start-indicator-for-updater-scripts: black;/,/--end-indicator-for-updater-scripts: black;/{//!d;}' userContent.css

works fine for me (also works under gsed, not sure how well this translates to linux).

I agree that the safest would be using the if statements.

@overdodactyl
Copy link
Owner

Interesting it works on high sierra - wonder it that user was just wrong or something was just changed from sierra to hs. Either way, let's go with the if statements I think. Better safe than sorry and I don't think that'll be a huge problem.

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

Tomorrow I will be around another computer running Sierra, I'll test it there and report back.

@overdodactyl
Copy link
Owner

overdodactyl commented Mar 12, 2018

Thanks! On a random note:

I've been considering creating a Slack or Keybase group (or something similar) for this project...might be a nice place for convos like this/sharing code snippets without blasting people's email who are "watching" the repo.

Do you use anything of the sort/would that be of interest to ya? Or prefer sticking GitHub?

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

I am slightly familiar with Slack so I could join your channel.
Good way to get more familiar with slack.
Otherwise Discord or IRC would also work for me :)

@overdodactyl
Copy link
Owner

I've used Slack a little (not a ton), but haven't used IRC or Discord. I'm guessing the latter two are a bit more popular though...seem to hear them pop up pretty often.

Any preference/suggestion?

@Shourai
Copy link
Contributor Author

Shourai commented Mar 12, 2018

We could use Slack for starters and see how well that goes, could always decide to migrate if it doesn't work out.

@overdodactyl
Copy link
Owner

Here's the invitation link for anyone who would like. I'll get it added to README.md file shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants