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

main.go 2.5 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //go:build mage
  2. package main
  3. import (
  4. "errors"
  5. "fmt"
  6. "os"
  7. "path/filepath"
  8. "gitlink.org.cn/cloudream/common/magefiles"
  9. //mage:import
  10. _ "gitlink.org.cn/cloudream/common/magefiles/targets"
  11. cp "github.com/otiai10/copy"
  12. )
  13. const (
  14. BuildDir = "./build"
  15. )
  16. func All() error {
  17. if err := Bin(); err != nil {
  18. return err
  19. }
  20. if err := Scripts(); err != nil {
  21. return err
  22. }
  23. if err := Confs(); err != nil {
  24. return err
  25. }
  26. return nil
  27. }
  28. func Bin() error {
  29. if err := Agent(); err != nil {
  30. return err
  31. }
  32. if err := Client(); err != nil {
  33. return err
  34. }
  35. if err := Coordinator(); err != nil {
  36. return err
  37. }
  38. if err := Scanner(); err != nil {
  39. return err
  40. }
  41. return nil
  42. }
  43. func Scripts() error {
  44. scriptsDir := "./common/assets/scripts"
  45. info, err := os.Stat(scriptsDir)
  46. if errors.Is(err, os.ErrNotExist) {
  47. fmt.Printf("no scripts.\n")
  48. return nil
  49. }
  50. if !info.IsDir() {
  51. return fmt.Errorf("scripts is not a directory")
  52. }
  53. fullDirPath, err := filepath.Abs(filepath.Join(BuildDir, "scripts"))
  54. if err != nil {
  55. return err
  56. }
  57. fmt.Printf("copying scripts to %s\n", fullDirPath)
  58. return cp.Copy(scriptsDir, fullDirPath)
  59. }
  60. func Confs() error {
  61. confDir := "./common/assets/confs"
  62. info, err := os.Stat(confDir)
  63. if errors.Is(err, os.ErrNotExist) {
  64. fmt.Printf("no confs.\n")
  65. return nil
  66. }
  67. if !info.IsDir() {
  68. return fmt.Errorf("confs is not a directory")
  69. }
  70. fullDirPath, err := filepath.Abs(filepath.Join(BuildDir, "confs"))
  71. if err != nil {
  72. return err
  73. }
  74. fmt.Printf("copying confs to %s\n", fullDirPath)
  75. return cp.Copy(confDir, fullDirPath)
  76. }
  77. func Agent() error {
  78. return magefiles.Build(magefiles.BuildArgs{
  79. OutputName: "agent",
  80. OutputDir: "agent",
  81. AssetsDir: "assets",
  82. EntryFile: "agent/main.go",
  83. })
  84. }
  85. func Client() error {
  86. return magefiles.Build(magefiles.BuildArgs{
  87. OutputName: "client",
  88. OutputDir: "client",
  89. AssetsDir: "assets",
  90. EntryFile: "client/main.go",
  91. })
  92. }
  93. func Client2() error {
  94. return magefiles.Build(magefiles.BuildArgs{
  95. OutputName: "client2",
  96. OutputDir: "client2",
  97. AssetsDir: "assets",
  98. EntryFile: "client2/main.go",
  99. })
  100. }
  101. func Coordinator() error {
  102. return magefiles.Build(magefiles.BuildArgs{
  103. OutputName: "coordinator",
  104. OutputDir: "coordinator",
  105. AssetsDir: "assets",
  106. EntryFile: "coordinator/main.go",
  107. })
  108. }
  109. func Scanner() error {
  110. return magefiles.Build(magefiles.BuildArgs{
  111. OutputName: "scanner",
  112. OutputDir: "scanner",
  113. AssetsDir: "assets",
  114. EntryFile: "scanner/main.go",
  115. })
  116. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。