1
0

entrypoint.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. set -eu
  3. if [ ! -f "$SSHD_HOST_KEYS_DIR/rsa" ]; then
  4. ssh-keygen -t rsa -b 4096 -N '' -f "$SSHD_HOST_KEYS_DIR/rsa"
  5. fi
  6. if [ ! -f "$SSHD_HOST_KEYS_DIR/ed25519" ]; then
  7. ssh-keygen -t ed25519 -N '' -f "$SSHD_HOST_KEYS_DIR/ed25519"
  8. fi
  9. unset SSHD_HOST_KEYS_DIR
  10. if [ ! -d "$HOME/.gitolite" ]; then
  11. # > First run: either the pubkey or the admin name is *required*, [...]
  12. (set -x; gitolite setup --admin "$GITOLITE_INITIAL_ADMIN_NAME")
  13. fi
  14. unset GITOLITE_INITIAL_ADMIN_NAME
  15. key_dir_path="$HOME/.container-entrypoint/users/public-keys"
  16. mkdir --parents "$key_dir_path"
  17. for var_name in $(compgen -e); do
  18. if [[ $var_name =~ ^GITOLITE_USER_PUBLIC_KEY_ ]]; then
  19. user="${var_name#GITOLITE_USER_PUBLIC_KEY_}"
  20. # https://github.com/sitaramc/gitolite/blob/v3.6.11/src/lib/Gitolite/Setup.pm#L93
  21. key_path="${key_dir_path}/${user}.pub"
  22. printenv "$var_name" > "$key_path"
  23. (set -x; gitolite setup --pubkey "$key_path")
  24. unset "$var_name"
  25. fi
  26. done
  27. set -x
  28. exec "$@"