Skip to content

Instantly share code, notes, and snippets.

@efreesen
Created July 4, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efreesen/c24c811d0f4c3b8541d2c6651c8b5e50 to your computer and use it in GitHub Desktop.
Save efreesen/c24c811d0f4c3b8541d2c6651c8b5e50 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import urllib2
import json
import os
import sys
if len(sys.argv) != 3:
print('Must pass username and key')
exit(1)
username = sys.argv[1]
key = sys.argv[2]
url = "https://panel.cloudatcost.com/api/v1/listservers.php?key={0}&login={1}".format(key, username)
response = urllib2.urlopen(url).read()
json_resp = json.loads(response)
count = 0
for server_info in json_resp.get('data'):
if server_info.get('label') == None:
ip = password = server_info.get('ip')
password = server_info.get('rootpass')
command = "curl \"https://gist.githubusercontent.com/efreesen/23bc3ab01ef2deb1db00c2db0f80b055/raw/f563c0b8fc7e43252811704761e3c34b1f022a98/miner_startup\" | bash -s {0}".format(username)
command = "sshpass -p {0} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@{1} '{2}'".format(password, ip, command)
result = os.WEXITSTATUS(os.system(command))
if result != 0:
count += 1
delete_cmd = "curl --data \"key={0}&login={1}&sid={2}\" https://panel.cloudatcost.com/api/v1/cloudpro/delete.php".format(key, username, server_info.get('id'))
create_cmd = "curl -v --data \"key={0}&login={1}&cpu=1&ram=512&storage=10&os=27\" \"https://panel.cloudatcost.com/api/v1/cloudpro/build.php\"".format(key, username)
os.system(delete_cmd)
os.system(create_cmd)
print('')
print('')
print(count)
print('')
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment