Initial commit
This commit is contained in:
commit
72a08e758b
6
config.py
Normal file
6
config.py
Normal file
@ -0,0 +1,6 @@
|
||||
GITLAB_HOST = "leviathan.local"
|
||||
GITLAB_KEY = "Escape-Anything-These-Company-3"
|
||||
GITLAB_SSH_PORT = 2200
|
||||
|
||||
LISTENER_ADDRESS = "0.0.0.0"
|
||||
LISTENER_PORT = 9001
|
31
gitlab-listener
Executable file
31
gitlab-listener
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from subprocess import call
|
||||
|
||||
import config
|
||||
|
||||
MY_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
try:
|
||||
from flask import Flask, request
|
||||
except ImportError:
|
||||
call(". " + os.path.join(MY_DIR, "venv", "bin", "activate") + "; " + " ".join(sys.argv), shell=True)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
COMMAND = os.path.join(MY_DIR, "update-keys")
|
||||
|
||||
@app.route("/", methods=['POST'])
|
||||
def commit ():
|
||||
key = request.args.get('key', '')
|
||||
if not key == config.GITLAB_KEY:
|
||||
return "not ok"
|
||||
|
||||
time.sleep(1)
|
||||
call([COMMAND])
|
||||
return "ok"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host=config.LISTENER_ADDRESS, port=config.LISTENER_PORT)
|
14
gitlab-shell
Executable file
14
gitlab-shell
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
import config
|
||||
|
||||
command = " ".join(sys.argv)
|
||||
|
||||
if 'SSH_ORIGINAL_COMMAND' in os.environ:
|
||||
command = "SSH_ORIGINAL_COMMAND='" + os.environ['SSH_ORIGINAL_COMMAND'] + "' " + command
|
||||
|
||||
subprocess.call(["ssh", "git@{}".format(config.GITLAB_HOST), "-p", "{}".format(config.GITLAB_SSH_PORT), command])
|
5
setup
Executable file
5
setup
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
virtualenv venv
|
||||
. venv/bin/activate
|
||||
pip install Flask
|
12
update-keys
Executable file
12
update-keys
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
import config
|
||||
|
||||
keys = subprocess.check_output(["ssh", "git@{}".format(config.GITLAB_HOST), "-p", "{}".format(config.GITLAB_SSH_PORT), "cat", ".ssh/authorized_keys"])
|
||||
|
||||
with open("/home/git/.ssh/authorized_keys", "w") as ak:
|
||||
ak.write(keys)
|
Loading…
x
Reference in New Issue
Block a user