Resolve .cron in cwd
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
*.log
|
||||
*.cron
|
||||
|
BIN
crontabd/crontabd.exe
(Stored with Git LFS)
BIN
crontabd/crontabd.exe
(Stored with Git LFS)
Binary file not shown.
@@ -133,17 +133,31 @@ func createJobFunc(job CronJob) func() {
|
||||
|
||||
func resolveCrontabPath() (string, error) {
|
||||
// Resolve crontab file location
|
||||
homeDir, err := os.UserHomeDir()
|
||||
// homeDir, err := os.UserHomeDir()
|
||||
// if err != nil {
|
||||
// return "", fmt.Errorf("failed to get user home directory: %v", err)
|
||||
// }
|
||||
// userName := os.Getenv("USERNAME")
|
||||
// crontabFile = filepath.Join(homeDir, "crontab", userName+".cron")
|
||||
// crontabFile, err = filepath.Abs(crontabFile)
|
||||
// if err != nil {
|
||||
// return "", fmt.Errorf("failed to get absolute path: %v", err)
|
||||
// }
|
||||
// crontabFile = filepath.Clean(crontabFile)
|
||||
|
||||
// Never mind this fucking noise
|
||||
// When running shit with nssm we have to run it with a system account
|
||||
// And the home of that one is deep within system32
|
||||
// I'm not going to poke around in system32
|
||||
// To make it run with the local account requires the password of the account
|
||||
// Even if the account has no fucking password
|
||||
// So we're just going to look for it in the cwd and call it a day
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get user home directory: %v", err)
|
||||
return "", fmt.Errorf("failed to get current working directory: %v", err)
|
||||
}
|
||||
userName := os.Getenv("USERNAME")
|
||||
crontabFile = filepath.Join(homeDir, "crontab", userName+".cron")
|
||||
crontabFile, err = filepath.Abs(crontabFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get absolute path: %v", err)
|
||||
}
|
||||
crontabFile = filepath.Clean(crontabFile)
|
||||
crontabFile = filepath.Join(cwd, "crontab.cron")
|
||||
return crontabFile, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user