thekube/gen_random.sh

103 lines
5.5 KiB
Bash
Raw Normal View History

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
# CSGO2 servers
csgo2-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 csgo2-server $random-csgo2-std --network vn-$random --config limits.cpu=2 --config limits.memory=2048MiB > /dev/null
}
csgo2-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 csgo2-server $random-csgo2-max --network vn-$random --config limits.cpu=4 --config limits.memory=4096MiB > /dev/null
}
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
cat /root/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
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
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
}
# Apex servers
apex-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 apex-server $random-apex-std --network vn-$random --config limits.cpu=2 --config limits.memory=2048MiB > /dev/null
}
apex-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 apex-server $random-apex-max --network vn-$random --config limits.cpu=4 --config limits.memory=4096MiB > /dev/null
}
2023-12-20 16:51:11 +00:00
2023-12-20 19:41:21 +00:00
# Rust servers
rust-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 rust-server $random-rust-std --network vn-$random --config limits.cpu=2 --config limits.memory=2048MiB > /dev/null
}
rust-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 rust-server $random-rust-max --network vn-$random --config limits.cpu=4 --config limits.memory=4096MiB > /dev/null
}
2023-12-20 16:51:11 +00:00
# GTA server
2023-12-20 19:41:21 +00:00
gta-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 gta-server $random-gta-std --network vn-$random --config limits.cpu=2 --config limits.memory=2048MiB > /dev/null
}
gta-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 gta-server $random-gta-max --network vn-$random --config limits.cpu=4 --config limits.memory=4096MiB > /dev/null
}
2023-12-20 17:08:36 +00:00
# Generate docker compose file
2023-12-20 19:47:09 +00:00
echo $random > /tmp/$random-random
export VAR=`cat /tmp/$random-random`
2023-12-20 17:08:36 +00:00
envsubst < template-wg_server.yaml > $random-wg_server.yaml
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
rm ${random}-wg_server.yaml
2023-12-20 19:47:09 +00:00
rm /tmp/$random-random
2023-12-20 18:08:35 +00:00
$1