freedombone-upgrade 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Command to upgrade the system
  12. # License
  13. # =======
  14. #
  15. # Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
  16. #
  17. # This program is free software: you can redistribute it and/or modify
  18. # it under the terms of the GNU Affero General Public License as published by
  19. # the Free Software Foundation, either version 3 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # This program is distributed in the hope that it will be useful,
  23. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. # GNU Affero General Public License for more details.
  26. #
  27. # You should have received a copy of the GNU Affero General Public License
  28. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. PROJECT_NAME='freedombone'
  30. PROJECT_DIR="$HOME/${PROJECT_NAME}"
  31. # An optional configuration file which overrides some of these variables
  32. CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
  33. PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
  34. CURRENT_BRANCH=master
  35. # clear temporary files
  36. rm -rf /tmp/*
  37. UTILS_FILES="/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*"
  38. for f in $UTILS_FILES
  39. do
  40. source "$f"
  41. done
  42. source "/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-email"
  43. read_config_param PROJECT_REPO
  44. read_config_param DEVELOPMENT_BRANCH
  45. read_config_param DEFAULT_DOMAIN_NAME
  46. DEVELOPMENT_BRANCH=master
  47. write_config_param "DEVELOPMENT_BRANCH" "$DEVELOPMENT_BRANCH"
  48. if [ $DEVELOPMENT_BRANCH ]; then
  49. if [ ${#DEVELOPMENT_BRANCH} -gt 0 ]; then
  50. CURRENT_BRANCH=$DEVELOPMENT_BRANCH
  51. fi
  52. fi
  53. if [ -f /usr/bin/backupdatabases ]; then
  54. if grep -q "cat /root/dbpass" /usr/bin/backupdatabases; then
  55. # update to using the password manager
  56. sed -i "s|cat /root/dbpass|freedombone-pass -u root -a mariadb|g" /usr/bin/backupdatabases
  57. fi
  58. fi
  59. #update-ca-certificates
  60. if [ ! -d "$PROJECT_DIR" ]; then
  61. git_clone "$PROJECT_REPO" "$PROJECT_DIR"
  62. fi
  63. if [ -d "$PROJECT_DIR" ]; then
  64. if [ -f "$CONFIGURATION_FILE" ]; then
  65. cd "$PROJECT_DIR" || exit 246823484
  66. rm -rf "$PROJECT_DIR/locale/"*
  67. if [[ "$CURRENT_BRANCH" == *"master" ]]; then
  68. git_pull $PROJECT_REPO
  69. else
  70. git_pull $PROJECT_REPO origin/$DEVELOPMENT_BRANCH
  71. fi
  72. git checkout stretch
  73. make install
  74. if [ -d /usr/share/${PROJECT_NAME} ]; then
  75. chown -R root:root /usr/share/${PROJECT_NAME}
  76. chmod -R +r /usr/share/${PROJECT_NAME}
  77. fi
  78. if ! ${PROJECT_NAME} -c "$CONFIGURATION_FILE"; then
  79. exit 453536
  80. fi
  81. #rebuild_exim_with_socks
  82. apt-get -yq -t stretch-backports install certbot
  83. email_install_tls
  84. email_disable_chunking
  85. rm /etc/exim4/exim4.conf.template.bak*
  86. #defrag_filesystem
  87. # reinstall tor from backports
  88. tor_version=$(tor --version)
  89. if [[ "$tor_version" == *' 0.2'* ]]; then
  90. echo 'N' | apt-get -yq -t stretch-backports install tor
  91. systemctl restart tor
  92. fi
  93. fi
  94. fi
  95. # If logging was left on then turn it off
  96. ${PROJECT_NAME}-logging off
  97. # deliberately there is no 'exit 0' here