abra/pkg/server/server.go
decentral1se 7b7e1bfa97
refactor!: server add/rm has better UI/UX
Less confusing logging messages, clear "is created" / "already exists"
output. Move the majority of logging to debug output to not confuse the
situation. Some code cleanups also in there.
2024-06-25 09:48:53 +02:00

28 lines
512 B
Go

package server
import (
"os"
"path"
"coopcloud.tech/abra/pkg/config"
"github.com/sirupsen/logrus"
)
// CreateServerDir creates a server directory under ~/.abra.
func CreateServerDir(serverName string) error {
serverPath := path.Join(config.ABRA_DIR, "servers", serverName)
if err := os.Mkdir(serverPath, 0764); err != nil {
if !os.IsExist(err) {
return err
}
logrus.Debugf("%s already exists", serverPath)
return nil
}
logrus.Debugf("successfully created %s", serverPath)
return nil
}