blob: 0cfde44fbe4f5f16286c9fb78dbaf2f3844686b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/bin/sh
dir=`dirname $0`
run_mysqld="$dir/run_mysqld"
run_httpd="$dir/run_httpd"
mysql="$dir/call_mysql"
dbname="asterisk" # FIXME: could it be changed?
mysql_rootpw="123456" # FIXME: copied from run_mysqld script
mysql_user="grant-all"
mysql_user_pass="Archibald-Alexander-Leach"
db_dump="db.sql"
usage() {
me=`basename $0`
echo "$me: runs a local instance of the web app (Apache + MySQL)"
echo "Usage: $me <start|stop|restart|reload|status> - the usual"
echo "Usage: $me <init|clean> - install / remove the databases"
}
do_init() {
$run_mysqld init
$run_mysqld start
sleep 1
(
echo "CREATE USER '$mysql_user'@'localhost' identified by '$mysql_user_pass'"
echo "CREATE DATABASE $dbname"
echo "GRANT ALL on $dbname.* to '$mysql_user'@'localhost'"
cat $db_dump
) | $mysql -uroot -p"$mysql_rootpw"
$run_mysqld stop
}
case "$1" in
start | stop | reload | restart) $run_httpd $1 && $run_mysqld $1;;
status) $run_httpd $1; $run_mysqld $1;; # FIXME: what status do I return?
clean) $run_mysqld $1;;
init) do_init;;
*) usage; exit 1;;
esac
|