From c6e732265b0428f12a42f2a98ae83af38eda4ab5 Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Thu, 8 Feb 2018 17:43:42 +0100
Subject: [PATCH] Choose the number of maximum connections

---
 deploy.sh | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/deploy.sh b/deploy.sh
index af0372aa..a525cc63 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -1,11 +1,29 @@
 #!/bin/bash
+usage(){
+    echo "Usage $0 NbMaxconnections"
+    echo "Set the LCS maximum number of samba connection to NbMaxconnections"
+}
+
 if [[ ! "`hostname`" =~ "lcs" ]]
 then
     echo "This script should be run on the LCS"
+    usage
     exit 1
 fi
+
+if [ -z "$1" ]
+then
+    usage
+    exit 1
+fi
+
 DIR=`dirname $0`
 # Update lcs-smb-config then run it to force max connections to 1
-awk 'BEGIN{PRINT=1;FOUND=0} /^[";]*$/{if(IN){IN=0;if(FOUND==0){print "\tmax connections = 1";FOUND=1}}} /^\[homes\]/{IN=1} /max connections/{if(IN){FOUND=1;PRINT=0; print "\tmax connections = 1"}} {if(PRINT){print $0};PRINT=1}' /usr/share/lcs/sbin/lcs-smb-config > /usr/share/lcs/sbin/lcs-smb-config.new
+set -x
+awk "BEGIN{PRINT=1;FOUND=0} \
+    /^[\";]*$/{if(IN){IN=0;if(FOUND==0){print \"\tmax connections = $1\";FOUND=1}}} \
+    /^\[homes\]/{IN=1} /max connections/{if(IN){FOUND=1;PRINT=0; print \"\tmax connections = $1\"}} \
+    {if(PRINT){print \$0};PRINT=1}" \
+        /usr/share/lcs/sbin/lcs-smb-config > /usr/share/lcs/sbin/lcs-smb-config.new
 cp /usr/share/lcs/sbin/lcs-smb-config.new /usr/share/lcs/sbin/lcs-smb-config
 /usr/share/lcs/sbin/lcs-smb-config
-- 
GitLab