-
Notifications
You must be signed in to change notification settings - Fork 40
/
auto_delegate.sh
executable file
·59 lines (47 loc) · 1.2 KB
/
auto_delegate.sh
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
#!/bin/bash
usage() {
echo "Usage: $0 -p [file]" 1>&2
exit 1
}
while getopts ":p:" option; do
case "${option}" in
p)
p=${OPTARG}
if [[ ! -f "$p" ]]; then
usage
fi
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [[ -z "${p}" ]]; then
usage
fi
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
PROFILE_PATH="${p}"
LOG_PATH="${SCRIPT_DIR}/auto_delegate.log"
source ${PROFILE_PATH}
if [[ -z "$TX_PASSWD_CONFIRMATIONS" ]]; then
TX_PASSWD_CONFIRMATIONS=1
fi
if [[ -z "$TX_PASSWD_PRHASE" ]]; then
TX_PASSWD_PRHASE="Enter keyring passphrase:"
fi
if [[ -z "$SLEEPING_TIME" ]]; then
SLEEPING_TIME=$((5*60))
fi
echo "Last running: $(date)" > "${LOG_PATH}"
echo "Log: ${LOG_PATH}"
while :
do
if [[ "$KEYRING_BACKEND" = "test" || "$KEYRING_BACKEND" = "memory" ]]; then
${SCRIPT_DIR}/delegate.sh "${PROFILE_PATH}" >> "${LOG_PATH}" 2>&1
else
${SCRIPT_DIR}/delegate.exp "${PROFILE_PATH}" "${PASSWD}" "${TX_PASSWD_CONFIRMATIONS}" "${TX_PASSWD_PRHASE}" >> "${LOG_PATH}" 2>&1
fi
echo "------ SLEEP ${SLEEPING_TIME}s ------" >> "${LOG_PATH}"
sleep ${SLEEPING_TIME}
done