From cfa6e98a33e89291b19376e9e1ab25510afdfb7d Mon Sep 17 00:00:00 2001 From: jwansek Date: Mon, 19 Sep 2022 17:19:13 +0100 Subject: Added metadata file --- del_repo | 9 ++++----- gitscripts.conf.example | 3 ++- klaus/Dockerfile | 11 +++++++++++ klaus/app.py | 12 ++++++++++++ klaus/docker-compose.yml | 16 ++++++++++++++++ klaus/requirements.txt | 2 ++ make_repo.py | 11 +++++++++++ 7 files changed, 58 insertions(+), 6 deletions(-) create mode 100755 klaus/Dockerfile create mode 100755 klaus/app.py create mode 100755 klaus/docker-compose.yml create mode 100755 klaus/requirements.txt diff --git a/del_repo b/del_repo index 4bf9cca..9fb038f 100755 --- a/del_repo +++ b/del_repo @@ -1,9 +1,8 @@ #!/bin/bash -echo -n "Input repo name to delete: " +echo -n "Input repo name to delete (excluding the .git suffix): " read repo -rm -fvr /srv/git/$repo -rm -fvr ~/$repo -rm -fvr ~/$repo.git - +rm -fvr /srv/git/$repo.git +rm -fvr ~/$repo* +rm -fv /srv/www/repositories/$repo* diff --git a/gitscripts.conf.example b/gitscripts.conf.example index a2596a4..4acf70d 100755 --- a/gitscripts.conf.example +++ b/gitscripts.conf.example @@ -1,9 +1,10 @@ [git] repo_path = /srv/git +repo_meta_path = /srv/www/repositories domain = git.eda.gay gitignore_templates = /srv/www/gitignore license_templates = /srv/www/license-templates/templates [github] user = jwansek -key = ****************************** \ No newline at end of file +key = ****************************** diff --git a/klaus/Dockerfile b/klaus/Dockerfile new file mode 100755 index 0000000..bfaca80 --- /dev/null +++ b/klaus/Dockerfile @@ -0,0 +1,11 @@ +FROM jonashaag/klaus:latest +MAINTAINER Eden Attenborough "eda@e.email" +ENV TZ=Europe/London +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +COPY . /app +WORKDIR /app +RUN pip3 install -r requirements.txt +ENTRYPOINT ["python3"] +CMD ["app.py"] + diff --git a/klaus/app.py b/klaus/app.py new file mode 100755 index 0000000..3ddd08b --- /dev/null +++ b/klaus/app.py @@ -0,0 +1,12 @@ +import configparser +import waitress +import klaus +import os + +repositories = ["/srv/git/git-scripts.git", "/srv/git/anExampleRepo%21.git"] + + +if __name__ == "__main__": + app = klaus.make_app(repositories, "Eden's git server - Repositories") + waitress.serve(app, host = "0.0.0.0", port = 80, threads = int(os.environ["APP_THREADS"])) + diff --git a/klaus/docker-compose.yml b/klaus/docker-compose.yml new file mode 100755 index 0000000..e980485 --- /dev/null +++ b/klaus/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + klaus: + container_name: klaus + build: + context: . + dockerfile: Dockerfile + image: jwansek/klaus + user: "1002:1000" + environment: + - APP_THREADS=4 + volumes: + - '/media/git:/srv/git:ro' + ports: + - '81:80' diff --git a/klaus/requirements.txt b/klaus/requirements.txt new file mode 100755 index 0000000..dbdd421 --- /dev/null +++ b/klaus/requirements.txt @@ -0,0 +1,2 @@ +waitress + diff --git a/make_repo.py b/make_repo.py index f40ed9a..6d8f3eb 100755 --- a/make_repo.py +++ b/make_repo.py @@ -64,6 +64,17 @@ with ChangeCWD(repo_dir): subprocess.run(["ln", "-s", os.path.join(os.path.dirname(conf_path), "post-receive-hook.sh"), os.path.join(repo_dir, "hooks", "post-receive")]) +repo_metadata_path = os.path.join(CONFIG.get("git", "repo_meta_path"), repo_name + ".conf") +repo_metadata = configparser.ConfigParser() +repo_metadata[repo_name] = { + "name": repo_name, + "path": repo_dir, + "visible": not private, + "url": repo_url +} +with open(repo_metadata_path, "w") as f: + repo_metadata.write(f) + if input("Would you like the repository to remain bare? Useful for making mirrors of Github repos. : ").lower() != "y": with tempfile.TemporaryDirectory() as tempdir: subprocess.run(["git", "clone", repo_url, tempdir]) -- cgit v1.2.3