#!/bin/sh

alterator_api_version=1

. bacula-client-sh-functions
. bacula-sh-functions

. alterator-sh-functions

. shell-quote

on_message()
{
	case "$in_action" in
		read)
		    #local director_name="$(bacula_director_get_name)"
		    local director_name="$(bacula_file_get_director)"
		    local passphrase="$(bacula_file_get_password)"

		    write_string_param passphrase "$passphrase"
		    write_string_param director_name "$director_name"
		    ;;
		write)
		    if [ -z $in_director_name ]; then
			    write_error "`_ "Empty director name"`"
			    return
		    else bacula_file_set_director "$in_director_name"
		    fi
		    if [ -n "$in_passphrase" ]; then
			    bacula_file_set_password "$in_passphrase"
		    else write_error "`_ "Empty password"`"
		    fi
		;;
	esac
}

message_loop

