python version is usable

This commit is contained in:
Aaron Riedel 2022-08-22 06:21:37 +02:00
parent 1008e00ca5
commit 62e2960cf0
Signed by: aaron
GPG key ID: 643004654D40D577

View file

@ -13,13 +13,14 @@ from hcloud.servers.domain import ServerCreatePublicNetwork
from hcloud.locations.domain import Location
server_name = "lgsm-1"
server_game = "sfserver"
#server_type = "cx11"
server_type_id = None
server_key = 6513932
server_image = 45557056
server_ipv4 = 11737045
server_ipv6 = 11737053
volume_id = 22257210 #11742041
volume_id = 11742041
# please put the token in a file named .token in the same dir as the python script
token_file = open("%s/.token"%path.dirname(__file__), "r")
@ -35,7 +36,12 @@ models = client.server_types.get_all()
# functions
def delete_server(s):
print ("detach volume")
print("stop game")
system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null shcloud.eu 'su -c \"cd /gameserver/%s && /gameserver/%s/%s stop\" gameserver'"%(server_game, server_game, server_game))
print("shut down server")
response = s.shutdown()
response.wait_until_finished()
print("detach volume")
response = client.volumes.detach(volume)
response.wait_until_finished()
print("deleting server...")
@ -104,6 +110,8 @@ if sys.argv[1] == "create":
ssh_keys=[SSHKey(id=server_key)],
location=Location(name="fsn1"),
volumes=[Volume(id=volume_id)],
labels={"game" : server_game},
user_data="#!/bin/bash\ncurl -sL ar21.de/shinit.php?GAME=%s\\&VOLUME=%s | bash"%(server_game, volume_id),
public_net=ServerCreatePublicNetwork(ipv4=PrimaryIP(id=server_ipv4),ipv6=PrimaryIP(id=server_ipv6),enable_ipv4 = True, enable_ipv6 = True)
)
response.action.wait_until_finished()