diff --git a/deploy.sh b/deploy.sh index 1e055700e3bea42b1a709d8afc18309c2ae6d3f6..cd7d935d758b3f83b9f4e07568da4fc5b87eb092 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,8 +1,4 @@ #!/bin/bash -usage(){ - echo "Usage $0 NbMaxconnections" - echo "Set the LCS maximum number of samba connection to NbMaxconnections" -} # Copyright (C) 2018 Tetras Libre <Contact@Tetras-Libre.fr> # Author: Beniamine, David <David.Beniamine@Tetras-Libre.fr> @@ -23,23 +19,16 @@ usage(){ if [[ ! "`hostname`" =~ "lcs" ]] then echo "This script should be run on the LCS" - usage exit 1 fi -if [ -z "$1" ] +DIR=`dirname $0` + +if [ -f "/usr/local/sbin/post-smb-config" ] && \ + [ ! -f "/usr/local/sbin/post-smb-config" ] then - usage - exit 1 + cp /usr/local/sbin/post-smb-config /usr/local/sbin/post-smb-config.old fi - -DIR=`dirname $0` -# Update lcs-smb-config then run it to force max connections to 1 -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 +cp $DIR/post-smb-config /usr/local/sbin/post-smb-config +/usr/local/sbin/post-smb-config +service samba restart diff --git a/post-smb-config b/post-smb-config new file mode 100644 index 0000000000000000000000000000000000000000..42dc2469fdf0246504eb8e78fbc7f0375828a7d5 --- /dev/null +++ b/post-smb-config @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright (C) 2018 Tetras Libre <Contact@Tetras-Libre.fr> +# Author: Beniamine, David <David.Beniamine@Tetras-Libre.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +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}" \ + /etc/samba/smb.conf > /etc/samba/smb.conf.new +if [ ! -f "/etc/samba/smb.conf.old" ] +then + cp /etc/samba/smb.conf /etc/samba/smb.conf.old +fi +mv /etc/samba/smb.conf.new /etc/samba/smb.conf diff --git a/reset.sh b/reset.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8643667c1c5744eca5b3f0911ebb9bd3032a372 --- /dev/null +++ b/reset.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (C) 2018 Tetras Libre <Contact@Tetras-Libre.fr> +# Author: Beniamine, David <David.Beniamine@Tetras-Libre.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +if [[ ! "`hostname`" =~ "lcs" ]] +then + echo "This script should be run on the LCS" + exit 1 +fi + +DIR=`dirname $0` +if [ -f "/usr/local/sbin/post-smb-config.old" ] +then + cp /usr/local/sbin/post-smb-config.old /usr/local/sbin/post-smb-config +else + rm /usr/local/sbin/post-smb-config +fi +awk "BEGIN{PRINT=1;FOUND=0} \ + /^$/{if(IN){IN=0;if(FOUND==0){print \"\tmax connections = 30\";FOUND=1}}} \ + /^\[homes\]/{IN=1} /max connections/{if(IN){FOUND=1;PRINT=0; print \"\tmax connections = 30\"}} \ + {if(PRINT){print \$0};PRINT=1}" \ + /etc/samba/smb.conf > /etc/samba/smb.conf.new +if [ ! -f "/etc/samba/smb.conf.old" ] +then + cp /etc/samba/smb.conf /etc/samba/smb.conf.old +fi +mv /etc/samba/smb.conf.new /etc/samba/smb.conf +service samba restart +