kea-admin.in 21 KB
Newer Older
1 2
#!/bin/sh

Francis Dupont's avatar
Francis Dupont committed
3
# Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
4
#
5 6 7
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 9 10 11

# This is kea-admin script that conducts administrative tasks on the Kea
# installation. Currently supported operations are:
#
12 13 14
# - lease database init
# - lease database version check
# - lease database version upgrade
15 16 17


# Get the location of the kea-admin scripts
18
prefix=@prefix@
19
export prefix
20
SCRIPTS_DIR_DEFAULT=@datarootdir@/@PACKAGE@/scripts
21
scripts_dir=${SCRIPTS_DIR_DEFAULT}
22
VERSION=@PACKAGE_VERSION@
23 24 25

# These are the default parameters. They will likely not work in any
# specific deployment.
26
db_host="localhost"
27 28 29 30
db_user="keatest"
db_password="keatest"
db_name="keatest"

31 32 33
# lease dump parameters
dump_type=0
dump_file=""
34
dump_qry=""
35

36 37 38 39 40
# Include utilities. Use installed version if available and
# use build version if it isn't.
if [ -e @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh ]; then
    . @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh
else
41
    . @abs_top_srcdir@/src/bin/admin/admin-utils.sh
42 43
fi

44
# Prints out usage version.
45
usage() {
46
    printf "kea-admin $VERSION\n"
47 48 49 50 51 52 53 54
    printf "\n"
    printf "This is a kea-admin script that conducts administrative tasks on\n"
    printf "the Kea installation.\n"
    printf "\n"
    printf "Usage: $0 COMMAND BACKEND [parameters]\n"
    printf "\n"
    printf "COMMAND: Currently supported operations are:\n"
    printf "\n"
55
    printf " - lease-init: Initializes new lease database. Useful for first time installation.\n"
56 57 58
    printf " - lease-version: Checks version of the existing lease database scheme. Useful\n"
    printf " -                for checking lease DB version when preparing for an upgrade.\n"
    printf " - lease-upgrade: Upgrades your lease database scheme\n"
59
    printf " - lease-dump: Dump current leases to a CSV file\n"
60
    printf "\n"
Tomek Mrugalski's avatar
Tomek Mrugalski committed
61
    printf "BACKEND - one of the supported backends: memfile|mysql|pgsql|cql\n"
62 63 64
    printf "\n"
    printf "PARAMETERS: Parameters are optional in general, but may be required\n"
    printf "            for specific operation.\n"
65
    printf " -h or --host hostname - specifies a hostname of a database to connect to\n"
66 67 68 69
    printf " -u or --user name - specifies username when connecting to a database\n"
    printf " -p or --password pass - specifies a password when connecting to a database\n"
    printf " -n or --name database - specifies a database name to connect to\n"
    printf " -d or --directory - path to upgrade scripts (default: ${SCRIPTS_DIR_DEFAULT})\n"
70
    printf " -v or --version - print kea-admin version and quit.\n"
71 72 73 74 75
    printf "\n"
    printf " Parameters specific to lease-dump:\n"
    printf "     -4 to dump IPv4 leases to file\n"
    printf "     -6 to dump IPv6 leases to file\n"
    printf "     -o or --output - name of file to which leases will be dumped\n"
76 77 78 79 80 81
}


### Logging functions ###

# Logs message at the error level.
82
# Takes one parameter that is printed as is.
83 84 85 86 87
log_error() {
    printf "ERROR/kea-admin: ${1}\n"
}

# Logs message at the warning level.
88
# Takes one parameter that is printed as is.
89 90 91 92 93
log_warning() {
    printf "WARNING/kea-admin: ${1}\n"
}

# Logs message at the info level.
94
# Takes one parameter that is printed as is.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
log_info() {
    printf "INFO/kea-admin: ${1}\n"
}

### Convenience functions ###

# Checks if the value is in the list. An example usage of this function
# is to determine whether the kea-admin command belongs to the list of
# supported commands.
is_in_list() {
    local member=${1}  # Value to be checked
    local list="${2}"  # Comma separated list of items
    _inlist=0          # Return value: 0 if not in list, 1 otherwise.
    if [ -z ${member} ]; then
        log_error "missing ${class}"
    fi
    # Iterate over all items on the list and compare with the member.
    # If they match, return, otherwise log error and exit.
    for item in ${list}
    do
        if [ ${item} = ${member} ]; then
            _inlist=1
            return
        fi
    done
}


