Move electrs startscript to tempdir and fix nits
This commit is contained in:
parent
5448619af4
commit
d9fbb9aff2
@ -21,6 +21,16 @@ in {
|
|||||||
default = "/var/lib/electrs";
|
default = "/var/lib/electrs";
|
||||||
description = "The data directory for electrs.";
|
description = "The data directory for electrs.";
|
||||||
};
|
};
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "electrs";
|
||||||
|
description = "The user as which to run electrs.";
|
||||||
|
};
|
||||||
|
group = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = cfg.user;
|
||||||
|
description = "The group as which to run electrs.";
|
||||||
|
};
|
||||||
high-memory = mkOption {
|
high-memory = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
@ -47,14 +57,15 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
users.users.electrs = {
|
users.users.${cfg.user} = {
|
||||||
|
name = cfg.user;
|
||||||
description = "electrs User";
|
description = "electrs User";
|
||||||
group = "electrs";
|
group = cfg.group;
|
||||||
extraGroups = [ "bitcoinrpc" "keys" "bitcoin"];
|
extraGroups = [ "bitcoinrpc" "keys" "bitcoin"];
|
||||||
home = cfg.dataDir;
|
home = cfg.dataDir;
|
||||||
};
|
};
|
||||||
users.groups.electrs = {
|
users.groups.electrs = {
|
||||||
name = "electrs";
|
name = cfg.group;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.electrs = {
|
systemd.services.electrs = {
|
||||||
@ -65,14 +76,14 @@ in {
|
|||||||
# create shell script to start up electrs safely with password parameter
|
# create shell script to start up electrs safely with password parameter
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -m 0770 -p ${cfg.dataDir}
|
mkdir -m 0770 -p ${cfg.dataDir}
|
||||||
chown 'electrs:electrs' ${cfg.dataDir}
|
chown -R '${cfg.user}:${cfg.group}' ${cfg.dataDir}
|
||||||
echo "${pkgs.electrs}/bin/electrs -vvv ${index-batch-size} ${jsonrpc-import} --timestamp --db-dir ${cfg.dataDir} --daemon-dir /var/lib/bitcoind --cookie=${config.services.bitcoind.rpcuser}:$(cat /secrets/bitcoin-rpcpassword) --electrum-rpc-addr=127.0.0.1:${toString cfg.port}" > /var/lib/electrs/startscript.sh
|
echo "${pkgs.electrs}/bin/electrs -vvv ${index-batch-size} ${jsonrpc-import} --timestamp --db-dir ${cfg.dataDir} --daemon-dir /var/lib/bitcoind --cookie=${config.services.bitcoind.rpcuser}:$(cat /secrets/bitcoin-rpcpassword) --electrum-rpc-addr=127.0.0.1:${toString cfg.port}" > /run/electrs/startscript.sh
|
||||||
chown -R 'electrs:electrs' ${cfg.dataDir}
|
|
||||||
chmod u+x ${cfg.dataDir}/startscript.sh
|
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = rec {
|
||||||
|
RuntimeDirectory = "electrs";
|
||||||
|
RuntimeDirectoryMode = "700";
|
||||||
PermissionsStartOnly = "true";
|
PermissionsStartOnly = "true";
|
||||||
ExecStart = "${pkgs.bash}/bin/bash ${cfg.dataDir}/startscript.sh";
|
ExecStart = "${pkgs.bash}/bin/bash /run/${RuntimeDirectory}/startscript.sh";
|
||||||
User = "electrs";
|
User = "electrs";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
|
Loading…
Reference in New Issue
Block a user