#!/bin/sh # ---------------------------------------------------------------------------- # /var/install/bin/bcclient-helpers.sh # # Creation: 2009-09-19 starwarsfan # Last Update: $Id$ # # Copyright (c) 2009 Yves Schumann <yves(at)eisfair(dot)org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ---------------------------------------------------------------------------- #exec 2> /tmp/bcclient-helpers-trace$$.log #set -x COLOR_RED='\033[1;31m' COLOR_NRM='\033[0;39m' # ---------------------------------------------------------------------------- # Write a message on the right border of the console # Known messages: # - no parameter: [ Done ] # - first parameter 'true': [ OK ] # - first parameter 'false': [ Failed ] # ---------------------------------------------------------------------------- actionFinished () { if [ $# -eq 0 ] then echo -e "\033[300C\033[$[9]D [ Done ]" elif [ $1 == true ] then echo -e "\033[300C\033[$[7]D [ OK ]" else echo -e "\033[300C\033[$[11]D [ ${COLOR_RED}Failed${COLOR_NRM} ]" fi } # ---------------------------------------------------------------------------- # Check if directory for configuration files exists and create it if not # ---------------------------------------------------------------------------- checkConfigurationDirectory () { # ------------------------------------ # Check the directory for config files if [ ! -d /etc/bacula ] then mecho -n 'Directory for configuration files not found, creating it... ' mkdir /etc/bacula actionFinished fi } # ---------------------------------------------------------------------------- # Cleanup configuration directory # Parameters: # $1 .. The prefix for the files to delete e. g. 'job-' or 'schedule-' # ---------------------------------------------------------------------------- cleanupConfigurationDirectory () { # ------------------------------------------------ # The prefix for the files to delete must be given if [ $# -eq 1 -a -d /etc/bacula ] then rm -f /etc/bacula/${1}* fi }