You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

  1. /*
  2. Copyright © 2019 Devan Carpenter <mail@dvn.me>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. // configuration is handled by this package
  15. package config
  16. import (
  17. "fmt"
  18. "os"
  19. "github.com/mitchellh/go-homedir"
  20. // "gopkg.in/ini.v1"
  21. )
  22. var userHome, err = homedir.Dir()
  23. var ConfigPath string = fmt.Sprintf("%s/.secushare/boxen/", userHome)
  24. var LogsPath string = fmt.Sprintf("%slogs/", ConfigPath)
  25. var SshPath string = fmt.Sprintf("%sssh/", ConfigPath)
  26. func MakeConfigDirs() {
  27. makeConfigDir()
  28. makeLogsDir()
  29. makeSshDir()
  30. }
  31. func makeConfigDir() {
  32. if _, err := os.Stat(ConfigPath); os.IsNotExist(err) {
  33. os.MkdirAll(ConfigPath, 0700)
  34. }
  35. }
  36. func makeLogsDir() {
  37. if _, err := os.Stat(LogsPath); os.IsNotExist(err) {
  38. os.MkdirAll(LogsPath, 0700)
  39. }
  40. }
  41. func makeSshDir() {
  42. if _, err := os.Stat(SshPath); os.IsNotExist(err) {
  43. os.MkdirAll(SshPath, 0700)
  44. }
  45. }
  46. var SshPrivKeyFile = fmt.Sprintf("%sid_rsa_boxen", SshPath)
  47. var SshPubKeyFile = fmt.Sprintf("%sid_rsa_boxen.pub", SshPath)
  48. /*
  49. func main() {
  50. cfg, err := ini.Load("my.ini")
  51. if err != nil {
  52. fmt.Printf("Fail to read file: %v", err)
  53. os.exit(1)
  54. }
  55. }
  56. */