freedombone-upgrade 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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-2016 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. FRIENDS_MIRRORS_SERVER=
  35. FRIENDS_MIRRORS_SSH_PORT=2222
  36. FRIENDS_MIRRORS_PASSWORD=
  37. MY_MIRRORS_PASSWORD=
  38. CURRENT_BRANCH=master
  39. # clear temporary files
  40. rm -rf /tmp/*
  41. UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
  42. for f in $UTILS_FILES
  43. do
  44. source $f
  45. done
  46. read_config_param PROJECT_REPO
  47. read_config_param DEVELOPMENT_BRANCH
  48. DEVELOPMENT_BRANCH=master
  49. write_config_param "DEVELOPMENT_BRANCH" "$DEVELOPMENT_BRANCH"
  50. if [ $DEVELOPMENT_BRANCH ]; then
  51. if [ ${#DEVELOPMENT_BRANCH} -gt 0 ]; then
  52. CURRENT_BRANCH=$DEVELOPMENT_BRANCH
  53. fi
  54. fi
  55. if grep -q "cat /root/dbpass" /usr/bin/backupdatabases; then
  56. # update to using the password manager
  57. sed -i "s|cat /root/dbpass|freedombone-pass -u root -a mariadb|g" /usr/bin/backupdatabases
  58. fi
  59. update-ca-certificates
  60. read_repo_servers
  61. #${PROJECT_NAME}-mirrors
  62. if [ ! -d $PROJECT_DIR ]; then
  63. git_clone $PROJECT_REPO $PROJECT_DIR
  64. fi
  65. if [ -d $PROJECT_DIR ]; then
  66. if [ -f $CONFIGURATION_FILE ]; then
  67. cd $PROJECT_DIR
  68. rm -rf $PROJECT_DIR/locale/*
  69. if [[ "$CURRENT_BRANCH" == *"master" ]]; then
  70. git_pull $PROJECT_REPO
  71. else
  72. git_pull $PROJECT_REPO origin/$DEVELOPMENT_BRANCH
  73. fi
  74. git checkout stretch
  75. make install
  76. if [ -d /usr/share/${PROJECT_NAME} ]; then
  77. chown -R root:root /usr/share/${PROJECT_NAME}
  78. chmod -R +r /usr/share/${PROJECT_NAME}
  79. fi
  80. ${PROJECT_NAME} -c $CONFIGURATION_FILE
  81. if [ ! "$?" = "0" ]; then
  82. lockdown_permissions
  83. exit 453536
  84. fi
  85. lockdown_permissions
  86. defrag_filesystem
  87. fi
  88. fi
  89. # If logging was left on then turn it off
  90. ${PROJECT_NAME}-logging off
  91. if [ -f /usr/bin/reset-tripwire ]; then
  92. echo '
  93. ' | reset-tripwire
  94. fi
  95. # deliberately there is no 'exit 0' here