summaryrefslogtreecommitdiff
path: root/meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc
blob: f6fa3c4e4a4330321195850b1b82d1e85a65b19a (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
HOST_DEFAULT_TARGETS = " \
    multi-user.target.requires/obmc-host-reset@{}.target \
    multi-user.target.wants/phosphor-discover-system-state@{}.service \
    obmc-host-start@{}.target.requires/obmc-host-startmin@{}.target \
    obmc-host-start@{}.target.requires/phosphor-reset-host-reboot-attempts@{}.service \
    obmc-host-startmin@{}.target.wants/phosphor-set-host-transition-to-running@{}.service \
    obmc-host-stop@{}.target.wants/phosphor-set-host-transition-to-off@{}.service \
    obmc-host-reset@{}.target.requires/phosphor-reset-host-running@{}.service \
    obmc-host-stop@{}.target.wants/phosphor-reset-sensor-states@{}.service \
    obmc-host-shutdown@{}.target.requires/obmc-host-stop@{}.target \
    obmc-host-graceful-quiesce@{}.target.wants/obmc-host-quiesce@{}.target \
    obmc-host-graceful-quiesce@{}.target.wants/pldmSoftPowerOff.service \
    obmc-host-quiesce@{}.target.wants/phosphor-reset-sensor-states@{}.service \
    obmc-host-reboot@{}.target.requires/obmc-host-shutdown@{}.target \
    obmc-host-reboot@{}.target.requires/phosphor-reboot-host@{}.service \
    obmc-host-warm-reboot@{}.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service \
    obmc-host-force-warm-reboot@{}.target.requires/obmc-host-stop@{}.target \
    obmc-host-force-warm-reboot@{}.target.requires/phosphor-reboot-host@{}.service \
    obmc-host-warm-reboot@{}.target.requires/obmc-host-force-warm-reboot@{}.target \
"

CHASSIS_DEFAULT_TARGETS = " \
    obmc-chassis-poweron@{}.target.wants/phosphor-reset-host-recovery@{}.service \
    obmc-chassis-poweron@{}.target.requires/obmc-power-start@{}.service \
    obmc-chassis-poweron@{}.target.requires/phosphor-set-chassis-transition-to-on@{}.service \
    obmc-host-shutdown@{}.target.requires/obmc-chassis-poweroff@{}.target \
    obmc-chassis-poweroff@{}.target.requires/obmc-power-stop@{}.service \
    obmc-chassis-poweroff@{}.target.requires/obmc-powered-off@{}.service \
    obmc-chassis-poweroff@{}.target.wants/phosphor-clear-one-time@{}.service \
    obmc-chassis-poweroff@{}.target.requires/phosphor-set-chassis-transition-to-off@{}.service \
    obmc-chassis-blackout@{}.target.wants/phosphor-reset-sensor-states@{}.service \
    obmc-chassis-powerreset@{}.target.requires/phosphor-reset-chassis-on@{}.service \
    obmc-chassis-powerreset@{}.target.requires/phosphor-reset-chassis-running@{}.service \
"

# TODO: There are some targets that are chassis oriented, but there is no
#       obvious way to map HOST<->CHASSIS relationships.  Making an assumption
#       currently that there is a 1-to-1 relationship between the two.

pkg_postinst:${PN}-obmc-targets:append() {
    for i in ${OBMC_HOST_INSTANCES};
    do
        for j in ${HOST_DEFAULT_TARGETS};
        do
            LINK="$D$systemd_system_unitdir/${j}"
            LINK="$(echo ${LINK} | sed s/{}/${i}/g )"
            TARGET="../$(basename ${j} | sed s/{}//g )"
            mkdir -p "$(dirname ${LINK})"
            ln -s "${TARGET}" "${LINK}"
        done
    done

    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        for j in ${CHASSIS_DEFAULT_TARGETS};
        do
            LINK="$D$systemd_system_unitdir/${j}"
            LINK="$(echo ${LINK} | sed s/{}/${i}/g )"
            TARGET="../$(basename ${j} | sed s/{}//g )"
            mkdir -p "$(dirname ${LINK})"
            ln -s "${TARGET}" "${LINK}"
        done
    done
}

pkg_prerm:${PN}-obmc-targets:append() {
    for i in ${OBMC_HOST_INSTANCES};
    do
        for j in ${HOST_DEFAULT_TARGETS};
        do
            LINK="$D$systemd_system_unitdir/${j}"
            LINK="$(echo ${LINK} | sed s/{}/${i}/g )"
            rm "${LINK}"
        done
    done

    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        for j in ${CHASSIS_DEFAULT_TARGETS};
        do
            LINK="$D$systemd_system_unitdir/${j}"
            LINK="$(echo ${LINK} | sed s/{}/${i}/g )"
            rm "${LINK}"
        done
    done
}

pkg_postinst:${PN}-chassis:append() {
    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        mkdir -p $D$systemd_system_unitdir/multi-user.target.requires
        LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Chassis@${i}.service"
        TARGET="../xyz.openbmc_project.State.Chassis@.service"
        ln -s $TARGET $LINK
    done
}

pkg_prerm:${PN}-chassis:append() {
    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Chassis@${i}.service"
        rm $LINK
    done
}

pkg_postinst:${PN}-chassis-check-power-status:append() {
    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        mkdir -p $D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.requires
        LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.requires/phosphor-chassis-check-power-status@${i}.service"
        TARGET="../phosphor-chassis-check-power-status@.service"
        ln -s $TARGET $LINK
    done
}

pkg_prerm:${PN}-chassis-check-power-status:append() {
    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.requires/phosphor-chassis-check-power-status@${i}.service"
        rm $LINK
    done
}

pkg_postinst:${PN}-chassis-poweron-log:append() {
    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        mkdir -p $D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.wants
        LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.wants/phosphor-create-chassis-poweron-log@${i}.service"
        TARGET="../phosphor-create-chassis-poweron-log@.service"
        ln -s $TARGET $LINK
    done
}

pkg_prerm:${PN}-chassis-poweron-log:append() {
    for i in ${OBMC_CHASSIS_INSTANCES};
    do
        LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.wants/phosphor-create-chassis-poweron-log@${i}.service"
        rm $LINK
    done
}

pkg_postinst:${PN}-host:append() {
    for i in ${OBMC_HOST_INSTANCES};
    do
        mkdir -p $D$systemd_system_unitdir/multi-user.target.requires
        LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Host@${i}.service"
        TARGET="../xyz.openbmc_project.State.Host@.service"
        ln -s $TARGET $LINK

        if ${@bb.utils.contains('PACKAGECONFIG', 'host-gpio', 'true', 'false', d)}
        then
            LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-host-condition-gpio@${i}.service"
            TARGET="../phosphor-host-condition-gpio@.service"
            ln -s $TARGET $LINK
        fi
    done
}

pkg_prerm:${PN}-host:append() {
    for i in ${OBMC_HOST_INSTANCES};
    do
        LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Host@${i}.service"
        rm $LINK
    done
}

pkg_postinst:${PN}-scheduled-host-transition:append() {
    for i in ${OBMC_HOST_INSTANCES};
    do
        mkdir -p $D$systemd_system_unitdir/multi-user.target.wants
        LINK="$D$systemd_system_unitdir/multi-user.target.wants/xyz.openbmc_project.State.ScheduledHostTransition@${i}.service"
        TARGET="../xyz.openbmc_project.State.ScheduledHostTransition@.service"
        ln -s $TARGET $LINK
    done
}

pkg_prerm:${PN}-scheduled-host-transition:append() {
    for i in ${OBMC_HOST_INSTANCES};
    do
        LINK="$D$systemd_system_unitdir/multi-user.target.wants/xyz.openbmc_project.State.ScheduledHostTransition@${i}.service"
        rm $LINK
    done
}