forked from wballard/starphleet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
starphleet-status
executable file
·82 lines (75 loc) · 1.79 KB
/
starphleet-status
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
#!/usr/bin/env starphleet-launcher
### Usage:
### starphleet-status [<service_name>]
### --help
###
### Dump out handy statistics about your ship
##ssl stats
SSL_EXPIRATION=$(openssl x509 -noout -in ${STARPHLEET_ROOT:-/var/starphleet}/nginx/crt -dates | head -1 | awk 'BEGIN { FS = "=" } ; { print $2 }')
STARPHLEET_DEV_DIR=/hosthome/starphleet_dev
cat << EOF
hostname: $(hostname)
ssl_expiration: ${SSL_EXPIRATION}
EOF
cat << EOF
headquarters: ${HEADQUARTERS_REMOTE:-no headquarters}
EOF
##starphleet service processes
cat << EOF
services:
EOF
IFS=$'\n'
if [ -n "${service_name}" ]; then
FILTER="${service_name}"
else
FILTER="starphleet"
fi
for service in $(initctl list | grep ${FILTER} | sort)
do
cat << EOF
- ${service}
EOF
done
unset IFS
### ORDERS status starts here
if [ -d "${CURRENT_ORDERS}" ]; then
cat << EOF
orders:
EOF
if [ -n "${service_name}" ]; then
FILTER="${service_name}"
else
FILTER="starphleetstatus"
fi
for status in $(find "${CURRENT_ORDERS}" | grep 'starphleetstatus$' | grep ${FILTER})
do
if dev_mode; then
ORDER_LOCAL="${STARPHLEET_DEV_DIR}/${ORDER}"
else
ORDER_LOCAL=$(dirname "${status}")/git
fi
if [ -f $(dirname "${status}")/.container ]; then
CONTAINER=$(cat $(dirname "${status}")/.container)
else
CONTAINER="<none>"
fi
ORDER="$(dirname ${status} | sed -e "s[${CURRENT_ORDERS}/\?[[")"
LOCAL_IP=$([ -f "${status}.ip" ] && cat "${status}.ip")
get_CURRENT_SHA "${ORDER_LOCAL}"
cd "${ORDER_LOCAL}"
AUTHOR=$(git log -1 --format='%ae')
TEXT=$(git log -1 --format='%s')
cat << EOF
-
order: ${ORDER}
container: ${CONTAINER}
local_ip: ${LOCAL_IP}
sha: ${CURRENT_SHA}
author: ${AUTHOR}
text: >
${TEXT}
status: $(cat "${status}")
EOF
done
### ORDERS status ends here
fi