### Functions that implement database initialization commands
124

125
memfile_init() {
126
    # @todo Implement this as part of #3601
127 128 129 130
    log_error "NOT IMPLEMENTED"
    exit 1
}

131 132 133 134
# Initializes a new, empty MySQL database.
# It essentially calls scripts/mysql/dhcpdb_create.mysql script, with
# some extra sanity checks. It will refuse to use it if there are any
# existing tables. It's better safe than sorry.
135
mysql_init() {
136 137 138 139 140 141 142 143
    printf "Checking if there is a database initialized already. Please ignore errors.\n"

    # Let's try to count the number of tables. Anything above 0 means that there
    # is some database in place. If there is anything, we abort. Note that
    # mysql may spit out connection or access errors to stderr, we ignore those.
    # We should not hide them as they may give hints to user what is wrong with
    # his setup.
    #
144 145 146 147 148 149 150 151 152
    RESULT=`mysql_execute "SHOW TABLES;"`
    ERRCODE=$?
    if [ $ERRCODE -ne  0 ]
    then
        log_error "mysql_init table query failed, mysql status = $ERRCODE"
        exit 1
    fi

    COUNT=`echo $RESULT | wc -w`
153
    if [ $COUNT -gt 0 ]; then
Josh Soref's avatar
Josh Soref committed
154
        # Let's start with a new line. mysql could have printed something out.
155
        printf "\n"
156
        log_error "Expected empty database $db_name, but there are $COUNT tables: \n$RESULT. Aborting."
157 158 159
        exit 1
    fi

160
    printf "Initializing database using script %s\n" $scripts_dir/mysql/dhcpdb_create.mysql
161
    mysql -B --host=$db_host --user=$db_user --password=$db_password $db_name < $scripts_dir/mysql/dhcpdb_create.mysql
162 163 164 165 166
    ERRCODE=$?

    printf "mysql returned status code $ERRCODE\n"

    if [ "$ERRCODE" -eq 0 ]; then
167
        printf "Lease DB version reported after initialization: "
168
        mysql_version
169 170 171 172
        printf "\n"
    fi

    exit $ERRCODE
173 174
}

175
pgsql_init() {
176 177 178 179
    printf "Checking if there is a database initialized already. Please ignore errors.\n"

    # Let's try to count the number of tables. Anything above 0 means that there
    # is some database in place. If there is anything, we abort.
180 181 182 183 184 185 186 187
    RESULT=`pgsql_execute "\d"`
    ERRCODE=$?
    if [ "$ERRCODE" -ne 0 ]; then
        log_error "pgsql_init: table query failed, status code: $ERRCODE?"
        exit 1
    fi

    COUNT=`echo "$RESULT" | wc -w`
188 189
    if [ $COUNT -gt 0 ]; then
        printf "\n"
190
        log_error "Expected empty database $db_name, but the following tables are present \n$RESULT. Aborting."
191 192 193 194 195
        exit 2
    fi

    init_script="$scripts_dir/pgsql/dhcpdb_create.pgsql"
    printf "Initializing database using script %s\n" $init_script
196
    RESULT=`pgsql_execute_script $init_script`
197 198
    ERRCODE=$?
    if [ "$ERRCODE" -ne 0 ]; then
199
        log_error "Database initialization failed, status code: $ERRCODE?"
200 201 202
        exit 1
    fi

203 204
    version=`pgsql_version`
    printf "Lease DB version reported after initialization: $version\n"
205
    exit 0
206 207
}

