From c9f512bc4fec4646b404e90d43b3377d32e75680 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 17 Dec 2018 15:26:27 +0100 Subject: [PATCH] first import --- bin/check-compose-ovh-credentials | 47 +++++++++++++++++++++++++++++++ bin/update | 19 +++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 bin/check-compose-ovh-credentials create mode 100755 bin/update diff --git a/bin/check-compose-ovh-credentials b/bin/check-compose-ovh-credentials new file mode 100755 index 0000000..8dc1988 --- /dev/null +++ b/bin/check-compose-ovh-credentials @@ -0,0 +1,47 @@ +#!/usr/bin/env python +## -*- encoding: utf-8 -*- + +import ovh +import yaml +import sys +import os.path + +# Instantiate. Visit https://api.ovh.com/createToken/index.cgi?GET=/me +# to get your credentials + +def main(argv): + + if len(argv) == 1: + sys.stderr.write("Error: provide a YAML compose file as first argument.\n") + exit(1) + + if not os.path.exists(argv[1]): + sys.stderr.write("Error: file '%s' not found.\n" % argv[0]) + sys.stderr.write("Error: provide a YAML compose file as first argument.\n") + exit(1) + + try: + with open(sys.argv[1], 'r') as stream: + yml = yaml.load(stream) + except Exception: + sys.stderr.write("Error: provide a YAML compose file as first argument.\n") + exit(1) + + ovh_cfg = yml["letsencrypt"]["options"]["env"]["ovh"] + client = ovh.Client( + endpoint=ovh_cfg["entrypoint"], + application_key=ovh_cfg["application"]["key"], + application_secret=ovh_cfg["application"]["secret"], + consumer_key=ovh_cfg["consumer_key"], + ) + + # Print nice welcome message + print "Welcome", client.get('/me')['firstname'] + domains = client.get('/domain/zone') + print "Domains:" + for domain in domains: + print " - %s" % domain + + +if __name__ == "__main__": + main(sys.argv) diff --git a/bin/update b/bin/update new file mode 100755 index 0000000..354e1f4 --- /dev/null +++ b/bin/update @@ -0,0 +1,19 @@ +#!/bin/bash + +. /etc/shlib + +include common +include pretty + + +Wrap -d "Updating 0k-charms" <