Skip to content
Snippets Groups Projects
Verified Commit b370727f authored by David Beniamine's avatar David Beniamine
Browse files

Better deploy and reset

parent c4ecffff
No related branches found
No related tags found
No related merge requests found
#!/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
#!/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
reset.sh 0 → 100644
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment