diff --git a/.gitignore b/.gitignore index 397b4a7..faa078a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.log +*.cron diff --git a/crontabd/crontabd.exe b/crontabd/crontabd.exe index f584093..a20816c 100644 --- a/crontabd/crontabd.exe +++ b/crontabd/crontabd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:07372bec0b6132a557053598a10db61a38b6f2a53f6f6b43bb179e05195e26f5 -size 3502080 +oid sha256:53910f79fea843bd19c45539c6f7fb4e4802ce0f12cbf7c034c49081e1fce642 +size 3501056 diff --git a/crontabd/main.go b/crontabd/main.go index 2239980..335462c 100644 --- a/crontabd/main.go +++ b/crontabd/main.go @@ -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 }