This file is indexed.

/etc/maas/templates/power/moonshot.template is in maas-cluster-controller 1.5.4+bzr2294-0ubuntu1.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
# -*- mode: shell-script -*-
#
# Control a system via ipmipower
#

# Parameters.
power_change={{power_change}}
power_hwaddress={{power_hwaddress}}
power_address={{power_address}}
power_user={{power_user}}
power_pass={{power_pass}}
ipmitool={{ipmitool}}

# Determines the power command needed to execute the desired
# action. This function receives ${power_change} as argument.
formulate_power_command() {
    case $1 in
    'on') echo 'on' ;;
    'off') echo 'off' ;;
    *)
        echo "Got unknown power state from ipmipower: '$1'" >&2
        exit 1
    esac
}

# Determines the current state on which the machine finds itself.
# The argument passed comes from IPMI's stat command in the form:
# <ipmi-ip-address>: <on/off>
# This function evaluates whether it was <on/off>.
formulate_power_state() {
    case $4 in
    'on') echo 'on' ;;
    'off') echo 'off' ;;
    *)
        echo "Got unknown power state from ipmipower: '$2'" >&2
        exit 1
    esac
}

# Issue command to ipmipower, for the given system.
issue_ipmitool_command() {
    ${ipmitool} -I lanplus -H ${power_address} -U ${power_user} -P ${power_pass} ${power_hwaddress} power "$@"
}


# Get the given system's power state: 'on' or 'off'.
get_power_state() {
    ipmi_state=$(issue_ipmitool_command status)
    formulate_power_state ${ipmi_state}
}


if [ "$(get_power_state)" != "${power_change}" ]
then
    power_command=$(formulate_power_command ${power_change})
    issue_ipmitool_command ${power_command}
fi