-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomation_Custom_Script.sh
More file actions
158 lines (115 loc) · 4.1 KB
/
Automation_Custom_Script.sh
File metadata and controls
158 lines (115 loc) · 4.1 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
#------------------------------------------------------------------------------------------------------
# SolarPi - Installation script
#------------------------------------------------------------------------------------------------------
# (C) 2017 Dominik Schäfer - domme@solarcoin.mehrunfug.org
# This file is executed after the successful installation of DietPi OS.
# Solarcoind is downloaded, compiled and configured as a service.
# You may select a custom RPC password here.
# If you don't, a strong random password is generated (recommended).
# As a normal user you won't need the RPC password anyway.
# This file will be deleted after the installation is completed.
# Nevertheless, it's never a good idea to store any password in plain text.
# It is more secure to edit ~/.solarcoin/solarcoin.conf after the installation.
rpcpassword=0
# NO CHANGES BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING!
# Start setup
echo "Starting installation process..." > ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
# Update OS
cd
echo "Updating OS..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
apt-get update
apt-get upgrade -y
# Increase swap size
echo "Increasing swap size..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
sed -i "s/\(CONF_SWAPSIZE *= *\).*/\11024/" /etc/dphys-swapfile
dphys-swapfile setup
dphys-swapfile swapon
# Install dependencies
echo "Installing dependencies..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev libdb-dev libdb4.8++ libdb5.3++-dev git hardening-includes rng-tools g++ make -y
# Build BerkeleyDB
echo "Downloading BerkeleyDB..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
sudo tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
../dist/configure --enable-cxx --disable-shared
echo "Building BerkeleyDB..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
make
echo "Installing BerkeleyDB..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
make install
export CPATH="/usr/local/BerkeleyDB.4.8/include"
export LIBRARY_PATH="/usr/local/BerkeleyDB.4.8/lib"
# Build solarcoind
cd
echo "Downloading solarcoind..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
git clone https://github.com/onsightit/solarcoin.git
cd db-4.8.30.NC/build_unix
../dist/configure --prefix=/usr/local --enable-cxx --disable-shared
cd
cd solarcoin/src
echo "Building solarcoind..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
make -f makefile.unix -e PIE=1
strip solarcoind
hardening-check solarcoind >> ~/solarcoind_setup.log
echo "Installing solarcoind..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
install -m 755 solarcoind /usr/local/bin/solarcoind
cd
solarcoind
echo "Installation process complete! =)" >> ~/solarcoind_setup.log
# Create config file
echo "Creating config file..." >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
# Generate random password if no custom password is set.
if [ $rpcpassword = 0 ]; then
rpcpassword=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-64};echo;)
fi
cd ~/.solarcoin/
# Write config file
/bin/cat <<EOM >solarcoin.conf
addnode=162.243.214.120
server=1
daemon=1
rpcuser=solarcoinrpc
rpcpassword=$rpcpassword
listen=1
EOM
chmod 400 solarcoin.conf
sleep 1
# Set up solarcoind as a service
/bin/cat <<EOM >/etc/systemd/system/solarcoind.service
[Unit]
Description=SolarCoin daemon services
After=tlp-init.service
[Service]
Type=forking
ExecStart=/usr/local/bin/solarcoind
PIDFile=/root/.solarcoin/solarcoind.pid
RemainAfterExit=yes
Restart=on-failure
RestartSec=3
User=root
[Install]
WantedBy=multi-user.target
EOM
systemctl enable solarcoind.service
systemctl daemon-reload
systemctl start solarcoind.service
echo "solarcoind is now ready to operate! =)" >> ~/solarcoind_setup.log
echo "Please encrypt your wallet now!" >> ~/solarcoind_setup.log
date >> ~/solarcoind_setup.log
# Clean up
rm -rf db-4.8.30.NC*
rm solarcoind_setup.sh
rm /boot/AUTO_CustomScript.sh
rm /boot/Automation_Custom_Script.sh