-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptdroplet.sh
195 lines (177 loc) · 4.29 KB
/
ptdroplet.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
clear
echo "################################################################"
echo "# https://github.com/mrhasbean/PTDroplet #"
echo "# #"
echo "# We will go though the proccess of setting up a ProfitTrailer #"
echo "# bot server. #"
echo "# #"
echo "################################################################"
echo
prompt_confirm() {
while true; do
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
case $REPLY in
[yY]) echo ; return 0 ;;
[nN]) echo ; return 1 ;;
*) printf " \033[31m %s \n\033[0m" "invalid input"
esac
done
}
set_timezone() {
dpkg-reconfigure tzdata
export LC_ALL=en_US.UTF-8
export LANG="en_US.UTF-8"
export LANGUAGE=en_US.UTF-8
echo 'LC_ALL=en_US.UTF-8' >> /etc/environment
echo 'LANG=en_US.UTF-8' >> /etc/environment
echo 'LANGUAGE=en_US.UTF-8' >> /etc/environment
locale-gen en_US.UTF-8
dpkg-reconfigure locales
}
make_swap() {
fallocate -l 1024M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
sysctl vm.swappiness=10
echo "vm.swappiness=10" >> /etc/sysctl.conf
sysctl vm.vfs_cache_pressure=50
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf
}
prompt_confirm || exit 0
clear
# installation requires root access
echo Stage 1: Checking root access
echo
sleep 2
if [ "x$(id -u)" != 'x0' ]; then
echo 'Error: this script can only be executed by root'
exit 1
fi
echo
echo Stage 1: Complete
sleep 2
# creates SWAP on the server
echo Stage 2: Creating SWAP space
echo
sleep 2
swapnum=$(( $(wc -l < /proc/swaps) - 1 ))
if [ $swapnum -eq 0 ]
then
make_swap
else
echo Swap already exists, no further action required.
fi
echo
echo Stage 2: Complete
sleep 5
clear
# set time zone if not correct
echo Stage 3: Set server timezone & locale
echo
sleep 2
set_timezone
echo
echo Stage 3: Complete
sleep 5
clear
# update server software
echo Stage 4: Updating software
echo
sleep 2
apt-get -y update
echo
echo Stage 4: Complete
sleep 5
clear
# install a few useful tools
echo Stage 5: Installing archive tools
echo
sleep 2
apt-get -y install zip
apt-get -y install unzip
apt-get -y install p7zip-full
echo
echo Stage 5: Complete
sleep 5
clear
# install java
echo Stage 6: Installing Java
echo
sleep 2
apt-get -y install default-jdk
echo
echo Stage 6: Complete
sleep 5
clear
# install nodejs and link to /nodejs and /node directories
echo Stage 7: Installing nodejs
echo
sleep 2
apt-get -y install nodejs
ln -s /usr/bin/nodejs /usr/bin/node
echo
echo Stage 7: Complete
sleep 5
clear
# install npm and use npm to install pm2
echo Stage 8: Installing npm and pm2
echo
sleep 2
apt-get -y install npm
npm install pm2@latest -g
echo
echo Stage 8: Complete
sleep 5
clear
# create pt directory structure
echo Stage 9: Creating base PT folder structure
echo
sleep 2
echo Please enter a name for this bot. For best compatibility, use only lower case a-z and NO spaces. eg. myfirstbot
read -p 'Bot Name: ' botname
cd /var/opt
mkdir pt
cd pt
mkdir releases
# create bot directory
mkdir $botname
cd $botname
echo
echo Stage 9: Complete
sleep 5
clear
# download latest ProfitTrailer and extract to bot directory
echo Stage 10: Downloading latest ProfitTrailer release
echo
sleep 2
wget https://github.com/$(wget https://github.com/taniman/profit-trailer/releases/latest -O - | egrep '/.*/.*/.*zip' -o)
unzip *zip
mv *zip ../releases
mv ProfitTrailer* ProfitTrailer
cd ProfitTrailer
mv * ..
cd ..
rm -rf ProfitTrailer
chmod +x ProfitTrailer.jar
echo
echo Stage 10: Complete
sleep 5
clear
echo Installation complete. You must now reboot to finalise the installation. At the prompt below, simply type:
echo " reboot"
echo
echo After rebooting, please proceed to edit your application.properties and settings files.
echo See https://wiki.profittrailer.com/doku.php?id=mandatory_settings for details.
echo
echo After you have completed the Mandatory Settings, launch ProfitTrailer. At the prompt, type:
echo " cd /var/opt/pt/$botname"
echo " pm2 start pm2-ProfitTrailer.json"
echo
echo You can then monitor the bot using the pm2 Dashboard by typing:
echo " pm2 dash"
echo
echo Happy Profit Trailing!
# END