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

Automation script? #107

Closed
ghost opened this issue Feb 22, 2018 · 25 comments · Fixed by #124
Closed

Automation script? #107

ghost opened this issue Feb 22, 2018 · 25 comments · Fixed by #124

Comments

@ghost
Copy link

ghost commented Feb 22, 2018

I was looking at the README, and thought about making a shell script to autmate the installation of apaxy. We could have it automatically adjust the .htaccess files depending on the path and all that fancy stuff. I’m not talking about Docker, but an independent script to install it to a given path. Is this something we would make use of?

@oupala
Copy link
Owner

oupala commented Feb 22, 2018

This is a good idea. but

But it should not be mandatory, as not everyone is able to understand and run a shell script, it might not work on windows or mac, it might have problem with permissions.

So I think we also have to keep it as simple and stupid as possible, and to make it usable without a shell script.

But a shell script could be welcome to automate things for those who want.

I'm already automated this by ansible, but an independent shell script would be more appropriate here.

@ghost
Copy link
Author

ghost commented Feb 22, 2018

Yeah, I totally understand all of your concerns. Of course, we wouldn't make it mandatory. We could still keep all the instructions in the README the same, just maybe add a section at the top called "Quick Start" or something with instructions on how to run the script (as root, probably).

As for Mac and Windows users, I'm sure there would be problems, and I can't see maintaining three different scripts for three different platforms. Now that I think about it, a script maybe isn't the best Idea.

Would you want me to prototype a Linux script, or should I just close the issue? @oupala

@oupala
Copy link
Owner

oupala commented Feb 22, 2018

Running a script as root is a serious security concern for me. I see too much people running bash scripts downloaded from GitHub without understanding what is does, and even not knowing what sudo means.

And how would the script determine the path to replace? Would it be a parameter (the script is then juste an automated find and replace) or would you try to determine the path from apache configuration and current path to apaxy ? It could be tricky to get all different cases in mind.

Best security is - in my opinion - to explain as much as possible in the README.

@ghost
Copy link
Author

ghost commented Feb 22, 2018

Yes, it would take a parameter, and find an replace. I could also write a warning in the README about running scripts from the internet. I completely agree with you on the security factor of it.

@oupala
Copy link
Owner

oupala commented Feb 22, 2018

In my opinion, the hardest thing is not to find and replace, the hardest thing is to know what is the replacement string.

In other words, an automated script would automatize the simple task, and do nothing for the complex one.

It would be better to put efforts on the README, with examples.

@ghost
Copy link
Author

ghost commented Feb 22, 2018

It would just replace the {FOLDERNAME} string, right? That's what the convention is, from what I can see.

@nodiscc
Copy link

nodiscc commented Feb 22, 2018

Running a script as root

