onionAddresses: improve script
- use -e to check for existence of /var/lib/tor/state, use shorter polling interval - clear existing dataDir contents to avoid accumulating obsolete data - use concatMapStrings instead of foldl'
This commit is contained in:
parent
b266f23251
commit
5f34b094d3
@ -44,32 +44,27 @@ in {
|
|||||||
CapabilityBoundingSet = "CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_IPC_OWNER";
|
CapabilityBoundingSet = "CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_IPC_OWNER";
|
||||||
};
|
};
|
||||||
script = ''
|
script = ''
|
||||||
# wait until tor is up
|
# Wait until tor is up
|
||||||
until ls -l /var/lib/tor/state; do sleep 1; done
|
until [[ -e /var/lib/tor/state ]]; do sleep 0.1; done
|
||||||
|
|
||||||
cd ${dataDir}
|
cd ${dataDir}
|
||||||
|
rm -rf *
|
||||||
|
|
||||||
# Create directory for every user and set permissions
|
${concatMapStrings
|
||||||
${ builtins.foldl'
|
(user: ''
|
||||||
(x: user: x +
|
|
||||||
''
|
|
||||||
mkdir -p -m 0700 ${user}
|
mkdir -p -m 0700 ${user}
|
||||||
chown ${user} ${user}
|
chown ${user} ${user}
|
||||||
# Copy onion hostnames into the user's directory
|
${concatMapStrings
|
||||||
${ builtins.foldl'
|
(service: ''
|
||||||
(x: onion: x +
|
onionFile=/var/lib/tor/onion/${service}/hostname
|
||||||
''
|
if [[ -e $onionFile ]]; then
|
||||||
ONION_FILE=/var/lib/tor/onion/${onion}/hostname
|
cp $onionFile ${user}/${service}
|
||||||
if [ -e "$ONION_FILE" ]; then
|
chown ${user} ${user}/${service}
|
||||||
cp $ONION_FILE ${user}/${onion}
|
fi
|
||||||
chown ${user} ${user}/${onion}
|
'')
|
||||||
fi
|
cfg.access.${user}
|
||||||
'')
|
}
|
||||||
""
|
'')
|
||||||
(builtins.getAttr user cfg.access)
|
|
||||||
}
|
|
||||||
'')
|
|
||||||
""
|
|
||||||
(builtins.attrNames cfg.access)
|
(builtins.attrNames cfg.access)
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user