freedombone-utils-final 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Final stage of install
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 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_final {
  31. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  32. return
  33. fi
  34. # unmount any attached usb drive
  35. if [ -d $USB_MOUNT ]; then
  36. umount $USB_MOUNT
  37. rm -rf $USB_MOUNT
  38. fi
  39. function_check split_gpg_key_into_fragments
  40. split_gpg_key_into_fragments
  41. lockdown_permissions
  42. mark_completed $FUNCNAME
  43. clear
  44. echo ''
  45. if [[ $ONION_ONLY == 'no' ]]; then
  46. echo $"
  47. If you wish to verify the server ssh public key at next login it is:
  48. $(get_ssh_server_key)
  49. Ensure that ports are forwarded from your internet router.
  50. You can find the list of ports within the firewall section of
  51. the administrator control panel.
  52. "
  53. else
  54. echo $"
  55. If you wish to verify the server ssh public key at next login it is:
  56. $(get_ssh_server_key)
  57. "
  58. fi
  59. echo ''
  60. # add user menu on ssh login
  61. if ! grep -q 'controluser' /home/$MY_USERNAME/.bashrc; then
  62. echo 'controluser' >> /home/$MY_USERNAME/.bashrc
  63. fi
  64. if [ ! -f $IMAGE_PASSWORD_FILE ]; then
  65. if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then
  66. create_wifi_startup_script
  67. echo ''
  68. echo $'Shutting down the system. Detatch the ethernet cable, attach wifi dongle, then power on again.'
  69. echo ''
  70. ${PROJECT_NAME}-logging off --restart
  71. systemctl poweroff
  72. return
  73. fi
  74. echo $'Turning off logging'
  75. ${PROJECT_NAME}-logging off --restart
  76. echo $'Rebooting the system'
  77. systemctl reboot -i
  78. fi
  79. echo $'Turning off logging'
  80. ${PROJECT_NAME}-logging off --restart
  81. }
  82. function update_installed_apps_list {
  83. # Why does this secondary file exist, apart from COMPLETION_FILE ?
  84. # It's so that it is visible to unprivileged users from the user control panel
  85. cat $COMPLETION_FILE | grep "install_" > /usr/share/${PROJECT_NAME}/installed.txt
  86. }
  87. function setup_final {
  88. function_check update_installed_apps_list
  89. update_installed_apps_list
  90. function_check install_tripwire
  91. install_tripwire
  92. function_check install_final
  93. install_final
  94. export DEBIAN_FRONTEND=
  95. }
  96. # NOTE: deliberately no exit 0