Revision 87d1bf2e snf-image-host/common.sh.in

b/snf-image-host/common.sh.in
27 27

  
28 28
network_backend_support="@network_backend_support@"
29 29

  
30
# Use file descriptors in the range 3-9. File descriptors below 3 are used for
31
# standard input, output, and error, the ones above 9 may be used by the shell
32
# internally.
33
MONITOR_FD=9
34

  
35 30
ERROR_TYPE="ganeti-error"
36 31

  
37 32
CLEANUP=( )
......
50 45

  
51 46
close_fd() {
52 47
    local fd="$1"
53
    eval "exec $fd>&-"
48
    exec {fd}>&-
54 49
}
55 50

  
56 51
report_error() {
57 52
    local error_file=$1
53
    local monitor_fd=$2
58 54

  
59
    local id=$(sed 's/"/\\"/g' <<< "$INSTANCE_NAME")
60 55
    local type="$ERROR_TYPE"
61 56
    local location="host"
62 57

  
......
72 67

  
73 68
    local stderr="$(cat "$error_file" | sed 's/"/\\"/g')"
74 69

  
75
    report="{\"id\":\"$id\","
76
    report+="\"type\":\"$type\"," \
77
    report+="\"timestamp\":$(date +%s.%N)," \
78
    report+="\"location\":\"$location\"," \
79
    report+="\"messages\":$msg," \
70
    report="\"type\":\"$type\","
71
    report+="\"timestamp\":$(date +%s.%N),"
72
    report+="\"location\":\"$location\","
73
    report+="\"messages\":$msg,"
80 74
    report+="\"stderr\":\"$stderr\"}"
81 75

  
82
    eval "echo $(printf "%q" "$report") >&${MONITOR_FD}"
76
    eval "echo $(printf "%q" "$report") >&${monitor_fd}"
83 77
}
84 78

  
85 79
get_api5_arguments() {
......
331 325
report_and_cleanup(){
332 326

  
333 327
    local err_file="$1"
328
    local fd="$2"
334 329

  
335
    report_error "$err_file"
330
    report_error "$err_file" "$fd"
336 331
    cleanup
337 332
}
338 333

  

Also available in: Unified diff