Tomek Mrugalski's avatar
Tomek Mrugalski committed
208
cql_init() {
209 210
    printf "Checking if there is a database initialized already... Please ignore errors.\n"

Andrei Pavel's avatar
Andrei Pavel committed
211 212
    result=$(cql_execute "DESCRIBE tables;")
    if [ $(echo "$result" | grep "<empty>" | wc -w) -gt 0 ]; then
213 214 215
        printf "Creating and initializing tables using script %s...\n" $scripts_dir/cql/dhcpdb_create.cql
        cql_execute_script $scripts_dir/cql/dhcpdb_create.cql
    else
Tomek Mrugalski's avatar
Tomek Mrugalski committed
216 217
        log_error "Expected empty database $db_name, but the following tables are present \n$result. Aborting."
        exit 2
218 219
    fi

Andrei Pavel's avatar
Andrei Pavel committed
220 221
    version=$(cql_version)
    printf "Lease DB version reported after initialization: %s\n" "$version"
222

Razvan Becheriu's avatar
Razvan Becheriu committed
223
    exit 0
224 225
}

226
### Functions that implement database version checking commands
227
memfile_version() {
228
    # @todo Implement this as part of #3601
229 230 231 232 233
    log_error "NOT IMPLEMENTED"
    exit 1
}

### Functions used for upgrade
234
memfile_upgrade() {
235
    # @todo Implement this as part of #3601
236 237 238 239
    log_error "NOT IMPLEMENTED"
    exit 1
}

240 241 242 243 244 245
# Upgrades existing MySQL database installation. The idea is that
# it will go over all upgrade scripts from (prefix)/share/kea/scripts/mysql
# and run them one by one. They will be named properly, so they will
# be run in order.
#
# This function prints version before and after upgrade.
246
mysql_upgrade() {
247

248
    printf "Lease DB version reported before upgrade: "
249
    mysql_version
250
    printf "\n"
251 252 253 254 255 256 257 258

    # Check if the scripts directory exists at all.
    if [ ! -d ${scripts_dir}/mysql ]; then
        log_error "Invalid scripts directory: ${scripts_dir}/mysql"
        exit 1
    fi

    # Check if there are any files in it
259
    num_files=$(find ${scripts_dir}/mysql/upgrade*.sh -type f | wc -l)
260
    if [ $num_files -eq 0 ]; then
261
        log_error "No scripts in ${scripts_dir}/mysql or the directory is not readable or does not have any upgrade* scripts."
262 263 264
        exit 1
    fi

265
    for script in ${scripts_dir}/mysql/upgrade*.sh
266 267
    do
        echo "Processing $script file..."
268
        sh ${script} --host=${db_host} --user=${db_user} --password=${db_password} ${db_name}
269 270
    done

271
    printf "Lease DB version reported after upgrade: "
272
    mysql_version
273
    printf "\n"
274 275
}

276
pgsql_upgrade() {
277 278
    version=`pgsql_version`
    printf "Lease DB version reported before upgrade: $version\n"
279 280 281 282 283 284 285 286 287 288 289 290 291 292

    # Check if the scripts directory exists at all.
    if [ ! -d ${scripts_dir}/pgsql ]; then
        log_error "Invalid scripts directory: ${scripts_dir}/pgsql"
        exit 1
    fi

    # Check if there are any files in it
    num_files=$(find ${scripts_dir}/pgsql/upgrade*.sh -type f | wc -l)
    if [ $num_files -eq 0 ]; then
        log_error "No scripts in ${scripts_dir}/pgsql or the directory is not readable or does not have any upgrade* scripts."
        exit 1
    fi

293 294 295 296
    # Postgres psql does not accept pw on command line, but can do it
    # thru an env
    export PGPASSWORD=$db_password

297 298 299
    for script in ${scripts_dir}/pgsql/upgrade*.sh
    do
        echo "Processing $script file..."
300
        sh ${script} -U ${db_user} -h ${db_host} -d ${db_name}
301 302
    done

303 304
    version=`pgsql_version`
    printf "Lease DB version reported after upgrade: $version\n"
305
    exit 0
306 307
}

