freedombone-upgrade 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # Command to upgrade the system
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2015-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. PROJECT_NAME='freedombone'
  29. PROJECT_DIR="$HOME/${PROJECT_NAME}"
  30. # An optional configuration file which overrides some of these variables
  31. CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
  32. PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
  33. CURRENT_BRANCH=master
  34. # clear temporary files
  35. rm -rf /tmp/*
  36. UTILS_FILES="/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*"
  37. for f in $UTILS_FILES
  38. do
  39. source "$f"
  40. done
  41. source "/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-email"
  42. read_config_param PROJECT_REPO
  43. read_config_param DEVELOPMENT_BRANCH
  44. read_config_param DEFAULT_DOMAIN_NAME
  45. DEVELOPMENT_BRANCH=master
  46. write_config_param "DEVELOPMENT_BRANCH" "$DEVELOPMENT_BRANCH"
  47. if [ $DEVELOPMENT_BRANCH ]; then
  48. if [ ${#DEVELOPMENT_BRANCH} -gt 0 ]; then
  49. CURRENT_BRANCH=$DEVELOPMENT_BRANCH
  50. fi
  51. fi
  52. # upgrading file prevents USB canary from activating
  53. if [ ! -f /tmp/.upgrading ]; then
  54. touch /tmp/.upgrading
  55. fi
  56. if [ -f /usr/bin/backupdatabases ]; then
  57. if grep -q "cat /root/dbpass" /usr/bin/backupdatabases; then
  58. # update to using the password manager
  59. sed -i "s|cat /root/dbpass|${PROJECT_NAME}-pass -u root -a mariadb|g" /usr/bin/backupdatabases
  60. fi
  61. fi
  62. #update-ca-certificates
  63. if [ ! -d "$PROJECT_DIR" ]; then
  64. git_clone "$PROJECT_REPO" "$PROJECT_DIR"
  65. fi
  66. if [ -d "$PROJECT_DIR" ]; then
  67. if [ -f "$CONFIGURATION_FILE" ]; then
  68. cd "$PROJECT_DIR" || exit 246823484
  69. rm -rf "$PROJECT_DIR/locale/"*
  70. if [[ "$CURRENT_BRANCH" == *"master" ]]; then
  71. git_pull $PROJECT_REPO
  72. else
  73. git_pull $PROJECT_REPO origin/$DEVELOPMENT_BRANCH
  74. fi
  75. git checkout stretch
  76. make install
  77. if [ -d /usr/share/${PROJECT_NAME} ]; then
  78. chown -R root:root /usr/share/${PROJECT_NAME}
  79. chmod -R +r /usr/share/${PROJECT_NAME}
  80. fi
  81. if ! ${PROJECT_NAME} -c "$CONFIGURATION_FILE"; then
  82. rm /tmp/.upgrading
  83. exit 453536
  84. fi
  85. #rebuild_exim_with_socks
  86. install_dynamicdns
  87. torrc_migrate
  88. nodejs_upgrade
  89. apt-get -yq -t stretch-backports install certbot
  90. email_install_tls
  91. email_disable_chunking
  92. rm /etc/exim4/exim4.conf.template.bak*
  93. email_update_onion_domain
  94. prevent_mail_process_overrun
  95. #defrag_filesystem
  96. # reinstall tor from backports
  97. tor_version=$(tor --version)
  98. if [[ "$tor_version" == *' 0.2'* ]]; then
  99. echo 'N' | apt-get -yq -t stretch-backports install tor
  100. systemctl restart tor
  101. fi
  102. fi
  103. fi
  104. # If logging was left on then turn it off
  105. ${PROJECT_NAME}-logging off
  106. # upgrading file prevents USB canary from activating
  107. if [ -f /tmp/.upgrading ]; then
  108. rm /tmp/.upgrading
  109. fi
  110. # deliberately there is no 'exit 0' here