Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
cat << 'EOL' >/var/spool/asterisk/backup/hooks/postrestorehook.sh
#!/bin/bash

sql="/usr/bin/mysql --defaults-extra-file=/var/spool/asterisk/backup/hooks/.my.cnf"

#DB1
db1="test"
db1exists="$($sql -e 'show databases;' | grep -w $db1)"
if [ -z "$db1exists" ]; then
	"$sql" -e "create database $db1;"
fi
$sql $db1 < /var/spool/asterisk/backup/hooks/$db1.sql

EOL
chown asterisk:asterisk /var/spool/asterisk/backup/hooks/ -R
chmod +x /var/spool/asterisk/backup/hooks/*

...