Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

gitnonymous-setup 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. # figure out which directory we are stored in
  3. # https://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
  4. _GITNONYMOUS_SRC="${BASH_SOURCE[0]}"
  5. # resolve $_GITNONYMOUS_SRC until the file is no longer a symlink
  6. while [ -h "$_GITNONYMOUS_SRC" ]; do
  7. dir="$( cd -P "$( dirname "$_GITNONYMOUS_SRC" )" && pwd )"
  8. _GITNONYMOUS_SRC="$(readlink "$_GITNONYMOUS_SRC")"
  9. # if $_GITNONYMOUS_SRC was a relative symlink, we need to resolve it
  10. # relative to the path where the symlink file was located
  11. [[ $_GITNONYMOUS_SRC != /* ]] && _GITNONYMOUS_SRC="$DIR/$_GITNONYMOUS_SRC"
  12. done
  13. dir="$( cd -P "$( dirname "$_GITNONYMOUS_SRC" )" && pwd )"
  14. unset _GITNONYMOUS_SRC
  15. # set up our other variables
  16. confdir="${HOME}/.gitnonymous-${1}"
  17. sshfile="${confdir}/ssh/identity"
  18. configfile="${confdir}/config"
  19. sshwrapperfile="${confdir}/git-ssh-wrap"
  20. if [ "$1" = "" -o '-h' = "$1" -o '--help' = "$1" ]
  21. then
  22. echo "Usage: $0 KEYNAME"
  23. else
  24. comment="${1}@anonymous"
  25. echo "-> Creating ${confdir}."
  26. mkdir -p "${confdir}/ssh"
  27. echo "-> Creating SSH key '${sshfile}'."
  28. echo "SSH key comment (public) is '${comment}'."
  29. ssh-keygen -C "${comment}" -f "${sshfile}"
  30. echo "-> Creating SSH wrapper '${sshwrapperfile}'."
  31. cat "${dir}/git-ssh-wrap" | sed "s/KEYNAME/${1}/" > "${sshwrapperfile}"
  32. chmod 755 "${sshwrapperfile}"
  33. echo "-> Creating config file '${configfile}'."
  34. cp ${dir}/config "${configfile}"
  35. echo "-> Pubkey follows:"
  36. echo
  37. cat ${sshfile}.pub
  38. echo
  39. echo " *** You should now edit '${configfile}' and set your own pseudonymous username and email. ***"
  40. echo
  41. echo "-> To use your new identity:"
  42. echo ". ${0/-setup/} ${id}"
  43. fi