From 5a792fee1335ea60ca6930dddb6080bcf869213d Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 27 Mar 2021 23:17:14 +0300 Subject: further renaming work --- .ci/docker/docker-compose.yml | 6 +++--- .ci/local/test.sh | 22 +++++++++++----------- Dockerfile | 2 +- README.md | 22 +++++++++++----------- cgitize/cgit.py | 4 ++-- cgitize/main.py | 10 +++++----- cgitize/repo.py | 4 ++-- cgitize/utils.py | 4 ++-- examples/cgit-repos.conf | 24 ------------------------ examples/cgitize.conf | 24 ++++++++++++++++++++++++ systemd/cgit-repos.service | 13 ------------- systemd/cgit-repos.timer | 10 ---------- systemd/cgitize.service | 13 +++++++++++++ systemd/cgitize.timer | 10 ++++++++++ 14 files changed, 84 insertions(+), 84 deletions(-) delete mode 100644 examples/cgit-repos.conf create mode 100644 examples/cgitize.conf delete mode 100644 systemd/cgit-repos.service delete mode 100644 systemd/cgit-repos.timer create mode 100644 systemd/cgitize.service create mode 100644 systemd/cgitize.timer diff --git a/.ci/docker/docker-compose.yml b/.ci/docker/docker-compose.yml index e3bda62..6054764 100644 --- a/.ci/docker/docker-compose.yml +++ b/.ci/docker/docker-compose.yml @@ -11,6 +11,6 @@ services: dockerfile: Dockerfile image: client volumes: - - ./client/etc/:/etc/cgit-repos:ro - - "$SSH_AUTH_SOCK:/var/run/cgit-repos/ssh-agent.sock" - - ./client/output:/var/tmp/cgit-repos/output + - ./client/etc/:/etc/cgitize:ro + - "$SSH_AUTH_SOCK:/var/run/cgitize/ssh-agent.sock" + - ./client/output:/var/tmp/cgitize/output diff --git a/.ci/local/test.sh b/.ci/local/test.sh index 69a6458..43b9bbb 100755 --- a/.ci/local/test.sh +++ b/.ci/local/test.sh @@ -3,9 +3,9 @@ set -o errexit -o nounset -o pipefail readonly local_repo_path="$HOME/test_repo" -readonly cgit_repos_conf_path="$HOME/etc/cgit-repos/cgit-repos.conf" -readonly my_repos_path="$HOME/etc/cgit-repos/my_repos.py" -readonly output_path="$HOME/var/cgit-repos/output" +readonly cgitize_conf_path="$HOME/etc/cgitize/cgitize.conf" +readonly my_repos_path="$HOME/etc/cgitize/my_repos.py" +readonly output_path="$HOME/var/cgitize/output" setup_local_repo() { echo @@ -27,17 +27,17 @@ setup_local_repo() { popd > /dev/null } -setup_cgit_repos_conf() { +setup_cgitize_conf() { echo echo ---------------------------------------------------------------------- - echo cgit-repos.conf + echo cgitize.conf echo ---------------------------------------------------------------------- local conf_dir - conf_dir="$( dirname -- "$cgit_repos_conf_path" )" + conf_dir="$( dirname -- "$cgitize_conf_path" )" mkdir -p -- "$conf_dir" - cat < python3 -m cgitize.main --config path/to/cgit-repos.conf + > python3 -m cgitize.main --config path/to/cgitize.conf The repository list is stored in my_repos.py (the `my_repos` setting in the config). See [examples/my_repos.py] for an example. -cgit/repos/main.py calls git, which might call ssh internally. +cgitize/main.py calls git, which might call ssh internally. Make sure the required keys are loaded to a ssh-agent. -[examples/cgit-repos.conf]: examples/cgit-repos.conf +[examples/cgitize.conf]: examples/cgitize.conf [examples/my_repos.py]: examples/my_repos.py ### Docker The image is **egortensin/cgitize**. -The container reads the config from */etc/cgit-repos/cgit-repos.conf* and -writes the repositories to */var/tmp/cgit-repos/output*. +The container reads the config from */etc/cgitize/cgitize.conf* and +writes the repositories to */var/tmp/cgitize/output*. If SSH is required, the socket should be mapped to -*/var/run/cgit-repos/ssh-agent.sock*. +*/var/run/cgitize/ssh-agent.sock*. For example: > docker run -it --rm \ - -v "/path/to/config:/etc/cgit-repos:ro" \ - -v "$SSH_AUTH_SOCK:/var/run/cgit-repos/ssh-agent.sock" \ - -v "/path/to/output:/var/tmp/cgit-repos/output" \ + -v "/path/to/config:/etc/cgitize:ro" \ + -v "$SSH_AUTH_SOCK:/var/run/cgitize/ssh-agent.sock" \ + -v "/path/to/output:/var/tmp/cgitize/output" \ egortensin/cgitize ### my_repos.py diff --git a/cgitize/cgit.py b/cgitize/cgit.py index 778b1c9..6e287e9 100644 --- a/cgitize/cgit.py +++ b/cgitize/cgit.py @@ -1,6 +1,6 @@ # Copyright (c) 2018 Egor Tensin -# This file is part of the "cgit repos" project. -# For details, see https://github.com/egor-tensin/cgit-repos. +# This file is part of the "cgitize" project. +# For details, see https://github.com/egor-tensin/cgitize. # Distributed under the MIT License. from enum import Enum diff --git a/cgitize/main.py b/cgitize/main.py index 650c079..920b769 100644 --- a/cgitize/main.py +++ b/cgitize/main.py @@ -1,6 +1,6 @@ # Copyright (c) 2018 Egor Tensin -# This file is part of the "cgit repos" project. -# For details, see https://github.com/egor-tensin/cgit-repos. +# This file is part of the "cgitize" project. +# For details, see https://github.com/egor-tensin/cgitize. # Distributed under the MIT License. from argparse import ArgumentParser @@ -16,9 +16,9 @@ from cgitize.repo import BitbucketRepo, GithubRepo, Repo import cgitize.utils as utils -DEFAULT_OUTPUT_DIR = '/var/tmp/cgit-repos/output' -DEFAULT_CONFIG_PATH = '/etc/cgit-repos/cgit-repos.conf' -DEFAULT_MY_REPOS_PATH = '/etc/cgit-repos/my_repos.py' +DEFAULT_OUTPUT_DIR = '/var/tmp/cgitize/output' +DEFAULT_CONFIG_PATH = '/etc/cgitize/cgitize.conf' +DEFAULT_MY_REPOS_PATH = '/etc/cgitize/my_repos.py' @contextmanager diff --git a/cgitize/repo.py b/cgitize/repo.py index 4b3072c..02e283b 100644 --- a/cgitize/repo.py +++ b/cgitize/repo.py @@ -1,6 +1,6 @@ # Copyright (c) 2018 Egor Tensin -# This file is part of the "cgit repos" project. -# For details, see https://github.com/egor-tensin/cgit-repos. +# This file is part of the "cgitize" project. +# For details, see https://github.com/egor-tensin/cgitize. # Distributed under the MIT License. import abc diff --git a/cgitize/utils.py b/cgitize/utils.py index 84337e8..5ff8475 100644 --- a/cgitize/utils.py +++ b/cgitize/utils.py @@ -1,6 +1,6 @@ # Copyright (c) 2018 Egor Tensin -# This file is part of the "cgit repos" project. -# For details, see https://github.com/egor-tensin/cgit-repos. +# This file is part of the "cgitize" project. +# For details, see https://github.com/egor-tensin/cgitize. # Distributed under the MIT License. import contextlib diff --git a/examples/cgit-repos.conf b/examples/cgit-repos.conf deleted file mode 100644 index 94f73cd..0000000 --- a/examples/cgit-repos.conf +++ /dev/null @@ -1,24 +0,0 @@ -# All settings are optional. - -[DEFAULT] - -# /etc/cgit-repos/my_repos.py by default. -my_repos = /path/to/my_repos.py - -# /var/tmp/cgit-repos/output by default. -output = /path/to/output/ - -# URL to clone from the output directory. -# {repo_id} is substituted with the repository ID (in the NAME or SECTION/NAME -# format, etc.). -clone_url = http://example.com:8080/git/{repo_id} - -owner = Your Name - -[GITHUB] - -username = your-username - -[BITBUCKET] - -username = your-username diff --git a/examples/cgitize.conf b/examples/cgitize.conf new file mode 100644 index 0000000..a6ed701 --- /dev/null +++ b/examples/cgitize.conf @@ -0,0 +1,24 @@ +# All settings are optional. + +[DEFAULT] + +# /etc/cgitize/my_repos.py by default. +my_repos = /path/to/my_repos.py + +# /var/tmp/cgitize/output by default. +output = /path/to/output/ + +# URL to clone from the output directory. +# {repo_id} is substituted with the repository ID (in the NAME or SECTION/NAME +# format, etc.). +clone_url = http://example.com:8080/git/{repo_id} + +owner = Your Name + +[GITHUB] + +username = your-username + +[BITBUCKET] + +username = your-username diff --git a/systemd/cgit-repos.service b/systemd/cgit-repos.service deleted file mode 100644 index 12793d9..0000000 --- a/systemd/cgit-repos.service +++ /dev/null @@ -1,13 +0,0 @@ -# Adjust as you see fit. - -[Unit] -Description=Pull cgit repositories -Wants=ssh-agent.service - -[Service] -Type=simple -WorkingDirectory=%h/workspace/personal/cgit-repos -ExecStartPre=/usr/bin/truncate --size=0K -- %h/var/cgit-repos/cgit-repos.log -ExecStart=/usr/bin/python3 -m cgit.repos.main --config %h/etc/cgit-repos/cgit-repos.conf -StandardOutput=file:%h/var/cgit-repos/cgit-repos.log -StandardError=inherit diff --git a/systemd/cgit-repos.timer b/systemd/cgit-repos.timer deleted file mode 100644 index de56c5a..0000000 --- a/systemd/cgit-repos.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Pull cgit repositories periodically - -[Timer] -Persistent=false -OnCalendar=daily -AccuracySec=1 - -[Install] -WantedBy=timers.target diff --git a/systemd/cgitize.service b/systemd/cgitize.service new file mode 100644 index 0000000..0b517fc --- /dev/null +++ b/systemd/cgitize.service @@ -0,0 +1,13 @@ +# Adjust as you see fit. + +[Unit] +Description=Pull cgit repositories +Wants=ssh-agent.service + +[Service] +Type=simple +WorkingDirectory=%h/workspace/personal/cgitize +ExecStartPre=/usr/bin/truncate --size=0K -- %h/var/cgitize/cgitize.log +ExecStart=/usr/bin/python3 -m cgitize.main --config %h/etc/cgitize/cgitize.conf +StandardOutput=file:%h/var/cgitize/cgitize.log +StandardError=inherit diff --git a/systemd/cgitize.timer b/systemd/cgitize.timer new file mode 100644 index 0000000..de56c5a --- /dev/null +++ b/systemd/cgitize.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Pull cgit repositories periodically + +[Timer] +Persistent=false +OnCalendar=daily +AccuracySec=1 + +[Install] +WantedBy=timers.target -- cgit v1.2.3