Ein für Shopware 6 vorbereitet Systemmanagment.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

  1. #!/bin/bash
  2. function usage {
  3. echo
  4. echoMainTitle "Create, move the ssh keys and install them to server"
  5. echo
  6. echoSubTitle "Usage:"
  7. echo
  8. echo "project-manager ssh:add-key [project-shortname] [env]"
  9. echo
  10. echo " [env] could be live, stage or git"
  11. echo
  12. echo "--help Prints this message"
  13. echo
  14. }
  15. source "$project_manager_dir/bin/includes/project_header"
  16. env="$(getArgument "$2" "$(usage)" "live stage git")"
  17. sshValidate
  18. ssh_private_key="$(sshGetConfig "$env" "private_key")"
  19. ssh_public_key="$(sshGetConfig "$env" "public_key")"
  20. ssh_user="$(sshGetConfig "$env" "user")"
  21. ssh_domain="$(sshGetConfig "$env" "domain")"
  22. echo
  23. echoMainTitle "Adding SSH Keys"
  24. echo
  25. echoSubTitle "Please verify data"
  26. echo
  27. echo "-- $env"
  28. echo "Private key: $ssh_private_key"
  29. echo "Public key: $ssh_public_key"
  30. echo
  31. confirm
  32. if [ "$ssh_private_key" != "" ]
  33. then
  34. target="$app_dir/.ssh/$env"
  35. if [ -f "$source" ] && [ ! -f "$target" ]
  36. then
  37. cp "$ssh_private_key" "target"
  38. chmod 0600 "$target"
  39. fi
  40. fi
  41. if [ "$ssh_public_key" != "" ]
  42. then
  43. target="$app_dir/.ssh/$env.pub"
  44. if [ -f "$source" ] && [ ! -f "$target" ]
  45. then
  46. cp "$ssh_public_key" "target"
  47. chmod 0600 "$target"
  48. fi
  49. fi
  50. if [ "$ssh_private_key" == "" ] && [ "$ssh_public_key" == "" ] && [ ! -f "$app_dir/.ssh/$env" ] && [ ! -f "$app_dir/.ssh/$env.pub" ]
  51. then
  52. ssh-keygen -b 4096 -t rsa -f "$app_dir/.ssh/$env" -q -N ""
  53. chmod 0600 "$app_dir/.ssh/$env"
  54. chmod 0600 "$app_dir/.ssh/$env.pub"
  55. ssh-copy-id -i "$app_dir/.ssh/$env.pub" "$ssh_user"@"$ssh_domain"
  56. fi
  57. ssh-add "$app_dir/.ssh/$env"