commit 61c6a03d627b832e1b5dbdf472b48f41fc0522f4 Author: Ryan McCabe rmccabe@redhat.com Date: Sat Aug 20 14:41:35 2011 -0400
Change calls to 'echo' to $ECHOFUNC for the database backup and restore functionality added to the init script
input_files/initscript/initscript.in | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) --- diff --git a/input_files/initscript/initscript.in b/input_files/initscript/initscript.in index 135e5e1..414d8c5 100755 --- a/input_files/initscript/initscript.in +++ b/input_files/initscript/initscript.in @@ -291,20 +291,20 @@ dump_database() {
if [ -e "$output_file" ]; then if [ "$2" != "--force" ] && [ "$2" != "-f" ]; then - echo "A file named `$output_file' already exists. Pass the additional argument of --force to overwrite it." >&2 + $ECHOFUNC "A file named `$output_file' already exists. Pass the additional argument of --force to overwrite it." >&2 return 1 fi fi $sqlite_bin "$DB_FILE" '.dump' > "$output_file" if [ $? -ne 0 ]; then - echo "Failed to create `$output_file' properly." >&2 + $ECHOFUNC "Failed to create `$output_file' properly." >&2 rm -f -- "$output_file" return 1 fi chown $DAEMON_USER:$DAEMON_GROUP "$output_file" \ && chmod -- $BACKUP_PERMS "$output_file" if [ $? -ne 0 ]; then - echo "Unable to change ownership/attributes of the $PKG_NAME database backup file (`$output_file')." >&2 + $ECHOFUNC "Unable to change ownership/attributes of the $PKG_NAME database backup file (`$output_file')." >&2 rm -f -- "$output_file" >&/dev/null return 1 fi @@ -315,32 +315,32 @@ dump_database() { load_database() { db_dump_file=$1 if [ ! "$db_dump_file" ]; then - echo "No database backup file was specified. Run `$0 list-backups' to get a list of known existing backup files." >&2 + $ECHOFUNC "No database backup file was specified. Run `$0 list-backups' to get a list of known existing backup files." >&2 return 1 fi
if [ ! -r "$db_dump_file" ]; then - echo "The database backup in `$db_dump_file' cannot be read." >&2 + $ECHOFUNC "The database backup in `$db_dump_file' cannot be read." >&2 return 1 fi
tmp_db="$(mktemp --tmpdir=$DB_DIR)" if [ $? -ne 0 ]; then - echo "Unable to create a temporary file in `$DB_DIR'." >&2 + $ECHOFUNC "Unable to create a temporary file in `$DB_DIR'." >&2 return 1 fi $sqlite_bin $tmp_db ".read $db_dump_file" if [ $? -ne 0 ] || [ ! -s "$tmp_db" ]; then # sqlite will return 0 even if you feed it non-sql input. In the case # of bad input, the database file will have size 0. - echo "Unable to restore the database from the backup file `$db_dump_file'" >&2 + $ECHOFUNC "Unable to restore the database from the backup file `$db_dump_file'" >&2 rm -f -- "$tmp_db" >&/dev/null return 1 fi chown $DAEMON_USER:$DAEMON_GROUP "$tmp_db" \ && chmod -- $DB_PERMS "$tmp_db" if [ $? -ne 0 ]; then - echo "Unable to change ownership/attributes of the $PKG_NAME database file (`$tmp_db')." >&2 + $ECHOFUNC "Unable to change ownership/attributes of the $PKG_NAME database file (`$tmp_db')." >&2 rm -f -- "$tmp_db" >&/dev/null return 1 fi @@ -357,7 +357,7 @@ load_database() { mv -n -- "$DB_FILE" "$old_db_name" if [ $? -ne 0 ]; then # it appeared out of nowhere - echo "Unable to move the existing database file to `$old_db_name'." >&2 + $ECHOFUNC "Unable to move the existing database file to `$old_db_name'." >&2 rm -f -- "$tmp_db" >&/dev/null return 1 fi @@ -368,10 +368,10 @@ load_database() { if [ $? -ne 0 ]; then rm -f -- "$tmp_db" >&/dev/null if [ $old_exists -eq 1 ]; then - echo "Unable to move the newly created database file to `$DB_FILE'. Trying to restore database from `$old_db_name'." >&2 + $ECHOFUNC "Unable to move the newly created database file to `$DB_FILE'. Trying to restore database from `$old_db_name'." >&2 mv -- "$old_db_name" "$DB_FILE" else - echo "Unable to move the newly created database file to `$DB_FILE'." >&2 + $ECHOFUNC "Unable to move the newly created database file to `$DB_FILE'." >&2 fi ret_code=1 fi @@ -492,7 +492,7 @@ case "$1" in entry_check || exit 4 status &>/dev/null if [ $? -eq 0 ]; then - echo "The database backup operation can proceed only when @SERVICENAME@ is stopped. Stop @SERVICENAME@, then try again." >&2 + $ECHOFUNC "The database backup operation can proceed only when @SERVICENAME@ is stopped. Stop @SERVICENAME@, then try again." >&2 exit 1 fi shift @@ -503,7 +503,7 @@ case "$1" in entry_check || exit 4 status &>/dev/null if [ $? -eq 0 ]; then - echo "The database restore operation can proceed only when @SERVICENAME@ is stopped. Stop @SERVICENAME@, then try again." >&2 + $ECHOFUNC "The database restore operation can proceed only when @SERVICENAME@ is stopped. Stop @SERVICENAME@, then try again." >&2 exit 1 fi shift
luci-commits@lists.fedorahosted.org