-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·55 lines (49 loc) · 1.11 KB
/
entrypoint.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
#!/usr/bin/env bash
function wallet_init() {
echo "++ wallet_init";
output=$(textile wallet init)
mnemonics=$(echo "${output}" | head -n2 | tail -n1)
echo "Save this! ${mnemonics}"
export SEED=$(echo "${output}" | tail -n1)
}
function textile_init() {
echo "++ textile_init";
if [[ -n "${ARGS}" ]]; then
textile init --repo-dir=/textile ${ARGS}
else
textile init --repo-dir=/textile --seed ${SEED}
fi
}
function textile_start() {
echo "++ textile_start";
textile daemon --repo-dir=/textile
}
function main() {
echo "++ main";
if [[ -f /textile/textile ]]; then
textile_start;
elif [[ -n "${SEED}" ]] || [[ -n "${ARGS}" ]] ; then
textile_init;
textile_start;
else
wallet_init;
textile_init;
textile_start;
fi
}
ARGS=""
while [[ -n "$1" ]] ; do
case "$1" in
--seed)
shift;
export SEED=$1
export ARGS="${ARGS} --seed=${1}"
shift;
;;
*)
export ARGS="${ARGS} $1"
shift
;;
esac
done
main;