#!/bin/bash random=`date | md5sum | awk '{print $1}' | cut -c 22-` echo $random # Minecraft servers minecraft-std() { 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 cat /root/default.profile | lxc --project $random profile edit default > /dev/null lxc launch --project $random -p default minecraft-server $random-minecraft-std --network vn-$random --config limits.cpu=2 --config limits.memory=2048MiB > /dev/null lxc launch --project $random -p default wireguard-server $random-vpn-server --network vn-$random --config limits.cpu=1 --config limits.memory=1024MiB > /dev/null } 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 cat /root/default.profile | lxc --project $random profile edit default > /dev/null lxc launch --project $random -p default minecraft-server $random-minecraft-max --network vn-$random --config limits.cpu=4 --config limits.memory=4096MiB > /dev/null lxc launch --project $random -p default wireguard-server $random-vpn-server --network vn-$random --config limits.cpu=1 --config limits.memory=1024MiB > /dev/null } # Setup VPN vpn_port=`python3 /opt/thekube/ports.py` 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 curl --silent -X PUT --user "adelorenzo:dimi2014" https://couchdb.oe74.cloud/kk_users/${random}/${random} -d "{"_id":"$random"}" > /dev/null random_rev=`curl --silent -X GET https://adelorenzo:dimi2014@couchdb.oe74.cloud/kk_users/$random | jq -c '._rev' | sed 's/^.//' | sed 's/.$//'` #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 $1