secushare-box/config/config.go

71 lines
1.7 KiB
Go
Raw Normal View History

/*
Copyright © 2019 Devan Carpenter <mail@dvn.me>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// configuration is handled by this package
package config
import (
"fmt"
"os"
"github.com/mitchellh/go-homedir"
// "gopkg.in/ini.v1"
)
var userHome, err = homedir.Dir()
var ConfigPath string = fmt.Sprintf("%s/.secushare/boxen/", userHome)
var LogsPath string = fmt.Sprintf("%slogs/", ConfigPath)
var SshPath string = fmt.Sprintf("%sssh/", ConfigPath)
func MakeConfigDirs() {
makeConfigDir()
makeLogsDir()
makeSshDir()
}
func makeConfigDir() {
if _, err := os.Stat(ConfigPath); os.IsNotExist(err) {
os.MkdirAll(ConfigPath, 0700)
}
}
func makeLogsDir() {
if _, err := os.Stat(LogsPath); os.IsNotExist(err) {
os.MkdirAll(LogsPath, 0700)
}
}
func makeSshDir() {
if _, err := os.Stat(SshPath); os.IsNotExist(err) {
os.MkdirAll(SshPath, 0700)
}
}
var SshPrivKeyFile = fmt.Sprintf("%sid_rsa_boxen", SshPath)
var SshPubKeyFile = fmt.Sprintf("%sid_rsa_boxen.pub", SshPath)
/*
func main() {
cfg, err := ini.Load("my.ini")
if err != nil {
fmt.Printf("Fail to read file: %v", err)
os.exit(1)
}
}
*/