-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot-completed.sh
More file actions
executable file
·39 lines (33 loc) · 1.29 KB
/
Copy pathboot-completed.sh
File metadata and controls
executable file
·39 lines (33 loc) · 1.29 KB
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
#!/system/bin/sh
MODDIR=${0%/*}
CONTROL="$MODDIR/bin/control.sh"
[ -x "$CONTROL" ] || exit 0
# A watchdog cannot survive a reboot. Recover any still-pending change before
# considering the separately opt-in, previously confirmed boot selection.
settings=$("$CONTROL" settings 2>/dev/null) || exit 0
pending=$(printf '%s\n' "$settings" \
| sed -n 's/.*"pendingToken":"\([0-9a-fA-F][0-9a-fA-F]*\)".*/\1/p' \
| head -n 1)
if [ "${#pending}" -eq 32 ]; then
"$CONTROL" rollback "$pending" >/dev/null 2>&1 || {
"$CONTROL" set-reapply off >/dev/null 2>&1 || true
exit 0
}
settings=$("$CONTROL" settings 2>/dev/null) || exit 0
fi
case "$settings" in *'"reapply":true'*) ;; *) exit 0 ;; esac
case "$settings" in *'"applied":true'*) ;; *) exit 0 ;; esac
# Telephony can become ready shortly after the boot-completed hook. Retry a
# bounded number of times; a final failure disables reapply to avoid boot loops.
attempt=1
while [ "$attempt" -le 3 ]; do
if OPBAND_INTERNAL=1 "$CONTROL" __boot-reapply >/dev/null 2>&1; then
exit 0
fi
[ "$attempt" -eq 3 ] || sleep 6
attempt=$((attempt + 1))
done
"$CONTROL" set-reapply off >/dev/null 2>&1 || true
command -v logger >/dev/null 2>&1 \
&& logger -t opband-control 'Boot reapply failed and was disabled' 2>/dev/null
exit 0