Skip to content

Commit

Permalink
use /sbin/initctl to detect upstart
Browse files Browse the repository at this point in the history
  • Loading branch information
SteelPhase authored and kardianos committed Aug 21, 2018
1 parent 18492ae commit 3bfa85e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions service_upstart_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func isUpstart() bool {
if _, err := os.Stat("/sbin/upstart-udev-bridge"); err == nil {
return true
}
if _, err := os.Stat("/sbin/init"); err == nil {
if out, err := exec.Command("/sbin/init", "--version").Output(); err == nil {
if strings.Contains(string(out), "init (upstart") {
if _, err := os.Stat("/sbin/initctl"); err == nil {
if out, err := exec.Command("/sbin/initctl", "--version").Output(); err == nil {
if strings.Contains(string(out), "initctl (upstart") {
return true
}
}
Expand Down Expand Up @@ -96,12 +96,12 @@ func (s *upstart) hasSetUIDStanza() bool {
}

func (s *upstart) getUpstartVersion() []int {
out, err := exec.Command("/sbin/init", "--version").Output()
out, err := exec.Command("/sbin/initctl", "--version").Output()
if err != nil {
return nil
}

re := regexp.MustCompile(`init \(upstart (\d+.\d+.\d+)\)`)
re := regexp.MustCompile(`initctl \(upstart (\d+.\d+.\d+)\)`)
matches := re.FindStringSubmatch(string(out))
if len(matches) != 2 {
return nil
Expand Down

0 comments on commit 3bfa85e

Please sign in to comment.