-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (39 loc) · 1.09 KB
/
main.go
File metadata and controls
50 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/robfig/cron"
"github.com/sanda0/linodsync/service"
)
func main() {
exePath, err := os.Executable()
if err != nil {
fmt.Println("get exe path error: ", err)
}
exedir := filepath.Dir(exePath)
configPath := flag.Bool("cc", false, "create linodsync.config.json")
servicePath := flag.Bool("cs", false, "create service file")
addTobackup := flag.Bool("add", false, "add to backup")
runBackup := flag.Bool("run", false, "run backup")
flag.Parse()
if *configPath {
service.CreateConfigJson(filepath.Join(exedir, "linodsync.config.json"))
}
if *servicePath {
fmt.Println("create service file", *servicePath)
service.CreateSystemdFile("linodsync", exedir+"/linodsync -run", "root")
}
if *addTobackup {
service.AddToBackup(filepath.Join(exedir, "backup_config.json"))
}
if *runBackup {
c := cron.New()
c.AddFunc("@daily", func() {
service.RunBackup(filepath.Join(exedir, "linodsync.config.json"), filepath.Join(exedir, "backup_config.json"), filepath.Join(exedir, "tmp"))
})
c.Start()
select {}
}
}