-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from sghill/configurable-install-cmd
Extract LegacyInstallCmd, Add installCmd to Daemon Definition
- Loading branch information
Showing
7 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/groovy/com/netflix/gradle/plugins/daemon/LegacyInstallCmd.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.netflix.gradle.plugins.daemon | ||
|
||
class LegacyInstallCmd { | ||
static String create(Map<String, Object> ctx) { | ||
if (ctx.isRedHat) { | ||
"/sbin/chkconfig ${ctx.daemonName} on" | ||
} else { | ||
def startRunLevels = ctx.runLevels.join(' ') | ||
def stopRunLevels = ([0, 1, 2, 3, 4, 5, 6] - ctx.runLevels).join(' ') | ||
"/usr/sbin/update-rc.d ${ctx.daemonName} start ${ctx.startSequence} ${startRunLevels} . stop ${ctx.stopSequence} ${stopRunLevels} ." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/groovy/com/netflix/gradle/plugins/daemon/LegacyInstallCmdSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.netflix.gradle.plugins.daemon | ||
|
||
import spock.lang.Specification | ||
|
||
class LegacyInstallCmdSpec extends Specification { | ||
def 'should call chkconfig if redhat'() { | ||
when: | ||
String actual = LegacyInstallCmd.create(isRedHat: true, daemonName: 'ABC') | ||
|
||
then: | ||
actual == "/sbin/chkconfig ABC on" | ||
} | ||
|
||
def 'should call update-rc.d if not redhat'() { | ||
when: | ||
String actual = LegacyInstallCmd.create(isRedHat: false, daemonName: 'ABC', runLevels: [3, 4, 5], startSequence: 20, stopSequence: 21) | ||
|
||
then: | ||
actual == "/usr/sbin/update-rc.d ABC start 20 3 4 5 . stop 21 0 1 2 6 ." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters