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

Moduliarize (use includes) script #17

Open
loftux opened this issue Mar 8, 2014 · 9 comments
Open

Moduliarize (use includes) script #17

loftux opened this issue Mar 8, 2014 · 9 comments

Comments

@loftux
Copy link
Contributor

loftux commented Mar 8, 2014

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

@housni
Copy link

housni commented Aug 15, 2016

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

@loftux
Copy link
Contributor Author

loftux commented Aug 15, 2016

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

@housni
Copy link

housni commented Aug 15, 2016

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.

@loftux
Copy link
Contributor Author

loftux commented Aug 15, 2016

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

@housni
Copy link

housni commented Aug 15, 2016

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
Copy link

housni commented Aug 15, 2016

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
Copy link

housni commented Aug 15, 2016

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

@housni
Copy link

housni commented Aug 19, 2016

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
Copy link

housni commented Aug 19, 2016

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

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

No branches or pull requests

2 participants