From 88c36ad5dcc3ea9c0761358e0e2ece1477e2c538 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sun, 27 Mar 2016 12:55:31 +0800 Subject: [PATCH] support android key and ios cert path flag. Signed-off-by: Bo-Yi Wu --- main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/main.go b/main.go index bc702aa..52f8a1a 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,8 @@ import ( func main() { version := flag.Bool("v", false, "gopush version") confPath := flag.String("c", "", "yaml configuration file path for gopush") + certificateKeyPath := flag.String("i", "", "iOS certificate key file path for gopush") + apiKey := flag.String("k", "", "Android api key configuration for gopush") port := flag.String("p", "", "port number for gopush") flag.Parse() @@ -37,6 +39,17 @@ func main() { } if gopush.PushConf.Ios.Enabled { + + if *certificateKeyPath != "" { + gopush.PushConf.Ios.PemKeyPath = *certificateKeyPath + } + + if gopush.PushConf.Ios.PemKeyPath == "" { + log.Println("iOS certificate path not define") + + return + } + gopush.CertificatePemIos, err = certificate.FromPemFile(gopush.PushConf.Ios.PemKeyPath, "") if err != nil { @@ -52,6 +65,20 @@ func main() { } } + // check andorid api key exist + if gopush.PushConf.Android.Enabled { + + if *apiKey != "" { + gopush.PushConf.Android.ApiKey = *apiKey + } + + if gopush.PushConf.Android.ApiKey == "" { + log.Println("Android API Key not define") + + return + } + } + // overwrite server port if *port != "" { gopush.PushConf.Core.Port = *port