is not necessary in that case, it can be run as an unprivilegied user, then the resulting files placed/uploaded to the desired apache dir. Or it could be run as www-data. I think the script should just

  • let the user define some variables (page title, footer content, FOLDERNAME, additional IndexOptions...)
  • automate replacement and renaming (i linked to some ideas here
  • create a ready-to-upload/move directory

@oupala
Copy link
Owner

oupala commented Feb 22, 2018

Ok, let's try.

But the hard thing is:

  • let the user define some variables (page title, footer content, FOLDERNAME, additional IndexOptions...)

And this step is not automated (and can hardly be).

@ghost
Copy link
Author

ghost commented Feb 22, 2018

@nodiscc I actually never thought of that. That's definitely the safer option.

@ghost
Copy link
Author

ghost commented Feb 23, 2018

Ok, so do you want me to try this, or do one of you guys want to take a swing at it? @oupala @nodiscc

@oupala
Copy link
Owner

oupala commented Feb 23, 2018

I won't have time to dig into this script. Feel free to do that of you want to.

I can post my ansible script, as it could help you to see what steps to implement in your script.

@UksusoFF
Copy link
Contributor

UksusoFF commented Mar 1, 2018

Maybe it's will be easy make some configuration generator based on js/html?

Such as: https://shorturls.redwerks.org/?url=https%3A%2F%2Fru.wikipedia.org%2F

@ghost
Copy link
Author

ghost commented May 10, 2018

@oupala @nodiscc
Ok, I have a prototype script here. Let me know if this is what you imagined or not.

@nodiscc
Copy link

nodiscc commented Jul 8, 2018

@jordanbancino It looks ok, though you should quote all variables, and also check if specified target directories/files exist and are writeable. I also ran it through shellcheck:

$ shellcheck apaxy-configure.sh 

In apaxy-configure.sh line 8:
    source $CONFIG
    ^-- SC1090: Can't follow non-constant source. Use a directive to specify location.


In apaxy-configure.sh line 22:
    if [ $USE_LOCAL_FONT = 1 ]; then
         ^-- SC2086: Double quote to prevent globbing and word splitting.


In apaxy-configure.sh line 36:
    if [ -f $HTACCESS ]; then
            ^-- SC2086: Double quote to prevent globbing and word splitting.


In apaxy-configure.sh line 54:
sed 's/'"$HTACCESS_VAR"'/'"$INSTALL_DIRECTORY"'/g' <$HTACCESS >$HTACCESS_OUT
                                                    ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                               ^-- SC2086: Double quote to prevent globbing and word splitting.


In apaxy-configure.sh line 58:
    mv $THEME_HTACCESS_IN $THEME_HTACCESS_OUT
       ^-- SC2086: Double quote to prevent globbing and word splitting.
                          ^-- SC2086: Double quote to prevent globbing and word splitting.


In apaxy-configure.sh line 62:
if [ $USE_LOCAL_FONT = 1 ]; then
     ^-- SC2086: Double quote to prevent globbing and word splitting.

You could also automate changing FOLDERNAME if needed like I did here

@ghost
Copy link
Author

ghost commented Jul 10, 2018

@nodiscc Ok, I'll fix up those things, then when I have time I can actually test it. I wrote that entire script on the GitHub Gist web interface on my iPad one day, and it had been a while since I'd written a shell script, so when I have time, I can test it as well. There's a couple lines that I don't even know if they'll work.

EDIT: both the config and shell script have been fixed to be shellcheck compliant, I've uploaded the new versions here, as I'm no longer using GitHub for my work. Please note that I have not yet tested these scripts, but I will as soon as I have time.

@oupala
Copy link
Owner

oupala commented Jul 17, 2018

Tell us when you have tested your script.

We'll have to commit it for you into the repo.

@oupala
Copy link
Owner

oupala commented Nov 23, 2018

Have you had time to test the script?

@ghost
Copy link
Author

ghost commented Nov 26, 2018

Oh man, I totally forgot about that. I can throw Apaxy on my server real quick and give it a go. I've been pretty busy lately, so I can't promise I'll have time to finish it, but I'll take a look, and at the very least fix up anything that I currently have implemented that doesn't work.

Whether I get it working or not, I'll report back shortly.

@oupala
Copy link
Owner

oupala commented Nov 26, 2018

@jordanbancino I was also very busy lately. But I'm about to start a new test session for all pull requests so it might be time for you and me to finalize all our pending job in order to clean up pending items (issues, pull requests) of this repo.

@ghost
Copy link
Author

ghost commented Nov 30, 2018

The script is almost complete, I just have to figure out a few more things, then it should all be good. I'll also add instructions to the README.

@oupala
Copy link
Owner

oupala commented Nov 30, 2018

Could you please open a pull request now so we can start to test and discuss the script?

@ghost
Copy link
Author

ghost commented Dec 3, 2018

Yes, I can. But first, I'd like to clarify exactly what you would like me to do with the font. I'm working on #59 right now. @nodiscc said:

What I would do, in order of preference:

  • Don't include the font, browsers with an available local Open Sans font will display it fine, and those who don't will provide a reasonable fallback.
  • Provide a bundled Open Sans as part of tagged releases (https://help.github.com/articles/creating-releases/ point 7. - attach a zip file with Apaxy + fonts)
  • Download the font as part of the install script (Automation script? #107)
  • Include the font in the git repository (large files)
  • Include the font in the git repository

So are you looking to use this script to download and configure the font properly?

If you don't want me mess with the font in the script at all, then I think we have plenty of good options here, but I just want to know what your vision for handling fonts via a script would be. I personally think it would be easier to just go with one of the other options, like not including a font at all.

@ghost
Copy link
Author

ghost commented Dec 3, 2018

Also, if I were to download the font within the script, we would need to do something like this in our style code, correct? Because when I curled the current font URL, all it does is link to a bunch of different formats to ensure that all browsers are supported. So if we were to do local fonts, then I would need to figure out how to fetch all the different formats.

@oupala
Copy link
Owner

oupala commented Dec 3, 2018

I think we should aim at simplicity and do not bother with fonts at all.

Default fonts from browsers should be good enough.

It seems that I have the same opinion as you, so let's go for it!

@ghost
Copy link
Author

ghost commented Dec 3, 2018

Awesome, I'll remove my current font code, and we should be good to go. If I have time, I will commit the script and open a pull request by the end of the day.

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.

3 participants