-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreboot-all
74 lines (61 loc) · 1.46 KB
/
reboot-all
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
#!/usr/bin/env bash
#
# Synopsis:
# Cron script to fully reboot all blob process @reboot cron schedule
# Usage:
# # in crontab
# BLOBIO_ROOT=/usr/local/blobio
# LOG=$BLOBIO_ROOT/log/reboot-blobio.log
#
# @reboot $BLOBIO_ROOTsbin/reboot-blobio >>$LOG 2>&1
# Note:
# inexact zapping of flowd process by zap-proc when the file
# run/flowd.pid is missing.
#
PROG=$(basename $0)
FLOWD_PAUSE=4
PKILL_PAUSE=4
log()
{
echo "$(date +'%Y/%m/%d %H:%M:%S'): $PROG#$$: $@"
}
die()
{
log "ERROR: $@" >&2
exit 1
}
leave()
{
log 'good bye, cruel world'
}
test $# = 0 || die "wrong argument count: got $#, need 0"
log 'hello, world'
trap leave EXIT
test -n "$BLOBIO_ROOT" || die "environment variable not defined: BLOBIO_ROOT"
log "BLOBIO_ROOT=$BLOBIO_ROOT"
cd $BLOBIO_ROOT || die "cd $BLOBIO_ROOT failed"
. etc/profile
log 'calling bio4d_ctl restart bio4d ...'
bio4d_ctl restart || die "bio4d_ctl restart failed: exit status=$?"
log 'bio4d_ctl restart ok'
FLOW_PATH=$(find-etc-flow-path)
STATUS=$?
case $STATUS in
0)
log "etc flow: $FLOW_PATH"
;;
1)
die 'missing etc flow file'
;;
*)
die "find-etc-flow-path failed: exit status=$STATUS"
;;
esac
log 'starting flowd server in background ...'
flowd server $FLOW_PATH &
log "pausing $FLOWD_PAUSE sec while flowd starts ..."
sleep $FLOWD_PAUSE
test -e run/flowd.pid || die "flowd failed to start in background"
log "flowd pid: $(cat run/flowd.pid)"
reboot-sync-remote || die "reboot-sync-remote failed: exit status=$?"
exec run-stat-report