alfresco-ubuntu-install icon indicating copy to clipboard operation
alfresco-ubuntu-install copied to clipboard

Moduliarize (use includes) script

Open loftux opened this issue 10 years ago • 9 comments

The script is becoming large. For better maintainability try to use modules and include them. This also opens up the option to create upgrade versions of the scripts, i.e you can use the script to upgrade LibreOffice or Tomcat easily.

Possibly first create a downloader script alfinit.sh. This will download alfinstall.sh and all includes. Possible locations /opt/alfresco/scripts/alfinstall.sh /opt/alfresco/scripts/include/downloadurl.sh /opt/alfresco/scripts/include/tomcat.sh /opt/alfresco/scripts/include/alfresco.sh /opt/alfresco/scripts/include/(module).sh

The alfinit.sh script itself can then be invoked again to update the basic alfinstall.sh script and the modules. The alfinstall.sh script can then be invoked with "upgrade" as parameter.

Here is a possible modularization pattern http://stackoverflow.com/questions/78497/design-patterns-or-best-practices-for-shell-scripts

loftux avatar Mar 08 '14 07:03 loftux

I can help with this or at least clean up the script. I will submit a PR in the next few days.

housni avatar Aug 15 '16 13:08 housni

Hi, can you work from the experimental branch for this?

loftux avatar Aug 15 '16 13:08 loftux

Sure, can do. I have already done this in a script but it has been changed to suit one of our servers and I also use it in Docker, to test.

Can I maybe use getopts so we can do run the script like alfinstall.sh -s 123.456.78.90 -r 123.456.78.91 so that share is served on 123.456.78.90 and the repo is on 123.456.78.91? That way, scripts like this can be used in Docker without requiring user interaction.

housni avatar Aug 15 '16 14:08 housni

Another option could be to have an "answers.txt" file that gets pulled in: Not sure how this plays with Docker.

loftux avatar Aug 15 '16 14:08 loftux

So, if answers.txt could look something like:

export SHARE_HOSTNAME=123.456.78.90
export REPO_HOSTNAME=123.456.78.91

that would work fine with or without Docker. I can just source answers.txt into alfinstall.sh and those variables would be available to the script.

housni avatar Aug 15 '16 14:08 housni

I might actually allow the user to specify the path to answers.txt as an argument. That way, based on their environment, they can specify different configs.

housni avatar Aug 15 '16 14:08 housni

Should this work for 14.04 or 16.04? Some of the package names are different across the two versions.

housni avatar Aug 15 '16 17:08 housni

I didn't have a whole bunch of time the other day but I started on it today and got this done so far.

Our config file would look like that.

It would be used like: curl -sL https://example.org/alfinit.sh | sudo -E bash -s -- -c /path/to/config.conf -

That's pretty much how NPM and a few other tools are installed.

If you have any suggestions, let me know.

PS: It's not properly tested so I'm sure it's quite buggy.

housni avatar Aug 19 '16 22:08 housni

I also added Docker so that it can be tested in an isolated environment.

housni avatar Aug 19 '16 22:08 housni