mirror of
https://github.com/khuedoan/homelab.git
synced 2025-02-06 17:18:51 +07:00
Turn off PXE server when all server has started up
This commit is contained in:
parent
b295e07905
commit
8569d8633e
4
infra/docker.sh
Normal file
4
infra/docker.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
yum install -y yum-utils
|
||||||
|
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||||
|
yum install -y docker-ce docker-ce-cli containerd.io
|
||||||
|
systemctl enable docker
|
@ -35,10 +35,13 @@ nodes = [
|
|||||||
def is_alive(node):
|
def is_alive(node):
|
||||||
return os.system(f"ping -c 1 {node['ip']}") == 0
|
return os.system(f"ping -c 1 {node['ip']}") == 0
|
||||||
|
|
||||||
|
def is_ready(node):
|
||||||
|
return os.system(f"ssh -o StrictHostKeyChecking=no {user}@{node['ip']} exit") == 0
|
||||||
|
|
||||||
def poweroff(node):
|
def poweroff(node):
|
||||||
if is_alive(node):
|
if is_alive(node):
|
||||||
print(f"Poweroff {node['name']}")
|
print(f"Poweroff {node['name']}")
|
||||||
os.system(f"ssh {user}@{node['ip']} poweroff")
|
os.system(f"ssh -o StrictHostKeyChecking=no {user}@{node['ip']} poweroff")
|
||||||
else:
|
else:
|
||||||
print(f"Node {node['name']} is already dead!")
|
print(f"Node {node['name']} is already dead!")
|
||||||
|
|
||||||
@ -57,3 +60,9 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
wake(node)
|
wake(node)
|
||||||
|
|
||||||
|
while not all(is_ready(node) for node in nodes):
|
||||||
|
print("Waiting for all servers to start up...")
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
os.system(f"docker-compose down")
|
||||||
|
Loading…
Reference in New Issue
Block a user