diff options
| author | Egor Tensin <egor@tensin.name> | 2026-10-14 15:59:48 +0500 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-10-14 15:59:48 +0500 |
| commit | 36dabd454bf137f74ab7c3e372b060a4ded7f284 (patch) | |
| tree | 8afec689f3e3d2bdfeb5f90bdc859fa4fb1e5840 /test/integration/docker/git_server/setup.sh | |
| parent | add CHANGELOG.md (diff) | |
| download | cgitize-36dabd454bf137f74ab7c3e372b060a4ded7f284.tar.gz cgitize-36dabd454bf137f74ab7c3e372b060a4ded7f284.zip | |
t/i/docker: move SSH setup to git_server
Diffstat (limited to '')
| -rwxr-xr-x | test/integration/docker/git_server/setup.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/test/integration/docker/git_server/setup.sh b/test/integration/docker/git_server/setup.sh new file mode 100755 index 0000000..f2572ff --- /dev/null +++ b/test/integration/docker/git_server/setup.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit lastpipe + +readonly ssh_dir=/ssh +readonly ssh_client_password='password' + +configure_git() { + echo + echo ---------------------------------------------------------------------- + echo Configuring git + echo ---------------------------------------------------------------------- + + git config --global user.name 'John Doe' + git config --global user.email 'John.Doe@example.com' + git config --global init.defaultBranch main +} + +generate_ssh_keys() { + echo + echo ---------------------------------------------------------------------- + echo Generating SSH keys + echo ---------------------------------------------------------------------- + + mkdir -p -- "$ssh_dir" + + ssh-keygen -t rsa -b 4096 -f "$ssh_dir/client_key" -N "$ssh_client_password" + ssh-keygen -t rsa -b 4096 -f "$ssh_dir/server_key" -N '' + + mkdir ~/.ssh + + cp "$ssh_dir/server_key" /etc/ssh/ssh_host_ed25519_key + cp "$ssh_dir/server_key.pub" /etc/ssh/ssh_host_ed25519_key.pub + cp "$ssh_dir/client_key.pub" ~/.ssh/authorized_keys + + chmod 0600 -- /etc/ssh/ssh_host_ed25519_key + chmod 0700 -- ~/.ssh/ + chmod 0600 -- ~/.ssh/authorized_keys +} + +readonly repo_path="$HOME/test_repo" + +create_repo() { + echo + echo ---------------------------------------------------------------------- + echo Setting up upstream repository + echo ---------------------------------------------------------------------- + + mkdir -p -- "$repo_path" + pushd -- "$repo_path" > /dev/null + git init + echo '1' > 1.txt + git add . + git commit -m 'first commit' + echo '2' > 2.txt + git add . + git commit -m 'second commit' + popd > /dev/null +} + +main() { + configure_git + generate_ssh_keys + create_repo +} + +main |