Tomek Mrugalski's avatar
Tomek Mrugalski committed
308 309
cql_upgrade() {
    version=`cql_version`
310 311 312
    printf "Lease DB version reported before upgrade: $version\n"

    # Check if the scripts directory exists at all.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
313 314
    if [ ! -d ${scripts_dir}/cql ]; then
        log_error "Invalid scripts directory: ${scripts_dir}/cql"
315 316 317
        exit 1
    fi

318 319 320
    # Check if directory is readable.
    if [ ! -r ${scripts_dir}/cql ]; then
        log_error "Directory is not readable: ${scripts_dir}/cql"
321 322 323
        exit 1
    fi

324 325 326 327 328 329 330 331 332 333 334
    # Check if there are upgrade scripts.
    files=$(find ${scripts_dir}/cql/upgrade*.sh -type f)
    if [ $? -eq 0 ]; then # Upgrade scripts are present.
        for script in ${scripts_dir}/cql/upgrade*.sh
        do
            echo "Processing $script file..."
            sh ${script} -u ${db_user} -p ${db_password} -k ${db_name}
        done
    else
        echo "No upgrade script available."
    fi
335

Tomek Mrugalski's avatar
Tomek Mrugalski committed
336
    version=`cql_version`
337
    printf "Lease DB version reported after upgrade: $version\n"
Razvan Becheriu's avatar
Razvan Becheriu committed
338
    exit 0
339 340
}

341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
# Utility function which tests if the given file exists and
# if so notifies the user and provides them the opportunity
# to abort the current command.
check_file_overwrite () {
    local file=$1
    if [ -e ${file} ]
    then
        echo "Output file, $file, exists and will be overwritten."
        echo "Do you wish to continue? (y/n)"
        read ans
        if [ ${ans} != "y" ]
        then
            echo "$command aborted by user."
            exit 1
        fi
    fi
357 358 359
}

### Functions used for dump
360 361 362 363 364 365 366

# Sets the global variable, dump_qry, to the schema-version specific
# SQL text needed to dump the lease data for the current backend
# and protocol
get_dump_query() {
    local version=$1

367 368
    case ${backend} in
    mysql)
369
        invoke="call"
370 371
        ;;
    pgsql)
372
        invoke="select * from"
373 374 375 376 377 378
        ;;
    *)
        log_error "unsupported backend ${backend}"
        usage
        exit 1
        ;;
379 380
    esac

381
    dump_qry="${invoke} lease${dump_type}DumpHeader();${invoke} lease${dump_type}DumpData();";
382 383 384 385 386 387 388 389 390
}

memfile_dump() {
    log_error "lease-dump is not supported for memfile"
    exit 1
}

mysql_dump() {

391
    # Check the lease type was given
392
    if [ $dump_type -eq 0 ]; then
393 394 395 396 397
        log_error "lease-dump: lease type ( -4 or -6 ) needs to be specified"
        usage
        exit 1
    fi

398 399 400 401 402 403 404 405 406 407 408 409 410
    # get the correct dump query
    version=`mysql_version`
    retcode=$?
    if [ $retcode -ne 0 ]
    then
        log_error "lease-dump: mysql_version failed, exit code $retcode"
        exit 1;
    fi

    # Fetch the correct SQL text. Note this function will exit
    # if it fails.
    get_dump_query $version

411 412 413 414 415 416 417 418
    # Make sure they specified a file
    if [ "$dump_file" = "" ]; then
        log_error "you must specify an output file for lease-dump"
        usage
        exit 1

    fi

419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
    # If output file exists, notify user, allow them a chance to bail
    check_file_overwrite $dump_file

    # Check the temp file too
    tmp_file="$dump_file.tmp"
    check_file_overwrite $tmp_file

    # Run the sql to output tab-delimited lease data to a temp file.
    # By using a temp file we can check for MySQL errors before using
    # 'tr' to translate tabs to commas.  We do not use MySQL's output
    # to file as that requires linux superuser privileges to execute
    # the select.
    mysql_execute "${dump_qry}" > $tmp_file
    retcode=$?
    if [ $retcode -ne 0 ]; then
        log_error "lease-dump: mysql_execute failed, exit code $retcode";
        exit 1
    fi
437

438 439 440 441
    # Now translate tabs to commas.
    cat $tmp_file | tr '\t' ',' >$dump_file
    if [ $? -ne 0 ]; then
        log_error "lease-dump: reformatting failed";
442 443 444
        exit 1
    fi

445 446
    # delete the tmp file on success
    rm $tmp_file
447 448 449 450 451 452
    echo lease$dump_type successfully dumped to $dump_file
    exit 0
}

