Re: "Allow installer to run without sudo & only need it when need to install Docker"

This commit is contained in:
Socheat Sok 2025-05-29 21:55:50 +07:00
parent 6f3514199a
commit c997b8625f
No known key found for this signature in database
GPG key ID: 8967527396F3D1B5

View file

@ -58,9 +58,11 @@ func main() {
reader := bufio.NewReader(os.Stdin)
// check if the user is root
if os.Geteuid() != 0 {
fmt.Println("This script must be run as root")
os.Exit(1)
if !isDockerInstalled() {
if os.Geteuid() != 0 {
fmt.Println("Docker is not installed. Please install Docker manually or run this installer as root.")
os.Exit(1)
}
}
var config Config
@ -619,4 +621,4 @@ func generateRandomSecretKey() string {
b[i] = charset[seededRand.Intn(len(charset))]
}
return string(b)
}
}