tor-hs: create hs folder only if not exists
authorSergey Ponomarev <redacted>
Wed, 7 Feb 2024 18:59:33 +0000 (20:59 +0200)
committerJosef Schlehofer <redacted>
Tue, 20 May 2025 11:20:46 +0000 (13:20 +0200)
Previously the chown/chmod was performed each time even if the folder already existed.

Signed-off-by: Sergey Ponomarev <redacted>
net/tor-hs/files/tor-hs.init

index eb909480fd62d2684fda4e29551e024fd5238594..33e3b1a636d753b3d7849ef060d2272f8a8fd78f 100755 (executable)
@@ -52,11 +52,12 @@ parse_hs_conf() {
        config_get ipv4 "$config" IPv4
 
        if [ "$enable_hs" = "1" ]; then
-               mkdir -p "$HS_DIR_PATH/$name"
-               chown "$TOR_USER":"$TOR_USER" "$HS_DIR_PATH/"
-               chown "$TOR_USER:$TOR_USER" "$HS_DIR_PATH/$name"
-               chmod 700 "$HS_DIR_PATH/"
-               chmod 700 "$HS_DIR_PATH/$name/"
+               if [ ! -d "$HS_DIR_PATH/$name" ]; then
+                       echo "New onion service dir is $HS_DIR_PATH/$name"
+                       mkdir -p -m 700 "$HS_DIR_PATH/"
+                       mkdir -m 700 "$HS_DIR_PATH/$name"
+                       chown -R "$TOR_USER:$TOR_USER" "$HS_DIR_PATH/"
+               fi
 
                echo "HiddenServiceDir $HS_DIR_PATH/$name" >> "$TORRC_FILE"
                config_list_foreach "$config" PublicLocalPort handle_hs_ports_conf "$ipv4"
git clone https://git.99rst.org/PROJECT