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

Wip/bashscript refactoring #348

Merged
merged 3 commits into from
Oct 1, 2014
Merged

Wip/bashscript refactoring #348

merged 3 commits into from
Oct 1, 2014

Conversation

muuki88
Copy link
Contributor

@muuki88 muuki88 commented Sep 11, 2014

This is a major refactoring of the bash-script-creation parts.

Main Goals

  • Reuse more bash scripts instead of copying around
  • Try to consolidate rpm and debian script handling
  • Separate archetypes and standard bash scripts

Reusable bash snippets

To reuse more bash scripts every reusable part is stored inside the linuxScriptReplacements.
The linuxScriptReplacements are scoped, so we can provide some parts only for Debian
or Rpm. One of the default debian scripts now looks like this

${{header}}
${{control-functions}}

addGroup ${{daemon_group}}
addUser ${{daemon_user}} ${{daemon_group}} "${{app_name}} daemon-user" ${{daemon_shell}}

${{chown-paths}}

The control-functions define methods for user/group creation/deletion which work
on most linux distributions.

Consolidate rpm and debian

  • For the java_server archetype the controlscripts are now name like the debian. See the scriptlets-override-rpm test for details.
  • Default bash scripts are now loaded via <package>/<name>-template, e.g. debian/postinst-template
  • DebianPlugin has now less magic (like rpm). Only the daemon_user and daemon_group will be generated. The chown commands are now generated by debianMakeChownReplacements and added to the linuxScriptReplacements in Debian

Archetype Bashscripts

Bash scripts for a specified archetype are now placed in <archetype>/<package>/<script>-template.
Non package-specified scripts are located in <archetype>/<identifier>/<script>. E.g

Script Archetype Package Path
postinst java_server debian java_server/debian/postinst-template

For the java_server archetype we have different systemloader scripts.
They get resolved like this

Script ServerLoader Package Path
start Upstart debian java_server/systemloader/upstart/start

Java Server Archetype

The scripts for the server archetype are now build up from basic templates.

  • A server loader defines a loader-functions script which provides two functions startService and stopService
  • Package specific scripts (rpm, debian) include the loader-functions with ${{loader-functions}} (just a replacement) and can use these methods like the control-script functions

Addition stuff

This won't be compatible with 0.7.x as I started to use some sbt 0.13.x features.

Tests and discussion

@jsuereth @kardapoltsev @aparkinson can you test on your systems? I have tested
everything so far on

  • CentOS 6.5 (SystemV)
  • Ubuntu 14.04 (Upstart)

@muuki88
Copy link
Contributor Author

muuki88 commented Sep 28, 2014

@kardapoltsev , I've changed the settings of requiredStartFacilities and requiredStopFacilities to Option[String].

@@ -0,0 +1,17 @@
${{header}}
${{control-functions}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely like this idea a lot, splitting the template into re-usable components....

If only we could auto-document this stuff...

@jsuereth
Copy link
Member

This LGTM. Is it ok to merge or are you doing more work on it?

@muuki88
Copy link
Contributor Author

muuki88 commented Sep 30, 2014

I'm afraid we should first merge #363 and then I rebase once again and then we can merge :)

@muuki88 muuki88 force-pushed the wip/bashscript-refactoring branch from 053fdbb to 3d63d6e Compare September 30, 2014 16:45
muuki88 added a commit that referenced this pull request Oct 1, 2014
@muuki88 muuki88 merged commit d0acaf1 into master Oct 1, 2014
@muuki88 muuki88 deleted the wip/bashscript-refactoring branch October 1, 2014 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants