freedombone-utils-monkeysphere 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # monkeysphere functions
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2014-2018 Bob Mottram <bob@freedombone.net>
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. function install_monkeysphere {
  29. if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
  30. return
  31. fi
  32. apt-get -yq install monkeysphere msva-perl
  33. #su -c "monkeysphere gen-subkey $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME
  34. mkdir "/home/$MY_USERNAME/.monkeysphere"
  35. chmod 755 "/home/$MY_USERNAME/.monkeysphere"
  36. echo "$MY_NAME <${MY_EMAIL_ADDRESS}>" > "/home/$MY_USERNAME/.monkeysphere/authorized_user_ids"
  37. chmod 644 "/home/$MY_USERNAME/.monkeysphere/authorized_user_ids"
  38. chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.monkeysphere"
  39. monkeysphere-authentication update-users
  40. if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
  41. echo $'monkeysphere import: ssh host key not found'
  42. exit 76295
  43. fi
  44. monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key "ssh://$DEFAULT_DOMAIN_NAME"
  45. SSH_ONION_HOSTNAME=$(grep 'ssh onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
  46. monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key "ssh://$SSH_ONION_HOSTNAME"
  47. if [ ! "$MY_GPG_PUBLIC_KEY_ID" ]; then
  48. MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$HOSTNAME")
  49. if [ ${#MY_GPG_PUBLIC_KEY_ID} -lt 4 ]; then
  50. echo $"monkeysphere unable to get GPG key ID for user $MY_USERNAME@$HOSTNAME"
  51. exit 52825
  52. fi
  53. fi
  54. # The admin user is the identity certifier
  55. fpr=$(gpg --with-colons --fingerprint "$MY_GPG_PUBLIC_KEY_ID" | grep fpr | head -n 1 | awk -F ':' '{print $10}')
  56. monkeysphere-authentication add-identity-certifier "$fpr"
  57. mark_completed "${FUNCNAME[0]}"
  58. }
  59. # NOTE: deliberately no exit 0