-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdvpn-price-cronjob.sh
43 lines (36 loc) · 1.59 KB
/
dvpn-price-cronjob.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
#!/bin/bash
#
# This will only work if you created a user name 'sentinel' with authorized ssh key access
# from your running machine.
#
# Also need 'sentinel ALL=(ALL:ALL) NOPASSWD: ALL' in /etc/sudoers
# This can be edited afterwards to remove the NOPASSWD permissions
#
# ssh pubkey access needs to be added to your /etc/ssh/sshd_config file
# for this to work
#
# EDIT THESE to all your IP ADDRESSES of your nodes
nodes=('zozobra.mathnodes.com molien.mathnodes.com petersen.mathnodes.com schrodinger.mathnodes.com')
# SSH PORT (EDIT)
port='22000'
# USERNAME OF DVPN NODE SOFTWARE
username='sentinel'
username2='v2ray'
for node in ${nodes[@]}; do
echo "$node"
ssh -p $port $username@$node << EOF
wget -O - https://github.com/freQniK/dvpn_price/releases/download/v0.4.1/dvpn_price-v0.4.1.tar.gz | tar xvzf -
sudo crontab -l > /home/$username/mycron
echo "59 0 * * * /home/$username/bin/dvpn_price -t 10 -p 0.009 -q 0.005 -u $username" >> /home/$username/mycron
echo "59 12 * * * /home/$username2/bin/dvpn_price -t 10 -p 0.009 -q 0.005 -u $username2" >> /home/$username/mycron
if id "$username2" >/dev/null 2>&1; then
sudo -H -u $username2 bash -c 'wget -O /home/$username2/dvpn.tar.gz https://github.com/freQniK/dvpn_price/releases/download/v0.4.1/dvpn_price-v0.4.1.tar.gz' && sudo -H -u $username2 bash -c 'tar xvzf /home/$username2/dvpn.tar.gz -C /home/$username2'
else
echo '$username2 not found'
fi
echo "Adding cronjob"
sleep 2
sudo crontab /home/$username/mycron
sudo rm -rf /home/$username/mycron
EOF
done