Commit 960a1727 authored by Kamil Trzciński's avatar Kamil Trzciński

Allow to run as system service on OSX and improve notice message for sudo

parent 3f08cd16
Pipeline #1010333 passed with stage
......@@ -10,6 +10,7 @@ v 1.1.0
- Add `git` to gitlab-runner:alpine
- Add support for `CapAdd`, `CapDrop` and `Devices` by docker executor
- Add support for passing the name of artifacts archive (`artifacts:name`)
- Add support for running runner as system service on OSX
- Refactor: The build trace is now implemented by `network` module
- Refactor: Remove CGO dependency on Windows
- Fix: Create alternative aliases for docker services (uses `-`)
......
......@@ -3,10 +3,10 @@
package commands
import (
"github.com/Sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
"os"
"path/filepath"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
)
func getDefaultConfigDirectory() string {
......@@ -19,19 +19,3 @@ func getDefaultConfigDirectory() string {
}
panic("Cannot get default config file location")
}
func userModeWarning(withRun bool) {
if os.Getuid() == 0 {
logrus.Infoln("Running in system-mode.")
logrus.Infoln("")
} else {
logrus.Warningln("Running in user-mode.")
if withRun {
logrus.Warningln("The user-mode requires you to manually start builds processing:")
logrus.Warningln("$ gitlab-runner run")
}
logrus.Warningln("Use sudo for system-mode:")
logrus.Warningln("$ sudo gitlab-runner...")
logrus.Infoln("")
}
}
......@@ -11,6 +11,3 @@ func getDefaultConfigDirectory() string {
panic("Cannot get default config file location")
}
}
func userModeWarning(withRun bool) {
}
package commands
import (
"os"
"runtime"
"github.com/Sirupsen/logrus"
)
func userModeWarning(withRun bool) {
// everything is supported on windows
if runtime.GOOS == "windows" {
return
}
// We support services on Linux, Windows and Darwin
noServices :=
runtime.GOOS != "linux" &&
runtime.GOOS != "darwin"
// We don't support services installed as an User on Linux
noUserService :=
runtime.GOOS == "linux"
if os.Getuid() == 0 {
logrus.Infoln("Running in system-mode.")
} else {
logrus.Warningln("Running in user-mode.")
}
if withRun {
if noServices {
logrus.Warningln("You need to manually start builds processing:")
logrus.Warningln("$ gitlab-runner run")
} else if noUserService {
logrus.Warningln("The user-mode requires you to manually start builds processing:")
logrus.Warningln("$ gitlab-runner run")
}
}
if os.Getuid() != 0 && noUserService {
logrus.Warningln("Use sudo for system-mode:")
logrus.Warningln("$ sudo gitlab-runner...")
}
logrus.Infoln("")
}
......@@ -167,7 +167,11 @@ func (b *BashShell) GenerateScript(info common.ShellScriptInfo) (*common.ShellSc
// su
if info.User != "" {
script.Command = "su"
script.Arguments = []string{"--shell", "/bin/sh", info.User}
if runtime.GOOS == "linux" {
// Support to specify shell when used on Linux
script.Arguments = []string{"--shell", "/bin/sh"}
}
script.Arguments = append(script.Arguments, info.User)
} else {
script.Command = "sh"
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment