Skip to content

Commit 1544bac

Browse files
authored
Merge pull request #700 from prikshittekta/nginx-config
nginx config
2 parents 63a06fe + d2bad15 commit 1544bac

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

bin/commands/countly.sh

+48
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,53 @@ countly_backup (){
147147
countly_backupdb "$@";
148148
}
149149

150+
countly_save (){
151+
if [ $# -eq 1 ]
152+
then
153+
echo "Please provide destination path";
154+
return 0;
155+
fi
156+
157+
if [ $# -lt 2 ]
158+
then
159+
echo "Please provide file paths" ;
160+
return 0;
161+
fi
162+
163+
if [ ! -d $2 ]
164+
then
165+
mkdir -p $2
166+
fi
167+
168+
if [ -f $1 ]
169+
then
170+
match=false
171+
files=$(ls $2 | wc -l)
172+
173+
if [ $files -gt 0 ]
174+
then
175+
for d in $2/*; do
176+
diff=$(diff $1 $d | wc -l)
177+
if [ $diff == 0 ]
178+
then
179+
match=true
180+
break
181+
fi
182+
done
183+
fi
184+
185+
files=$((files+1))
186+
filebasename=$(basename $1)
187+
if [ "$match" == false ]
188+
then
189+
cp -a $1 $2/${filebasename}.backup.${files}
190+
fi
191+
192+
else
193+
echo "The file does not exist"
194+
fi
195+
}
196+
150197
countly_restorefiles (){
151198
if [ $# -eq 0 ]
152199
then
@@ -280,6 +327,7 @@ else
280327
echo " countly restorefiles path/to/backup # restores user/config files from provided backup";
281328
echo " countly restoredb path/to/backup # restores countly db from provided backup";
282329
echo " countly restore path/to/backup # restores countly db and config files from provided backup";
330+
echo " countly save path/to/file /path/to/destination # copies the given file to the destination if no file with same data is present at the destination";
283331
countly api ;
284332
countly plugin ;
285333
countly update ;

bin/countly.install_rhel.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ yum -y install nginx
5151
set +e
5252
useradd www-data
5353
unalias cp
54-
cp /etc/nginx/conf.d/default.conf $DIR/config/nginx.default.backup
54+
countly save /etc/nginx/conf.d/default.conf $DIR/config/nginx
55+
countly save /etc/nginx/nginx.conf $DIR/config/nginx
5556
cp $DIR/config/nginx.server.conf /etc/nginx/conf.d/default.conf
5657
cp $DIR/config/nginx.conf /etc/nginx/nginx.conf
5758
service nginx restart

bin/countly.install_ubuntu.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ then
7575
fi
7676

7777
#configure and start nginx
78-
cp /etc/nginx/sites-enabled/default $DIR/config/nginx.default.backup
78+
countly save /etc/nginx/sites-enabled/default $DIR/config/nginx
79+
countly save /etc/nginx/nginx.conf $DIR/config/nginx
7980
cp $DIR/config/nginx.server.conf /etc/nginx/sites-enabled/default
8081
cp $DIR/config/nginx.conf /etc/nginx/nginx.conf
8182

0 commit comments

Comments
 (0)