From 1c6668fbb1bef36a67eb507653f20cd42060941d Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Dec 2023 23:08:03 +0100 Subject: [PATCH] new files --- del_project.sh | 22 ++++++++++++++++++++++ gen_random.sh | 20 ++++++++++++++++++++ template-wg_server.yaml | 29 +++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100755 del_project.sh create mode 100755 gen_random.sh create mode 100644 template-wg_server.yaml diff --git a/del_project.sh b/del_project.sh new file mode 100755 index 0000000..dedb6f3 --- /dev/null +++ b/del_project.sh @@ -0,0 +1,22 @@ +#!/usr/bin/bash + +random=$1 +lxc project switch $random + +lxc stop $random-csgo2-00 +lxc delete $random-csgo2-00 + +lxc project delete $random +lxc network delete vn-$random + +#node1=`nmctl node list | grep $random | grep k2c-1 | awk '{print $16}'` +#node2=`nmctl node list | grep $random | grep k2c-2 | awk '{print $16}'` +#node3=`nmctl node list | grep $random | grep k2c-3 | awk '{print $16}'` +#otto=`nmctl node list | grep $random | grep otto | awk '{print $16}'` + +#nmctl node delete $random $node1 +#nmctl node delete $random $node2 +#nmctl node delete $random $node3 +#nmctl node delete $random $otto + +#nmctl network delete $random diff --git a/gen_random.sh b/gen_random.sh new file mode 100755 index 0000000..00cb7e6 --- /dev/null +++ b/gen_random.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +random=`date | md5sum | awk '{print $1}' | cut -c 22-` +echo $random + +# Generate Game container +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 ubuntu:22.04 $random-csgo2-00 --network vn-$random > /dev/null + +# Generate docker compose file +echo $random > /tmp/random +export VAR=`cat /tmp/random` +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 diff --git a/template-wg_server.yaml b/template-wg_server.yaml new file mode 100644 index 0000000..2a739f8 --- /dev/null +++ b/template-wg_server.yaml @@ -0,0 +1,29 @@ +services: + $VAR: + image: lscr.io/linuxserver/wireguard:latest + container_name: $VAR-wireguard + cap_add: + - NET_ADMIN + - SYS_MODULE + environment: + - PUID=1000 + - PGID=1000 + - TZ=Etc/UTC + - SERVERURL=vpn.koffeekube.io + - SERVERPORT=51820 + - PEERS=200 + - PEERDNS=auto + - INTERNAL_SUBNET=10.13.13.0 + - ALLOWEDIPS=0.0.0.0/0 + - PERSISTENTKEEPALIVE_PEERS=15 + - LOG_CONFS=true + volumes: + - $VAR-config:/config + ports: + - :51820/udp + sysctls: + - net.ipv4.conf.all.src_valid_mark=1 + restart: unless-stopped + +volumes: + $VAR-config: