41 lines
1023 B
Go
41 lines
1023 B
Go
//go:build !windows
|
|
|
|
package winsvc
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func IsService() bool { return false }
|
|
|
|
func Run(func(ctx context.Context) error) error {
|
|
return fmt.Errorf("Windows service is only supported on Windows")
|
|
}
|
|
|
|
func Install(string, string) error { return fmt.Errorf("Windows service is only supported on Windows") }
|
|
func Uninstall() error { return fmt.Errorf("Windows service is only supported on Windows") }
|
|
func Start() error { return fmt.Errorf("Windows service is only supported on Windows") }
|
|
func Stop() error { return fmt.Errorf("Windows service is only supported on Windows") }
|
|
|
|
func ExePath() (string, error) {
|
|
p, err := os.Executable()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.EvalSymlinks(p)
|
|
}
|
|
|
|
func CopyFile(src, dst string) error {
|
|
in, err := os.ReadFile(src)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := os.MkdirAll(filepath.Dir(dst), 0o750); err != nil {
|
|
return err
|
|
}
|
|
return os.WriteFile(dst, in, 0o600)
|
|
}
|