File: ver-rc1.sh

package info (click to toggle)
mdevctl 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,072 kB
  • sloc: sh: 731; makefile: 74
file content (127 lines) | stat: -rwxr-xr-x 4,318 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
124
125
126
127
#!/bin/sh
# A basic utility script used for debugging versioning of call-out scripts
# in mdevctl. Output can be observed via system logs.

#stdin | -t type -e event -a action -s state -u uuid -p parent
shift
type=$1
shift 2
event=$1
shift 2
action=$1
shift 2
state=$1
shift 2
uuid=$1
shift 2
parent=$1
json=$(cat)

print_supported_version() {
    case "$1" in
        11111111-1111-0000-0000-000000000000)
            # full version 2 and RC=0
            echo "{\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 0
        ;;
        11111111-1111-0000-0000-111111111111)
            # valid json with RC=1
            echo "{\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 1
        ;;
        11111111-1111-0000-0000-111111111111)
            # valid json with RC=2
            echo "{\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 2
        ;;
        11111111-1111-0000-0000-aaaaaaaaaaaa)
            # no json output at all
            echo "This output is bad"
            exit 0
        ;;
        11111111-1111-0000-0000-bbbbbbbbbbbb)
            # extra action dummy
            echo "{\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\",\"dummy\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 0
        ;;
        11111111-1111-0000-0000-cccccccccccc)
            # extra event dummy
            echo "{\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\",\"dummy\"]"
            echo "}}"
            exit 0
        ;;
        11111111-1111-0000-0000-dddddddddddd)
            # action modify missing
            echo "{\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 0
        ;;
        11111111-1111-0000-0000-eeeeeeeeeeee)
            # extra valid data contained
            echo "{\"provides\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "},\"supports\":{"
            echo "\"version\":2,"
            echo "\"actions\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"events\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 0
        ;;
        11111111-1111-0000-0000-ffffffffffff)
            # invalid json
            echo "{\"supports\":{{{"
            echo "\"version\":111111,"
            echo "\"actors\":[\"start\",\"stop\",\"define\",\"undefine\",\"modify\",\"attributes\",\"capabilities\"],"
            echo "\"inventors\":[\"pre\",\"post\",\"notify\",\"get\"]"
            echo "}}"
            exit 0
        ;;
        *)
            exit 1
        ;;
    esac
}

case "$event" in
    get)
        case "$action" in
            capabilities)
                print_supported_version $uuid
            ;;
            attributes)
                echo "[{\"attribute0\": \"VALUE\"}]"
                exit 0
            ;;
            *)
                exit 1
            ;;
        esac
    ;;
    *)
        exit 1
    ;;
esac