h: switch to env file for golink
This commit is contained in:
parent
72a0442649
commit
9b93a4a973
@ -24,7 +24,7 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
keyFile = mkOption {
|
envFile = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "/run/secrets/golink";
|
default = "/run/secrets/golink";
|
||||||
description = ''
|
description = ''
|
||||||
@ -81,8 +81,10 @@ in {
|
|||||||
CacheDirectory = "golink";
|
CacheDirectory = "golink";
|
||||||
CacheDirectoryMode = "0755";
|
CacheDirectoryMode = "0755";
|
||||||
|
|
||||||
|
EnvironmentFile = cfg.envFile;
|
||||||
|
|
||||||
ExecStart =
|
ExecStart =
|
||||||
"${cfg.package}/bin/golink -sqlitedb ${cfg.dataDir}/golink.db -keyfile ${cfg.keyFile}";
|
"${cfg.package}/bin/golink -sqlitedb ${cfg.dataDir}/golink.db";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -10,12 +10,10 @@ buildGoModule rec {
|
|||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "tailscale";
|
owner = "tailscale";
|
||||||
repo = pname;
|
repo = pname;
|
||||||
rev = "0755e37a910b73b586544e2805c075dcec7d0207";
|
rev = "5fefe2519ffd9f1c6a3dd86a764d69717ee66d20";
|
||||||
sha256 = "sha256-zzup/TR9iRNPrEEOzhIL5PTF8iKF8NlPqXBuRKt8AEc=";
|
sha256 = "sha256-H4mwyQVFH/Yp6gIpN1o+L7S3Rupwbxl5CCLltcBh1Vk=";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [ ./golink_keyfile.diff ];
|
|
||||||
|
|
||||||
vendorSha256 = vendorHash;
|
vendorSha256 = vendorHash;
|
||||||
|
|
||||||
proxyVendor = true;
|
proxyVendor = true;
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
diff --git a/golink.go b/golink.go
|
|
||||||
index 3bc3353..fb0e791 100644
|
|
||||||
--- a/golink.go
|
|
||||||
+++ b/golink.go
|
|
||||||
@@ -37,6 +37,7 @@ var (
|
|
||||||
sqlitefile = flag.String("sqlitedb", "", "path of SQLite database to store links")
|
|
||||||
dev = flag.String("dev-listen", "", "if non-empty, listen on this addr and run in dev mode; auto-set sqlitedb if empty and don't use tsnet")
|
|
||||||
snapshot = flag.String("snapshot", "", "file path of snapshot file")
|
|
||||||
+ keyfile = flag.String("keyfile", "", "file path of file containing tskey")
|
|
||||||
)
|
|
||||||
|
|
||||||
var stats struct {
|
|
||||||
@@ -116,6 +117,13 @@ func Run() error {
|
|
||||||
Hostname: "go",
|
|
||||||
Logf: func(format string, args ...any) {},
|
|
||||||
}
|
|
||||||
+ if *keyfile != "" {
|
|
||||||
+ keyData, err := os.ReadFile(*keyfile)
|
|
||||||
+ if err != nil {
|
|
||||||
+ log.Fatalf("error reading keyfile file %q: %v", *keyfile, err)
|
|
||||||
+ }
|
|
||||||
+ srv.AuthKey = string(keyData)
|
|
||||||
+ }
|
|
||||||
if *verbose {
|
|
||||||
srv.Logf = log.Printf
|
|
||||||
}
|
|
||||||
@@ -353,7 +361,7 @@ type expandEnv struct {
|
|
||||||
var expandFuncMap = texttemplate.FuncMap{
|
|
||||||
"PathEscape": url.PathEscape,
|
|
||||||
"QueryEscape": url.QueryEscape,
|
|
||||||
- "TrimSuffix": strings.TrimSuffix,
|
|
||||||
+ "TrimSuffix": strings.TrimSuffix,
|
|
||||||
}
|
|
||||||
|
|
||||||
// expandLink returns the expanded long URL to redirect to, executing any
|
|
Loading…
Reference in New Issue
Block a user