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.Infof("%s already exists", serverPath)
		return nil
	}

	logrus.Infof("successfully created %s", serverPath)

	return nil
}