### Functions used for dump
pgsql_dump() {
453
    # Check the lease type was given
Francis Dupont's avatar
Francis Dupont committed
454
    if [ $dump_type -eq 0 ]; then
455 456 457 458 459
        log_error "lease-dump: lease type ( -4 or -6 ) needs to be specified"
        usage
        exit 1
    fi

460
    version=`pgsql_version`
461
    get_dump_query $version
462 463 464 465 466 467 468 469 470

    # Make sure they specified a file
    if [ "$dump_file" = "" ]; then
        log_error "you must specify an output file for lease-dump"
        usage
        exit 1

    fi

471 472 473
    # If output file exists, notify user, allow them a chance to bail
    check_file_overwrite $dump_file

474 475 476 477 478
    # psql does not accept password as a parameter but will look in the environment
    export PGPASSWORD=$db_password

    # Call psql and redirect output to the dump file. We don't use psql "to csv"
    # as it can only be run as db superuser.
479
    echo "$dump_qry" | psql --set ON_ERROR_STOP=1 -t -h $db_host -q --user=$db_user --dbname=$db_name -w --no-align --field-separator=',' >$dump_file
480
    retcode=$?
481 482

    # Check for errors.
483 484
    if [ $retcode -ne 0 ]; then
        log_error "lease-dump: psql call failed, exit code: $retcode";
485 486 487 488 489 490
        exit 1
    fi

    echo lease$dump_type successfully dumped to $dump_file
    exit 0
}
491

Tomek Mrugalski's avatar
Tomek Mrugalski committed
492
cql_dump() {
493 494
    # Get the query appropriate to lease version. Explicitly specify all columns
    # so that they are returned in expected order.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
495
    if [ $dump_type -eq 4 ]; then
496
        dump_query="SELECT address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context FROM lease4"
Tomek Mrugalski's avatar
Tomek Mrugalski committed
497
    elif [ $dump_type -eq 6 ]; then
498
        dump_query="SELECT address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,hwtype,hwaddr_source,state,user_context FROM lease6"
499 500 501 502
    else
        log_error "lease-dump: lease type ( -4 or -6 ) needs to be specified"
        usage
        exit 1
Tomek Mrugalski's avatar
Tomek Mrugalski committed
503
    fi
504

505
    # Check if file was specified.
506
    if [ "$dump_file" = "" ]; then
507
        log_error "lease-dump: output file needs to be specified with -o"
508 509 510 511
        usage
        exit 1
    fi

512
    # If output file exists, notify user, allow them a chance to bail.
513 514
    check_file_overwrite $dump_file

515 516 517 518 519
    # Run query, check for failure.
    result=`cql_execute "$dump_query"`
    return_code=$?
    if [ $return_code -ne 0 ]; then
        log_error "lease-dump: cql_execute failed, exit code $return_code";
520 521 522
        exit 1
    fi

523
    # Parse and display header.
524
    echo "$result" | head -n 2 | tail -n 1 | sed -e 's/[[:space:]]*//g' | sed -e 's/|/,/g' > $dump_file
525 526

    # Parse and display contents - done separately from header to allow sorting
527 528
    # by address. awk script replaces head -n -2 which is not portable.
    echo "$result" | tail -n +4 | awk 'n>=2 { print a[n%2] } { a[n%2]=$0; n=n+1 }' | sed -e 's/[[:space:]]*//g' | sed -e 's/|/,/g' | sort -r >> $dump_file
529 530

    echo lease$dump_type successfully dumped to $dump_file
Razvan Becheriu's avatar
Razvan Becheriu committed
531
    exit 0
532 533
}

534 535
### Script starts here ###

536
# First, find what the command is
537 538 539 540 541 542
command=${1}
if [ -z ${command} ]; then
    log_error "missing command"
    usage
    exit 1
fi
543 544 545 546 547 548 549

# Check if this is a simple question about version.
if test "${command}" = "-v" || test "${command}" = "--version" ; then
    echo "${VERSION}"
    exit 0
fi

550
is_in_list "${command}" "lease-init lease-version lease-upgrade lease-dump"
551 552 553 554 555 556
if [ ${_inlist} -eq 0 ]; then
    log_error "invalid command: ${command}"
    exit 1
fi
shift

557
# Second, check what's the backend
558 559 560 561 562 563
backend=${1}
if [ -z ${backend} ]; then
    log_error "missing backend"
    usage
    exit 1
