From f541654a867ffcec1c69020bf97043c75145ad07 Mon Sep 17 00:00:00 2001 From: Mike Shoup Date: Sat, 20 Oct 2018 19:49:58 -0600 Subject: [PATCH] Check if config file exists --- cli.go | 6 ++++++ install.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cli.go b/cli.go index 24b7393..850fd02 100644 --- a/cli.go +++ b/cli.go @@ -237,6 +237,12 @@ func PromptForConfiguration() Config { // ConfigCLI prompts the user for configuration and writes to a config file func ConfigCLI(path string) { + // Check if path exists + if _, err := os.Stat(path); !os.IsNotExist(err) { + fmt.Printf("File exists, or some other error trying to open file %s\n", path) + os.Exit(1) + } + config := PromptForConfiguration() SaveConfig(path, config) diff --git a/install.sh b/install.sh index 767fb4b..3bde91e 100644 --- a/install.sh +++ b/install.sh @@ -16,7 +16,7 @@ sudo chmod +x $INSTALLBIN sudo chown -R $INSTALLUSER: $INSTALLDIR # Generate a configuration file -sudo -u $INSTALLUSER $INSTALLBIN -c $CONFIGFILE config +sudo -u $INSTALLUSER $INSTALLBIN -c $CONFIGFILE config || true # Create unit file sudo sh -c "cat > /etc/systemd/system/tempgopher.service" << EOM