blob: 3a9ce06cf12c2f391e4e4e43794e2a8c0e7bb2e2 (
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
|
#!/bin/sh
#
# Copyright 2014-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
### BEGIN INIT INFO
# Provides: power-on
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Power on Server
### END INIT INFO
. /usr/local/fbpackages/utils/ast-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
# Disable Watch Dog Timer
/usr/local/bin/watchdog_ctrl.sh off
KEYDIR=/mnt/data/kv_store
DEF_PWR_ON=1
TO_PWR_ON=
check_por_config()
{
TO_PWR_ON=-1
# Check if the file/key doesn't exist
if [ ! -f "${KEYDIR}/slot${1}_por_cfg" ]; then
TO_PWR_ON=$DEF_PWR_ON
else
POR=`cat ${KEYDIR}/slot${1}_por_cfg`
# Case ON
if [ $POR == "on" ]; then
TO_PWR_ON=1;
# Case OFF
elif [ $POR == "off" ]; then
TO_PWR_ON=0;
# Case LPS
elif [ $POR == "lps" ]; then
# Check if the file/key doesn't exist
if [ ! -f "${KEYDIR}/pwr_server${1}_last_state" ]; then
TO_PWR_ON=$DEF_PWR_ON
else
LS=`cat ${KEYDIR}/pwr_server${1}_last_state`
if [ $LS == "on" ]; then
TO_PWR_ON=1;
elif [ $LS == "off" ]; then
TO_PWR_ON=0;
fi
fi
fi
fi
}
# Check whether it is fresh power on reset
if [ $(is_bmc_por) -eq 1 ]; then
check_por_config 1
if [ $TO_PWR_ON -eq 1 ] && [ $(is_server_prsnt 1) == "1" ] ; then
power-util slot1 on
fi
check_por_config 2
if [ $TO_PWR_ON -eq 1 ] && [ $(is_server_prsnt 2) == "1" ] ; then
power-util slot2 on
fi
check_por_config 3
if [ $TO_PWR_ON -eq 1 ] && [ $(is_server_prsnt 3) == "1" ] ; then
power-util slot3 on
fi
check_por_config 4
if [ $TO_PWR_ON -eq 1 ] && [ $(is_server_prsnt 4) == "1" ] ; then
power-util slot4 on
fi
fi
|