2023-12-20 17:14:36 +00:00
|
|
|
#!/bin/bash
|
2023-12-19 22:08:03 +00:00
|
|
|
|
|
|
|
random=`date | md5sum | awk '{print $1}' | cut -c 22-`
|
2023-12-20 19:41:21 +00:00
|
|
|
echo $random
|
2023-12-20 16:51:11 +00:00
|
|
|
|
2023-12-20 19:41:21 +00:00
|
|
|
# Minecraft servers
|
|
|
|
minecraft-std() {
|
2023-12-20 18:09:53 +00:00
|
|
|
lxc project create $random -c features.images=false > /dev/null
|
|
|
|
lxc project switch $random > /dev/null
|
|
|
|
lxc --project $random network create vn-$random > /dev/null
|
2024-01-03 23:52:29 +00:00
|
|
|
cat default.profile | lxc --project $random profile edit default > /dev/null
|
2023-12-20 19:41:21 +00:00
|
|
|
lxc launch --project $random -p default minecraft-server $random-minecraft-std --network vn-$random --config limits.cpu=2 --config limits.memory=2048MiB > /dev/null
|
2023-12-29 18:43:30 +00:00
|
|
|
lxc launch --project $random -p default wireguard-server $random-vpn-server --network vn-$random --config limits.cpu=1 --config limits.memory=1024MiB > /dev/null
|
2023-12-20 17:08:36 +00:00
|
|
|
}
|
2023-12-20 16:51:11 +00:00
|
|
|
|
2023-12-20 19:41:21 +00:00
|
|
|
minecraft-max() {
|
|
|
|
lxc project create $random -c features.images=false > /dev/null
|
|
|
|
lxc project switch $random > /dev/null
|
|
|
|
lxc --project $random network create vn-$random > /dev/null
|
2024-01-03 23:52:29 +00:00
|
|
|
cat default.profile | lxc --project $random profile edit default > /dev/null
|
2023-12-20 19:41:21 +00:00
|
|
|
lxc launch --project $random -p default minecraft-server $random-minecraft-max --network vn-$random --config limits.cpu=4 --config limits.memory=4096MiB > /dev/null
|
2023-12-29 18:43:30 +00:00
|
|
|
lxc launch --project $random -p default wireguard-server $random-vpn-server --network vn-$random --config limits.cpu=1 --config limits.memory=1024MiB > /dev/null
|
2023-12-20 19:41:21 +00:00
|
|
|
}
|
|
|
|
|
2024-01-03 23:52:29 +00:00
|
|
|
$1
|
|
|
|
|
2023-12-29 23:15:44 +00:00
|
|
|
# Setup VPN
|
2024-01-04 14:25:00 +00:00
|
|
|
vpn_port=`python3 ports.py`
|
2024-01-03 23:06:40 +00:00
|
|
|
lxc config device add $random-vpn-server udp$vpn_port proxy listen=udp:0.0.0.0:$vpn_port connect=udp:127.0.0.1:51820
|
2024-01-03 23:52:29 +00:00
|
|
|
curl --silent -X PUT --user "adelorenzo:dimi2014" https://couchdb.oe74.cloud/kk_users/${random}/${random} -d "{"_id":"$random"}"
|
2024-01-04 00:20:55 +00:00
|
|
|
random_rev=`curl --silent -X GET https://adelorenzo:dimi2014@couchdb.oe74.cloud/kk_users/$random | jq -c '._rev' | sed 's/^.//' | sed 's/.$//'`
|
2024-01-04 00:32:26 +00:00
|
|
|
curl --silent -X GET --user "adelorenzo:dimi2014" https://couchdb.oe74.cloud/kk_users/$random | jq '(.["vpn_port"] = '"$vpn_port"')' > $random-port.temp
|
|
|
|
curl -X PUT -H "Content-Type: application/json" https://adelorenzo:dimi2014@couchdb.oe74.cloud/kk_users/$random --data @${random}-port.temp
|
2024-01-04 14:25:28 +00:00
|
|
|
rm $random-port.temp
|
2023-12-29 23:09:38 +00:00
|
|
|
#curl --silent -H "Content-Type: text/x-yaml" -X PUT --data-binary @${random}-wg_server.yaml --user "adelorenzo:dimi2014" "https://couchdb.oe74.cloud/kk_users/${random}/${random}-wg_server.yaml?rev=$random_rev" > /dev/null
|