freedombone-utils-monkeysphere 2.7KB

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