#!/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,6 +1,7 @@
 #!/bin/bash
 
 TMPIVR=/tmp/osdial_ivr_sync
+IVRDIR=/var/lib/asterisk/sounds
 
 WEB=$1
 
@@ -8,6 +9,9 @@
 	WEB=127.0.0.1
 fi
 
+if [ ! -d "$IVRDIR" ]; then
+	mkdir -p $IVRDIR
+fi
 if [ ! -d "$TMPIVR" ]; then
 	mkdir $TMPIVR
 fi
@@ -15,7 +19,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 "/var/lib/asterisk/sounds/ivr/$i" ]; then
-		cp -f "$i" /var/lib/asterisk/sounds/ivr
+	if [ ! -f "$IVRDIR/$i" ]; then
+		cp -f "$i" $IVRDIR
 	fi
 done
Fix ivr_sync to make sounds directory if not found.

