oupala / apaxy

a simple, customisable theme for your apache directory listing
https://oupala.github.io/apaxy/
GNU General Public License v3.0
1.86k stars 256 forks source link

Automation script? #107

Closed ghost closed 5 years ago

ghost commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

nodiscc commented 6 years ago

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

oupala commented 6 years ago

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 commented 6 years ago

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

ghost commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

nodiscc commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

Tell us when you have tested your script.

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

oupala commented 5 years ago

Have you had time to test the script?

ghost commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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

ghost commented 5 years ago

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 (#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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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.