1
0
Fork 0
mirror of https://github.com/shouptech/tempgopher.git synced 2026-02-03 08:39:43 +00:00

Check if config file exists

This commit is contained in:
Emma 2018-10-20 19:49:58 -06:00
parent bdba7afbfd
commit f541654a86
2 changed files with 7 additions and 1 deletions

6
cli.go
View file

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

View file

@ -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