瀏覽代碼

feat: Only create readme.txt when folder is empty (#552)

Luis Muñiz 1 年之前
父節點
當前提交
900b520f23
共有 1 個文件被更改,包括 26 次插入21 次删除
  1. 26 21
      src/samba.sh

+ 26 - 21
src/samba.sh

@@ -21,7 +21,32 @@ if [ ! -d "$share" ] && [ -d "$STORAGE/shared" ]; then
 fi
 
 mkdir -p "$share"
-[ -z "$(ls -A "$share")" ] && chmod 777 "$share"
+
+if [ -z "$(ls -A "$share")" ]; then
+
+  chmod 777 "$share"
+
+  {      echo "--------------------------------------------------------"
+          echo " $APP for Docker v$(</run/version)..."
+          echo " For support visit $SUPPORT"
+          echo "--------------------------------------------------------"
+          echo ""
+          echo "Using this folder you can share files with the host machine."
+          echo ""
+          echo "To change its location, include the following bind mount in your compose file:"
+          echo ""
+          echo "  volumes:"
+          echo "    - \"/home/user/example:/shared\""
+          echo ""
+          echo "Or in your run command:"
+          echo ""
+          echo "  -v \"/home/user/example:/shared\""
+          echo ""
+          echo "Replace the example path /home/user/example with the desired shared folder."
+          echo ""
+  } | unix2dos > "$share/readme.txt"
+
+fi
 
 {      echo "[global]"
         echo "    server string = Dockur"
@@ -50,26 +75,6 @@ mkdir -p "$share"
         echo "    force group = root"
 } > "/etc/samba/smb.conf"
 
-{      echo "--------------------------------------------------------"
-        echo " $APP for Docker v$(</run/version)..."
-        echo " For support visit $SUPPORT"
-        echo "--------------------------------------------------------"
-        echo ""
-        echo "Using this folder you can share files with the host machine."
-        echo ""
-        echo "To change its location, include the following bind mount in your compose file:"
-        echo ""
-        echo "  volumes:"
-        echo "    - \"/home/user/example:/shared\""
-        echo ""
-        echo "Or in your run command:"
-        echo ""
-        echo "  -v \"/home/user/example:/shared\""
-        echo ""
-        echo "Replace the example path /home/user/example with the desired shared folder."
-        echo ""
-} | unix2dos > "$share/readme.txt"
-
 ! smbd && smbd --debug-stdout
 
 legacy=""