add check_root function
This commit is contained in:
parent
bbeadd28fe
commit
3eca4b2baa
1 changed files with 32 additions and 0 deletions
|
@ -0,0 +1,32 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
var mongo_base_path = "/opt/my-mongo"
|
||||||
|
var replicaset_name = "techtransthai-db"
|
||||||
|
var network_name = "mongonet"
|
||||||
|
var number_of_containers int = 5
|
||||||
|
var max_mem_alloc_percent int = 95
|
||||||
|
var mongo_initdb_root_username = "sasha"
|
||||||
|
var mongo_initdb_root_password = "12345"
|
||||||
|
|
||||||
|
func check_root() {
|
||||||
|
currentUser, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error getting current user:", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if currentUser.Uid != "0" {
|
||||||
|
fmt.Println("You must be root to run this script")
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
fmt.Println("UID:", currentUser.Uid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
check_root()
|
||||||
|
}
|
Loading…
Reference in a new issue