add check_root function

This commit is contained in:
Late Night Defender 2024-05-13 14:55:22 +07:00
parent bbeadd28fe
commit 3eca4b2baa

View file

@ -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()
}