Getting free VPS from Oracle Cloud

There is new always-free offer on Oracle site:
– AMD Epyc CPU: 2 servers, each with: 1 core, 1 GB ram, 50 GB HDD, 480 mb/s connection
– Ampere ARM CPU: 4 servers, each with: 1 core 2.8GHz, 6 GB ram, 50 GB HDD, 1gb/s connection
– 10 TB/month transfer limit for all your machines together

These 4 Ampere servers you can combine into 1 server: 4×2.8GHz, 24 GB ram, 50 GB HDD with 4gb/s connection!
You can also create 6 VPSes for 6 small projects.

Registration:
https://www.oracle.com/pl/cloud/free/
You will have to add credit card to account. Virtual/prepaid cards are not accepted. Revolut virtual card generated in smartphone application is not accepted, but physical Revolut card is ok.

It takes around 15 minutes to activate account after you register.

How to order free 4 core VPS and unlock internet access

When you order any dedic or VPS, it always comes with all internet access opened by default. Here we get machine with almost everything closed (except port 22 for SSH). Every port is blocked in Oracle Cloud panel and in Ubuntu.
If you install nginx on it, it will say in webbrowser that site is offline. Read next 16 steps to unlock all ports.

Go to https://cloud.oracle.com/ and login to your account. Click on ‘Create a VM instance’.

Click on ‘Edit Image and shape’.

Click on ‘Change image’.

Select ‘Canonical Ubuntu’ and click ‘Select image’.

Click on ‘Change shape’.
1. Select shape ‘Ampere’
2. Unroll options
3. Change OCPUs number to 4, it will automatically change RAM to 24 GB
4. Tick ‘VM.Standard.A1.Flex’
5. Click ‘Select shape’

For next step machine configuration step, you must have SSH key pair. If you already have one, you can skip next 3 steps.

To generate key pair you need ‘Git Bash’. You can download it here: https://git-scm.com/download/win

Run Git Bash using Windows Search. Just type ‘git’, it should find it.

In Git Bash window type:

ssh-keygen.exe -t rsa

It will generate SSH key pair and save it in your Windows user directory, in subdirectory .ssh. This directory may be hidden (depends on Windows settings), so you can’t easily navigate there. In this case, you can open any directory in Windows explorer, click on address bar, type:

%HOMEPATH%/.ssh

and click Enter. It should open folder with your id_rsa.pub file. You can copy it on desktop or to Downloads folder, to make it easy to find.

On Oracle page scroll to ‘Add SSH Keys’ and select option ‘Upload public key files (.pub)’.

Select file ‘id_rsa.pub’ we generated in previous 3 steps in file picker (button ‘Browse’). Oracle will upload it to your new VPS. Git Bash with automatically login to your server using this key – using all keys which are in .ssh directory – when you use ‘ssh’ command in it.

Your machine should change status to ‘Running’ within 1 minute. On right top side of page, there will appear IP of your server. Copy it. We will use it later.

There will also appear ‘Virtual cloud network’ with some random name. Click on it.

Click on Subnet name – again some random value.

Click on Default Security List name – again some random value.

Click ‘Add Ingress Rules’.

In ‘source CIDR’ type:

0.0.0.0/0

and click ‘Add Ingress Rules’.

Network TCP – like Tibia and www – traffic is unlocked in Oracle Cloud panel. You may also unblock UDP protocol traffic, if you plan to host TeamSpeak or other application which uses UDP.

Now we got to unlock traffic in Ubuntu. Open Git Bash and type:

ssh ubuntu@x.x.x.x

with your server IP in place of x.x.x.x, like ssh ubuntu@138.3.243.101
On first connection it will ask you, if you are sure that you connected to valid server. Type ‘yes’ and press Enter.

You are now connected to your VPS, but you still can’t run web server or OTS on it. Type:

sudo su
iptables -I INPUT -j ACCEPT
iptables-save > /etc/iptables/rules.v4

It will unlock all incoming traffic in Ubuntu.

Eloth start scripts for GMs

ROOK

Create fast monster spawn

Spawn “Snake” every second (1000 ms) for 5 seconds:

!lua function fms(m, p, c) doSummonCreature(m, p, true, true) if (c > 1) then addEvent(fms, 1000, m, p, c-1) end end fms("Spider", getCreaturePosition(cid), 5)

Mass spawn around GOD:

!lua for i = 1, 20 do doSummonCreature("Spider", getCreaturePosition(cid), true, true) end

Spawn temple NPC

For FACC towns:

/s The Oracle

For PACC towns:

/s The Gatekeeper

MAIN

Open Desert Quest

Create teleports that allow 20+ levels do quest solo without items:

!lua doCreateTeleport(1387, Position(32672, 32102, 8), Position(32647, 32092, 7)) doCreateTeleport(1387, Position(32672, 32070, 8), Position(32673, 32089, 8))

MySQL dump examples

Dump database to file with date in name:

mysqldump -u USERNAME -pSECRETPASSWORD --single-transaction --quick --lock-tables=false DBNAME_HERE > /home/backup/mysql/DBNAME_HERE_`date "+%Y-%m-%d-%H-%M"`.sql

Crontab version: dump every hour at minute 5

5 * * * * mysqldump -u USERNAME -pSECRETPASSWORD --single-transaction --quick --lock-tables=false DBNAME_HERE > /home/backup/mysql/DBNAME_HERE_`date "+\%Y-\%m-\%d-\%H-\%M"`.sql

Limit number of connections per IP

Limit number of incoming concurrent connections per IP to 1.

On all ports and IPs of server:

iptables -t filter -I INPUT -p tcp -j ACCEPT
iptables -t filter -I INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -I INPUT -p tcp --syn -m connlimit --connlimit-above 1 --connlimit-mask 32 -j DROP

On port 80 of server:

iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -I INPUT -p tcp --dport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -I INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 1 --connlimit-mask 32 -j DROP

On port 80 and IP 91.134.189.246 of server (in case when server has more IPs):

iptables -t filter -I INPUT -p tcp -d 91.134.189.246 --dport 80 -j ACCEPT
iptables -t filter -I INPUT -p tcp -d 91.134.189.246 --dport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -I INPUT -p tcp --syn -d 91.134.189.246 --dport 80 -m connlimit --connlimit-above 1 --connlimit-mask 32 -j DROP

Find newest files in directory (recursively)

List files from oldest to newest, recursively.

find . -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -n |  awk '{print strftime("%Y-%m-%d %H:%M:%S", $1), $5}' | tail --lines=50

Result:

(...)
2019-04-19 12:21:31 ./klientotc/modules/gamelib/ui/uiminimap.lua
2019-04-19 15:04:22 ./klientotc/modules/game_hotkeys/hotkeys_manager.otui
2019-04-19 15:11:36 ./klientotc/modules/game_hotkeys/hotkeys_manager.lua
2019-04-19 16:18:34 ./klientotc/.git/index
2019-04-19 16:18:34 ./klientotc/modules/corelib/ui/uiminiwindowcontainer.lua
2019-04-19 16:33:01 ./klientotc/modules/corelib/ui/uiminiwindow.lua
2019-04-19 17:15:50 ./klientotc.zip
2019-04-23 07:35:34 ./klientotc/Kasteria.log
2019-04-25 07:25:25 ./klientotc/.idea/workspace.xml
2019-04-26 10:26:27 ./source/.idea/workspace.xml