fi
Tomek Mrugalski's avatar
Tomek Mrugalski committed
564
is_in_list "${backend}" "memfile mysql pgsql cql"
565 566 567 568 569 570 571 572 573 574 575
if [ ${_inlist} -eq 0 ]; then
    log_error "invalid backend: ${backend}"
    exit 1
fi
shift

# Ok, let's process parameters (if there are any)
while [ ! -z "${1}" ]
do
    option=${1}
    case ${option} in
576 577 578 579 580 581 582 583 584 585
        # Specify database host
        -h|--host)
            shift
            db_host=${1}
            if [ -z ${db_host} ]; then
                log_error "-h or --host requires a parameter"
                usage
                exit 1
            fi
            ;;
586 587 588 589 590 591 592 593 594 595 596 597 598
        # Specify database user
        -u|--user)
            shift
            db_user=${1}
            if [ -z ${db_user} ]; then
                log_error "-u or --user requires a parameter"
                usage
                exit 1
            fi
            ;;
        # Specify database password
        -p|--password)
            shift
599 600
            db_password=${1}
            if [ -z ${db_password} ]; then
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
                log_error "-p or --password requires a parameter"
                usage
                exit 1
            fi
            ;;
        # Specify database name
        -n|--name)
            shift
            db_name=${1}
            if [ -z ${db_name} ]; then
                log_error "-n or --name requires a parameter"
                usage
                exit 1
            fi
            ;;
        -d|--directory)
            shift
            scripts_dir=${1}
            if [ -z ${scripts_dir} ]; then
                log_error "-d or --directory requires a parameter"
                usage
                exit 1
            fi
            ;;
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
        # specify DHCPv4 lease type
        -4)
            if [ $dump_type -eq 6 ]; then
                log_error "you may not specify both -4 and -6"
                usage
                exit 1
            fi
            dump_type=4
            ;;
        # specify DHCPv6 lease type
        -6)
            if [ $dump_type -eq 4 ]; then
                log_error "you may not specify both -4 and -6"
                usage
                exit 1
            fi
            dump_type=6
            ;;
        # specify output file, currently only used by lease dump
        -o|--output)
            shift
            dump_file=${1}
            if [ -z ${dump_file} ]; then
                log_error "-o or --output requires a parameter"
                usage
                exit 1
            fi
            ;;
653 654 655 656 657 658 659 660 661 662
        *)
            log_error "invalid option: ${option}"
            usage
            exit 1
    esac
    shift
done

case ${command} in
    # Initialize the database
663
    lease-init)
664 665
        case ${backend} in
            memfile)
666
                memfile_init
667 668
                ;;
            mysql)
669
                mysql_init
670 671
                ;;
            pgsql)
672
                pgsql_init
673
                ;;
Tomek Mrugalski's avatar
Tomek Mrugalski committed
674 675
            cql)
                cql_init
676
                ;;
677 678
            esac
        ;;
679
    lease-version)
680 681
        case ${backend} in
            memfile)
682
                memfile_version
683 684
                ;;
            mysql)
685
                mysql_version
686
                printf "\n"
687 688
                ;;
            pgsql)
689
                pgsql_version
690
                ;;
Tomek Mrugalski's avatar
Tomek Mrugalski committed
691 692
            cql)
                cql_version
693
                ;;
694 695
            esac
        ;;
696
    lease-upgrade)
697 698
        case ${backend} in
            memfile)
699
                memfile_upgrade
700 701
                ;;
            mysql)
702
                mysql_upgrade
703 704
                ;;
            pgsql)
705
                pgsql_upgrade
706
                ;;
Tomek Mrugalski's avatar
Tomek Mrugalski committed
707 708
            cql)
                cql_upgrade
709
                ;;
710 711
            esac
        ;;
712 713 714 715 716 717 718 719 720 721 722
    lease-dump)
        case ${backend} in
            memfile)
                memfile_dump
                ;;
            mysql)
                mysql_dump
                ;;
            pgsql)
                pgsql_dump
                ;;
Tomek Mrugalski's avatar
Tomek Mrugalski committed
723 724
            cql)
                cql_dump
725
                ;;
726 727
            esac
        ;;
728 729 730
esac

exit 0