File: create_db.sh.in

package info (click to toggle)
tango 10.0.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 89,484 kB
  • sloc: cpp: 201,245; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 269; sql: 72; ruby: 24
file content (46 lines) | stat: -rwxr-xr-x 990 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
#!/usr/bin/env sh

set -e

mysql=@MYSQL@
mysql_admin=@MYSQL_ADMIN@
mysql_admin_passwd=@MYSQL_ADMIN_PASSWD@
mysql_host=@MYSQL_HOST@
db_name=@TANGO_DB_NAME@

if test "x$mysql_admin" = "x"; then
	user_switch="";
else
	user_switch="-u$x$mysql_admin";
fi

if test "x$mysql_admin_passwd" = "x"; then
   passwd_switch="";
else
   passwd_switch="-p$mysql_admin_passwd"
fi

if test "x$mysql_host" = "x"; then
  host_switch="";
else
  host_switch="-h$mysql_host";
fi

connect="$mysql $user_switch $passwd_switch $host_switch $db_name"

if `echo quit | $connect >/dev/null 2>&1`; then
   if test "x$mysql_host" = "x"; then
      echo "The $db_name database is already defined on this host" >&2
   else
      echo "The $db_name database is already defined on $mysql_host" >&2
   fi
   echo "Please run " >&2
   echo "$connect < ./update_db.sql" >&2
   echo "manually to force a db update" >&2

   exit 1
else
  $mysql $user_switch $passwd_switch $host_switch < ./create_db.sql > /dev/null

  exit 0
fi