This commit is contained in:
Bob Mottram 2018-05-01 16:22:19 +01:00
parent 569410b9cc
commit cc1b4c1c6f
1 changed files with 16 additions and 16 deletions

View File

@ -34,7 +34,7 @@ HIDDEN_SERVICE_PATH='/var/lib/tor/hidden_service_'
ONION_SERVICES_FILE=/etc/torrc.d/${PROJECT_NAME}
function torrc_migrate {
if [ -f $ONION_SERVICES_FILE ]; then
if [ -f "$ONION_SERVICES_FILE" ]; then
if grep -q "#%include /etc/torrc.d" /etc/tor/torrc; then
sed -i 's|#%include /etc/torrc.d|%include /etc/torrc.d|g' /etc/tor/torrc
systemctl restart tor
@ -45,9 +45,9 @@ function torrc_migrate {
mkdir /etc/torrc.d
grep "HiddenServiceDir\\|HiddenServiceVersion\\|HiddenServicePort" /etc/tor/torrc | grep -v "#HiddenServiceDir" >> $ONION_SERVICES_FILE
grep "HiddenServiceDir\\|HiddenServiceVersion\\|HiddenServicePort" /etc/tor/torrc | grep -v "#HiddenServiceDir" >> "$ONION_SERVICES_FILE"
if ! grep "HiddenServiceVersion" $ONION_SERVICES_FILE; then
if ! grep "HiddenServiceVersion" "$ONION_SERVICES_FILE"; then
systemctl restart tor
return
fi
@ -121,17 +121,17 @@ function remove_onion_service {
nick="$3"
if [ ${#nick} -gt 0 ]; then
sed -i "/stealth ${nick}/d" $ONION_SERVICES_FILE
sed -i "/stealth ${nick}/d" "$ONION_SERVICES_FILE"
fi
sed -i "/hidden_service_${onion_service_name}/,+1 d" $ONION_SERVICES_FILE
sed -i "/hidden_service_${onion_service_name}_mobile/,+1 d" $ONION_SERVICES_FILE
sed -i "/127.0.0.1:${onion_service_port_to}/d" $ONION_SERVICES_FILE
sed -i "/hidden_service_${onion_service_name}/,+1 d" "$ONION_SERVICES_FILE"
sed -i "/hidden_service_${onion_service_name}_mobile/,+1 d" "$ONION_SERVICES_FILE"
sed -i "/127.0.0.1:${onion_service_port_to}/d" "$ONION_SERVICES_FILE"
if [ "$3" ]; then
sed -i "/127.0.0.1:${3}/d" $ONION_SERVICES_FILE
sed -i "/127.0.0.1:${3}/d" "$ONION_SERVICES_FILE"
if [ "$4" ]; then
sed -i "/127.0.0.1:${4}/d" $ONION_SERVICES_FILE
sed -i "/127.0.0.1:${4}/d" "$ONION_SERVICES_FILE"
if [ "$5" ]; then
sed -i "/127.0.0.1:${5}/d" $ONION_SERVICES_FILE
sed -i "/127.0.0.1:${5}/d" "$ONION_SERVICES_FILE"
fi
fi
fi
@ -164,16 +164,16 @@ function add_onion_service {
USE_V2_ONION_ADDRESS=
exit 877367
fi
if ! grep -q "hidden_service_${onion_service_name}" $ONION_SERVICES_FILE; then
echo "HiddenServiceDir ${HIDDEN_SERVICE_PATH}${onion_service_name}/" >> $ONION_SERVICES_FILE
if ! grep -q "hidden_service_${onion_service_name}" "$ONION_SERVICES_FILE"; then
echo "HiddenServiceDir ${HIDDEN_SERVICE_PATH}${onion_service_name}/" >> "$ONION_SERVICES_FILE"
if [ ! $USE_V2_ONION_ADDRESS ]; then
echo 'HiddenServiceVersion 3' >> $ONION_SERVICES_FILE
echo 'HiddenServiceVersion 3' >> "$ONION_SERVICES_FILE"
else
echo 'HiddenServiceVersion 2' >> $ONION_SERVICES_FILE
echo 'HiddenServiceVersion 2' >> "$ONION_SERVICES_FILE"
fi
echo "HiddenServicePort ${onion_service_port_from} 127.0.0.1:${onion_service_port_to}" >> $ONION_SERVICES_FILE
echo "HiddenServicePort ${onion_service_port_from} 127.0.0.1:${onion_service_port_to}" >> "$ONION_SERVICES_FILE"
if [ ${#onion_stealth_name} -gt 0 ]; then
echo "HiddenServiceAuthorizeClient stealth ${onion_stealth_name}" >> $ONION_SERVICES_FILE
echo "HiddenServiceAuthorizeClient stealth ${onion_stealth_name}" >> "$ONION_SERVICES_FILE"
fi
fi