#!/bin/bash

TMPIVR=/tmp/osdial_ivr_sync
IVRDIR=/var/lib/asterisk/sounds

WEB=$1

if [ -z "$WEB" ]; then
	WEB=127.0.0.1
fi

if [ ! -d "$IVRDIR" ]; then
	mkdir -p $IVRDIR
fi
if [ ! -d "$TMPIVR" ]; then
	mkdir $TMPIVR
fi
cd $TMPIVR
wget --mirror -nH http://$WEB/osdial/ivr > /dev/null 2>&1
cd osdial/ivr
for i in `ls *.wav *.WAV *.gsm *.GSM *.mp3 *.MP3`; do
	if [ ! -f "$IVRDIR/$i" ]; then
		cp -f "$i" $IVRDIR
	fi
done

#!/bin/bash

TMPIVR=/tmp/osdial_ivr_sync

WEB=$1

if [ -z "$WEB" ]; then
	WEB=127.0.0.1
fi

if [ ! -d "$TMPIVR" ]; then
	mkdir $TMPIVR
fi
cd $TMPIVR
wget --mirror -nH http://$WEB/osdial/ivr > /dev/null 2>&1
cd osdial/ivr
for i in `ls *.wav *.WAV *.gsm *.GSM *.mp3 *.MP3`; do
	if [ ! -f "/var/lib/asterisk/sounds/ivr/$i" ]; then
		cp -f "$i" /var/lib/asterisk/sounds/ivr
	fi
done

--- 
+++ 
@@ -1,7 +1,6 @@
 #!/bin/bash
 
 TMPIVR=/tmp/osdial_ivr_sync
-IVRDIR=/var/lib/asterisk/sounds
 
 WEB=$1
 
@@ -9,9 +8,6 @@
 	WEB=127.0.0.1
 fi
 
-if [ ! -d "$IVRDIR" ]; then
-	mkdir -p $IVRDIR
-fi
 if [ ! -d "$TMPIVR" ]; then
 	mkdir $TMPIVR
 fi
@@ -19,7 +15,7 @@
 wget --mirror -nH http://$WEB/osdial/ivr > /dev/null 2>&1
 cd osdial/ivr
 for i in `ls *.wav *.WAV *.gsm *.GSM *.mp3 *.MP3`; do
-	if [ ! -f "$IVRDIR/$i" ]; then
-		cp -f "$i" $IVRDIR
+	if [ ! -f "/var/lib/asterisk/sounds/ivr/$i" ]; then
+		cp -f "$i" /var/lib/asterisk/sounds/ivr
 	fi
 done
Fix ivr_sync to make sounds directory if not found.

