-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit-nxt.sh
executable file
·85 lines (71 loc) · 2.53 KB
/
init-nxt.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
if [ ! -f "/nxt/.init" ]; then
echo -e " init-nxt.sh: Performing init..."
# If there is no .init, this can be a new install
# or an upgrade... in the second case, we want to do some cleanup to ensure
# that the upgrade will go smooth
rm -Rf /nxt/lib && \
mkdir /nxt/conf
# if a script was provided, we download it locally
# then we run it before anything else starts
if [ -n "${SCRIPT-}" ]; then
filename=$(basename "$SCRIPT")
wget "$SCRIPT" -O "/nxt-boot/scripts/$filename"
chmod u+x "/nxt-boot/scripts/$filename"
/nxt-boot/scripts/$filename
fi
cd /
# Now time to get the NRS client
wget --no-check-certificate https://bitbucket.org/Jelurida/nxt/downloads/nxt-client-$NRSVersion.zip && \
wget --no-check-certificate https://bitbucket.org/Jelurida/nxt/downloads/nxt-client-$NRSVersion.changelog.txt.asc && \
gpg --keyserver pgpkeys.mit.edu --recv-key 0xFF18FD55 && \
gpg --verify nxt-client-$NRSVersion.changelog.txt.asc && \
unzip -o nxt-client*.zip && \
rm *.zip *.asc && \
cd /nxt && \
rm -Rf *.exe src changelogs
if [ -n "${PLUGINS-}" ]; then
/nxt-boot/scripts/install-plugins.sh "$PLUGINS"
else
echo " PLUGINS not provided"
fi
# We figure out what is the current db folder
if [ "$NXTNET" = "main" ]; then
DB="nxt_db"
else
DB="nxt_test_db"
fi
# just to be sure :)
echo " Database is $DB"
# if we need to bootstrap, we do that first.
# Warning, bootstrapping will delete the current blockchain.
# $BLOCKCHAINDL must point to a zip that contains the nxt_db folder itself.
if [ -n "${BLOCKCHAINDL-}" ] && [ ! -d "$DB" ]; then
echo " init-nxt.sh: $DB not found, downloading blockchain from $BLOCKCHAINDL";
wget "$BLOCKCHAINDL" && unzip *.zip && rm *.zip
echo " init-nxt.sh: Blockchain download complete"
else
echo " BLOCKCHAINDL not provided"
fi
# linking of the config
if [ "$NXTNET" = "main" ]; then
echo " init-nxt.sh: Linking config to mainnet"
cp /nxt-boot/conf/nxt-main.properties /nxt/conf/nxt.properties
else
echo " init-nxt.sh: Linking config to testnet"
cp /nxt-boot/conf/nxt-test.properties /nxt/conf/nxt.properties
fi
# if the admin password is defined in the ENV variable, we append to the config
if [ -n "${ADMINPASSWD-}" ]; then
echo -e "\nnxt.adminPassword=${ADMINPASSWD-}" >> /nxt/conf/nxt.properties
else
echo " ADMINPASSWD not provided"
fi
# If we did all of that, we dump a file that will signal next time that we
# should not run the init-script again
touch /nxt/.init
else
echo -e " init-nxt.sh: Init already done, skipping init."
fi
cd /nxt
./run.sh