File: fetchSampleDatabases.sh

package info (click to toggle)
mysqltuner 2.8.29-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,128 kB
  • sloc: perl: 7,229; sh: 620; python: 135; makefile: 119
file content (42 lines) | stat: -rwxr-xr-x 1,326 bytes parent folder | download
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
#!/bin/sh
# ==================================================================================
# Script: fetchSampleDatabases.sh
# Description: Fetches sample MySQL databases (sakila, world, etc.) for testing.
# Author: Jean-Marie Renouard
# Project: MySQLTuner-perl
# ==================================================================================



DB_WORLD_URL="https://downloads.mysql.com/docs/world.sql.zip"
DB_WORLDX_URL="https://downloads.mysql.com/docs/world_x-db.zip"
DB_SAKILA_URL="https://downloads.mysql.com/docs/sakila-db.zip"
DB_MESSAGERIE_URL="https://downloads.mysql.com/docs/menagerie-db.zip"
DB_TESTDB_URL="https://github.com/jmrenouard/test_db/archive/master.zip"

getVal()
{
    local vari=$1
    eval "echo \$$vari"
}
case "$1" in
    "fetchall")
        for sample in WORLD WORLDX SAKILA MESSAGERIE TESTDB; do
            sh $0 fetch $sample
        done
        ;;
    "fetch")
        [ -z "$2" ] && exit 1
        mkdir -p ./contents
        [ -f "contents/$(basename $(getVal "DB_$2_URL"))" ] || wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL")
        if [ $? -eq 0 ];then
             (cd contents; unzip $( basename $(getVal "DB_$2_URL")) )
        fi
        ;;
    "clean")
        rm -rf contents
        ;;
   *)
        echo "Unknown operation: $1"
        ;;
esac