tywin: enable storj on d0
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Jake Hillion 2023-06-28 22:12:56 +01:00
parent 4e2fc5cdbd
commit 4b13bd1444
3 changed files with 39 additions and 16 deletions

View File

@ -99,6 +99,8 @@
ip daddr 10.64.50.20 tcp dport 8444 counter accept comment "Chia" ip daddr 10.64.50.20 tcp dport 8444 counter accept comment "Chia"
ip daddr 10.64.50.20 tcp dport 28967 counter accept comment "zfs.tywin.storj" ip daddr 10.64.50.20 tcp dport 28967 counter accept comment "zfs.tywin.storj"
ip daddr 10.64.50.20 udp dport 28967 counter accept comment "zfs.tywin.storj" ip daddr 10.64.50.20 udp dport 28967 counter accept comment "zfs.tywin.storj"
ip daddr 10.64.50.20 tcp dport 28968 counter accept comment "d0.tywin.storj"
ip daddr 10.64.50.20 udp dport 28968 counter accept comment "d0.tywin.storj"
} }
} }
@ -108,6 +110,8 @@
iifname eth0 tcp dport 8444 counter dnat to 10.64.50.20 iifname eth0 tcp dport 8444 counter dnat to 10.64.50.20
iifname eth0 tcp dport 28967 counter dnat to 10.64.50.20 iifname eth0 tcp dport 28967 counter dnat to 10.64.50.20
iifname eth0 udp dport 28967 counter dnat to 10.64.50.20 iifname eth0 udp dport 28967 counter dnat to 10.64.50.20
iifname eth0 tcp dport 28968 counter dnat to 10.64.50.20
iifname eth0 udp dport 28968 counter dnat to 10.64.50.20
} }
chain postrouting { chain postrouting {

View File

@ -90,7 +90,26 @@
email = "jake+storj@hillion.co.uk"; email = "jake+storj@hillion.co.uk";
wallet = "0x03cebe2608945D51f0bcE6c5ef70b4948fCEcfEe"; wallet = "0x03cebe2608945D51f0bcE6c5ef70b4948fCEcfEe";
}; };
custom.storj.instances.zfs = {
custom.storj.instances =
let
mkStorj = index: {
name = "d${toString index}";
value = {
configDir = "/mnt/d${toString index}/storj/config";
identityDir = "/mnt/d${toString index}/storj/identity";
serverPort = 28967 + 1 + index;
externalAddress = "d${toString index}.tywin.storj.hillion.co.uk:${toString (28967 + 1 + index)}";
consoleAddress = "100.115.31.91:${toString (14002 + 1 + index)}";
storage = "1000GB";
};
};
instances = builtins.genList (x: x) 1;
in
builtins.listToAttrs (builtins.map mkStorj instances) // {
zfs = {
configDir = "/data/storj/config"; configDir = "/data/storj/config";
identityDir = "/data/storj/identity"; identityDir = "/data/storj/identity";
storage = "500GB"; storage = "500GB";
@ -99,6 +118,8 @@
externalAddress = "zfs.tywin.storj.hillion.co.uk:28967"; externalAddress = "zfs.tywin.storj.hillion.co.uk:28967";
authorizationTokenFile = config.age.secrets."storj/zfs_auth".path; authorizationTokenFile = config.age.secrets."storj/zfs_auth".path;
}; };
networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ 14002 ]; };
networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ 14002 14003 ];
}; };
} }

View File

@ -78,13 +78,14 @@ in
"--operator.wallet '${cfg.wallet}'" "--operator.wallet '${cfg.wallet}'"
"--console.address '${value.consoleAddress}'" "--console.address '${value.consoleAddress}'"
"--server.address ':${toString value.serverPort}'" "--server.address ':${toString value.serverPort}'"
"--server.private-address ':0'"
"--storage.allocated-disk-space '${value.storage}'" "--storage.allocated-disk-space '${value.storage}'"
] ++ (if value.externalAddress == null then [ ] else [ ] ++ (if value.externalAddress == null then [ ] else [
"--contact.external-address '${value.externalAddress}'" "--contact.external-address '${value.externalAddress}'"
])); ]));
in in
with pkgs; with pkgs;
if value.authorizationTokenFile == null then "" else with pkgs; '' (if value.authorizationTokenFile == null then "" else ''
if ! grep -c BEGIN ${value.identityDir}/ca.cert; then if ! grep -c BEGIN ${value.identityDir}/ca.cert; then
rm -rf ${value.identityDir}/storagenode rm -rf ${value.identityDir}/storagenode
${storj}/bin/identity create storagenode \ ${storj}/bin/identity create storagenode \
@ -96,8 +97,8 @@ in
mv ${value.identityDir}/storagenode/* ${value.identityDir} mv ${value.identityDir}/storagenode/* ${value.identityDir}
rm -d ${value.identityDir}/storagenode rm -d ${value.identityDir}/storagenode
fi fi
'' + '' '') + ''
if ! test -d ${value.configDir}/storage/blobs; then if ! test -f ${value.configDir}/config.yaml; then
${storj}/bin/storagenode setup ${args} ${storj}/bin/storagenode setup ${args}
fi fi
${storj}/bin/storagenode run ${args} ${storj}/bin/storagenode run ${args}
@ -125,6 +126,3 @@ in
}; };
}; };
} }