Resolve .cron in cwd

This commit is contained in:
2025-06-27 18:26:27 +02:00
parent f31103d1d8
commit 26ec0e38b2
3 changed files with 26 additions and 11 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
*.log *.log
*.cron

BIN
crontabd/crontabd.exe (Stored with Git LFS)

Binary file not shown.

View File

@@ -133,17 +133,31 @@ func createJobFunc(job CronJob) func() {
func resolveCrontabPath() (string, error) { func resolveCrontabPath() (string, error) {
// Resolve crontab file location // 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 { 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(cwd, "crontab.cron")
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)
return crontabFile, nil return crontabFile, nil
} }