diff --git a/is_master.go b/is_master.go index ffb4b35..3bdafad 100644 --- a/is_master.go +++ b/is_master.go @@ -16,6 +16,7 @@ var ( IP = flag.String("ip", "", "") FILE = flag.String("file", "", "") COMMAND = flag.String("command", "", "command to execute") + NOT = flag.Bool("not", false, "execute the command if the ip or the file isn't present") ) // Critical print a message and exit with code 2 @@ -86,15 +87,23 @@ func ipExist(ip string) bool { } func main() { - var isMaster bool + var execute bool if *FILE != "" { - isMaster = fileExist(*FILE) + execute = fileExist(*FILE) } else { - isMaster = ipExist(*IP) + execute = ipExist(*IP) } - if isMaster == false { + if *NOT { + if execute { + execute = false + } else { + execute = true + } + } + + if execute { Ok("I have nothing to do, i going to sleep") }