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.

66 lines
1.6 KiB

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