From bd92e9842381569bf37408d52dbb360d094ec0b0 Mon Sep 17 00:00:00 2001 From: Niko Date: Sat, 1 Aug 2020 11:56:53 +0400 Subject: [PATCH 1/3] ref #2 remove sporestack refund address as it won't actually work --- Readme.md | 6 +----- stand-up.py | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index da55377..11ad18d 100644 --- a/Readme.md +++ b/Readme.md @@ -3,8 +3,6 @@ script to create droplet / instance on digitalocean or google cloud or setup a manually deployed machine with sporestack it is possible to prepay a digitalocean instance using cryptocurrency, -the refund address can be used to get some of the payment back in case of an error on sporestacks side, -seemingly there are no refunds upon early termination of a prepaid instance. sporestack supports the standard digitalocean regions, but currently there is no nice way to specify the instance size or image via the API, so these values are fixed to the sporestack defaults for now (1GB, 1 Core, ubuntu 16.04) @@ -33,7 +31,7 @@ supports installing wallets, for now only monero is supported. ## help ``` usage: stand-up.py [-h] [--target {digitalocean,gcloud,sporestack,manual}] [--digitalocean-api-key DIGITALOCEAN_API_KEY] [--gcloud-api-key-file GCLOUD_API_KEY_FILE] - [--gcloud-project-id GCLOUD_PROJECT_ID] [--sporestack-days SPORESTACK_DAYS] [--sporestack-refund-address SPORESTACK_REFUND_ADDRESS] [--sporestack-currency {btc,bch,bsv}] + [--gcloud-project-id GCLOUD_PROJECT_ID] [--sporestack-days SPORESTACK_DAYS] [--sporestack-currency {btc,bch,bsv}] [--instance-ip INSTANCE_IP] [--name NAME] [--region REGION] [--size SIZE] [--image IMAGE] [--user USER] [--ssh-port SSH_PORT] [--ssh-connection-tries SSH_CONNECTION_TRIES] [--ssh-wait-for-auth] [--tool TOOL] [--repo REPO] [--service {ipsec,proxy,shadowsocks,wireguard,ssh-pivot}] [--wallet {monero}] [--force] [--destroy] [--bare] [--compose-version COMPOSE_VERSION] [--verbose] [--quiet] [--ssh-private-key SSH_PRIVATE_KEY] [--create-private-key] @@ -50,8 +48,6 @@ optional arguments: Project ID for GCloud (default: first available project id) --sporestack-days SPORESTACK_DAYS How many days to prepay sporestack instance - --sporestack-refund-address SPORESTACK_REFUND_ADDRESS - Refund Address for sporestack instances that have been terminated early --sporestack-currency {btc,bch,bsv} Which currency to use for payment --instance-ip INSTANCE_IP diff --git a/stand-up.py b/stand-up.py index 2f009c6..51f84c2 100755 --- a/stand-up.py +++ b/stand-up.py @@ -17,7 +17,6 @@ argparser.add_argument("--gcloud-api-key-file", help="API key file for GCloud") argparser.add_argument("--gcloud-project-id", help="Project ID for GCloud (default: first available project id)") argparser.add_argument("--sporestack-days", help="How many days to prepay sporestack instance", default=1, type=int) -argparser.add_argument("--sporestack-refund-address", help="Refund Address for sporestack instances that have been terminated early", default=None) argparser.add_argument("--sporestack-currency", help="Which currency to use for payment", default='btc', choices=['btc', 'bch', 'bsv', 'xmr']) argparser.add_argument("--instance-ip", help="Instance IP if manual mode is used") argparser.add_argument("--name", "-n", help="slug name (default: %(default)s)", default='investig') @@ -115,7 +114,7 @@ def cleanup_and_die(msg): cleanup_and_die("please install the gcloud module: 'pip install -U google-api-python-client'") def write_config(configdict, configfile): - for nosave in ["bare", "create_private_key", "destroy", "force", "instance_ip", "name", "quiet", "verbose", "digitalocean_api_key", "gcloud_api_key_file", "gcloud_api_key_file", "ssh_wait_for_auth", "sporestack_refund_address"]: + for nosave in ["bare", "create_private_key", "destroy", "force", "instance_ip", "name", "quiet", "verbose", "digitalocean_api_key", "gcloud_api_key_file", "gcloud_api_key_file", "ssh_wait_for_auth"]: if nosave in configdict: del configdict[nosave] if not os.path.exists(os.path.dirname(configfile)): os.mkdir(os.path.dirname(configfile)) @@ -559,7 +558,6 @@ def validate_digitalocean(): 1, # bandwidth, 'digitalocean.sporestack.com', # host=None, sporestackv2.client.API_ENDPOINT, # api_endpoint=API_ENDPOINT, - config['sporestack_refund_address'], # refund_address=None, 1, # cores=1, config['sporestack_currency'], # currency='bch', config['region'], # region=None, From 9fcb598942326279732d2269203eb7d27f0ddb56 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 14 Jun 2021 09:14:11 +0400 Subject: [PATCH 2/3] sporestackv2 has been renamed to sporestack --- stand-up.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/stand-up.py b/stand-up.py index 07683dc..c1e0973 100755 --- a/stand-up.py +++ b/stand-up.py @@ -77,9 +77,9 @@ def cleanup_and_die(msg): elif args.target == 'sporestack': try: instance_dict - machine_info = sporestackv2.client.get_machine_info(config['name']) + machine_info = sporestack.client.get_machine_info(config['name']) logger.critical("calling delete() on instance id {}".format(machine_info['machine_id'])) - sporestackv2.client.delete(config['name'], sporestackv2.client.API_ENDPOINT) + sporestack.client.delete(config['name'], sporestack.client.API_ENDPOINT) except NameError: logger.debug('no instance has been created yet') try: @@ -103,9 +103,9 @@ def cleanup_and_die(msg): cleanup_and_die("please install the digitalocean module: 'pip install -U python-digitalocean'") try: - import sporestackv2 + import sporestack except ImportError: - cleanup_and_die("please install the sporestackv2 module: 'pip install -U sporestack'") + cleanup_and_die("please install the sporestack module: 'pip install -U sporestack'") try: from google.oauth2 import service_account @@ -536,24 +536,24 @@ def validate_digitalocean(): logger.info("setting up existing instance on IP {}".format(instance_ip)) elif args.target == 'sporestack': if vars(args).get('destroy'): - if sporestackv2.client.machine_exists(config['name']): - machine_info = sporestackv2.client.get_machine_info(config['name']) - sporestackv2.client.delete(config['name'], sporestackv2.client.API_ENDPOINT) + if sporestack.client.machine_exists(config['name']): + machine_info = sporestack.client.get_machine_info(config['name']) + sporestack.client.delete(config['name'], sporestack.client.API_ENDPOINT) cleanup_and_die("destroyed instance id {}, aborting".format(machine_info['machine_id'])) else: cleanup_and_die("no instance with name {} found, aborting".format(config['name'])) - if sporestackv2.client.machine_exists(config['name']): - machine_info = sporestackv2.client.get_machine_info(config['name']) + if sporestack.client.machine_exists(config['name']): + machine_info = sporestack.client.get_machine_info(config['name']) logger.warning('the requested name "{}" is already taken'.format(config['name'])) if vars(args).get('force'): - sporestackv2.client.delete(config['name'], sporestackv2.client.API_ENDPOINT) + sporestack.client.delete(config['name'], sporestack.client.API_ENDPOINT) logger.warning('force option is set, calling destroy() on existing instance id {}'.format(machine_info['machine_id'])) else: exit(1) try: - instance_dict = sporestackv2.client.launch(config['name'], + instance_dict = sporestack.client.launch(config['name'], config['sporestack_days'], # days, 5, # disk, 1, # memory, @@ -561,7 +561,7 @@ def validate_digitalocean(): '/128', # ipv6, 1, # bandwidth, 'digitalocean.sporestack.com', # host=None, - sporestackv2.client.API_ENDPOINT, # api_endpoint=API_ENDPOINT, + sporestack.client.API_ENDPOINT, # api_endpoint=API_ENDPOINT, 1, # cores=1, config['sporestack_currency'], # currency='bch', config['region'], # region=None, From 3db44a12cec3e48c35748ab701ffcf75809e6757 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 14 Jun 2021 10:04:58 +0400 Subject: [PATCH 3/3] update droplet image, update commands to work with recent ubuntu version --- stand-up.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stand-up.py b/stand-up.py index c1e0973..e3146a6 100755 --- a/stand-up.py +++ b/stand-up.py @@ -21,7 +21,7 @@ argparser.add_argument("--name", "-n", help="slug name (default: %(default)s)", default='investig') argparser.add_argument("--region", "-r", help="region or zone (default: selects random region/zone)", default='random') argparser.add_argument("--size", "-s", help="slug size or machine type (default: %(default)s)", default='2gb') -argparser.add_argument("--image", help="slug image (default: %(default)s)", default='ubuntu-16-04-x64') +argparser.add_argument("--image", help="slug image (default: %(default)s)", default='ubuntu-20-04-x64') argparser.add_argument("--user", "-u", help="username to use for ssh connection (default: %(default)s)", default='root') argparser.add_argument("--ssh-port", help="port to use for ssh connection (default: %(default)s)", default=22, type=int) argparser.add_argument("--ssh-connection-tries", help="how many times to try to establish ssh connection (default: %(default)s)", default=30, type=int) @@ -649,7 +649,7 @@ def validate_digitalocean(): echo \"deb http://http.kali.org/kali kali-rolling main non-free contrib\" > /etc/apt/sources.list.d/kali.list && \ echo \"deb-src http://http.kali.org/kali kali-rolling main non-free contrib\" >> /etc/apt/sources.list.d/kali.list && \ export DEBIAN_FRONTEND=noninteractive; apt-get -q update && \ - apt-get -o Dpkg::Options::=\"--force-overwrite\" -yq install console-setup-linux") + apt-get -o Dpkg::Options::=\"--force-overwrite\" -yq install console-setup-linux software-properties-common") logger.debug("".join(stdout.readlines())) if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read())) printProgressBar(12) @@ -664,7 +664,7 @@ def validate_digitalocean(): printProgressBar(13) logger.info('installing tools "{}"'.format(standard_tools)) - stdin, stdout, stderr = ssh.exec_command("export DEBIAN_FRONTEND=noninteractive; apt-get -yq install {}".format("zlib1g-dev ruby-dev python-pip")) + stdin, stdout, stderr = ssh.exec_command("export DEBIAN_FRONTEND=noninteractive; apt-get -yq install {}".format("zlib1g-dev ruby-dev python3-pip")) logger.debug("".join(stdout.readlines())) if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read())) @@ -712,7 +712,7 @@ def validate_digitalocean(): logger.info('installing wallet {}'.format(item)) if item == 'monero': - stdin, stdout, stderr = ssh.exec_command("curl -L -o linux64.tar.bz2 https://downloads.getmonero.org/cli/linux64 && tar xf linux64.tar.bz2") + stdin, stdout, stderr = ssh.exec_command("curl -L -o linux64.tar.bz2 https://downloads.getmonero.org/cli/linux64 && tar xf linux64.tar.bz2 && rm linux64.tar.bz2") logger.debug("".join(stdout.readlines())) if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read())) printProgressBar(18) @@ -768,7 +768,7 @@ def validate_digitalocean(): print("\nsocks5 {} {} user {}".format(instance_ip, 1080, proxy_password)) if service == 'wireguard': - stdin, stdout, stderr = ssh.exec_command("export DEBIAN_FRONTEND=noninteractive; add-apt-repository -yu ppa:wireguard/wireguard && apt-get -yq install wireguard") + stdin, stdout, stderr = ssh.exec_command("export DEBIAN_FRONTEND=noninteractive; apt-get -yq install wireguard") logger.debug("".join(stdout.readlines())) if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read())) sftp = ssh.open_sftp()