From 8a398cfa8fed0369cd0fc42b16f1bd8bc6bfa7b4 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Thu, 18 Jun 2020 14:12:08 +0200 Subject: remove add_config.py --- src/add_config.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100755 src/add_config.py diff --git a/src/add_config.py b/src/add_config.py deleted file mode 100755 index 4fd4feb..0000000 --- a/src/add_config.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/python3 - -from sys import argv -import yaml -import psycopg2 -import hashlib - -db_config_path = '/etc/0tdns/db_connection_config.yml' - -ovpn_config_path = argv[1] - -with open(ovpn_config_path) as file: - ovpn_config_text = file.read() - -ovpn_config_raw = bytearray(ovpn_config_text, encoding='utf-8') - -ovpn_config_hash = hashlib.sha256(ovpn_config_raw).hexdigest() - -config = yaml.safe_load(open(db_config_path, 'r')) -connection = psycopg2.connect(user=config['user'], password=config['password'], - host=config['host'], port=config['port'], - database=config['database']) -cursor = connection.cursor() - -cursor.execute(''' -INSERT INTO vpn (location_id, ovpn_config, ovpn_config_sha256) -VALUES(%s, %s, %s)''', (11, ovpn_config_text, ovpn_config_hash)) - -connection.commit() -cursor.close() -connection.close() -- cgit v1.2.3