freedombone-upgrade 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. if [ -f /usr/bin/backupdatabases ]; then
  53. if grep -q "cat /root/dbpass" /usr/bin/backupdatabases; then
  54. # update to using the password manager
  55. sed -i "s|cat /root/dbpass|${PROJECT_NAME}-pass -u root -a mariadb|g" /usr/bin/backupdatabases
  56. fi
  57. fi
  58. #update-ca-certificates
  59. if [ ! -d "$PROJECT_DIR" ]; then
  60. git_clone "$PROJECT_REPO" "$PROJECT_DIR"
  61. fi
  62. if [ -d "$PROJECT_DIR" ]; then
  63. if [ -f "$CONFIGURATION_FILE" ]; then
  64. cd "$PROJECT_DIR" || exit 246823484
  65. rm -rf "$PROJECT_DIR/locale/"*
  66. if [[ "$CURRENT_BRANCH" == *"master" ]]; then
  67. git_pull $PROJECT_REPO
  68. else
  69. git_pull $PROJECT_REPO origin/$DEVELOPMENT_BRANCH
  70. fi
  71. git checkout stretch
  72. make install
  73. if [ -d /usr/share/${PROJECT_NAME} ]; then
  74. chown -R root:root /usr/share/${PROJECT_NAME}
  75. chmod -R +r /usr/share/${PROJECT_NAME}
  76. fi
  77. if ! ${PROJECT_NAME} -c "$CONFIGURATION_FILE"; then
  78. exit 453536
  79. fi
  80. #rebuild_exim_with_socks
  81. update_inadyn_config
  82. torrc_migrate
  83. nodejs_upgrade
  84. apt-get -yq -t stretch-backports install certbot
  85. email_install_tls
  86. email_disable_chunking
  87. rm /etc/exim4/exim4.conf.template.bak*
  88. email_update_onion_domain
  89. prevent_mail_process_overrun
  90. #defrag_filesystem
  91. # reinstall tor from backports
  92. tor_version=$(tor --version)
  93. if [[ "$tor_version" == *' 0.2'* ]]; then
  94. echo 'N' | apt-get -yq -t stretch-backports install tor
  95. systemctl restart tor
  96. fi
  97. fi
  98. fi
  99. # If logging was left on then turn it off
  100. ${PROJECT_NAME}-logging off
  101. # deliberately there is no 'exit 0' here