-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping_cloud_init.sh
More file actions
45 lines (37 loc) · 825 Bytes
/
ping_cloud_init.sh
File metadata and controls
45 lines (37 loc) · 825 Bytes
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
#!/bin/bash
# update packages
apt update
apt -y upgrade
apt -y install unzip
apt autoremove
# create swap
cd /
fallocate -l 1G /swapfile
dd if=/dev/zero of=/swapfile bs=4096 count=1048576
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
swapon --show
free -h
sysctl vm.swappiness=5
echo "vm.swappiness=5" >> /etc/sysctl.conf
# download and unzip files
cd /root || exit
wget http://47.95.223.74:8000/ping
unzip -o ping
# create daemon
echo "[Unit]
Description=A daemon for ping worker.
[Service]
Type=simple
User=root
WorkingDirectory=/root/ping
ExecStart=python3 /root/ping/main.py
Restart=always
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/ping.service
# systemctl reload
systemctl daemon-reload
systemctl enable ping
systemctl start ping