freedombone-utils-upgrade 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Upgrading functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
  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. # name of a script used to upgrade the system
  31. UPGRADE_SCRIPT_NAME="${PROJECT_NAME}-upgrade"
  32. function create_upgrade_script {
  33. if [ -f /usr/local/bin/${PROJECT_NAME}-upgrade ]; then
  34. cp /usr/local/bin/${PROJECT_NAME}-upgrade /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
  35. else
  36. cp /usr/bin/${PROJECT_NAME}-upgrade /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
  37. fi
  38. if grep -Fxq "create_upgrade_script" $COMPLETION_FILE; then
  39. return
  40. fi
  41. apt-get -y install unattended-upgrades
  42. echo 'create_upgrade_script' >> $COMPLETION_FILE
  43. }
  44. function upgrade_installation_from_previous_versions {
  45. if [ ! -f $COMPLETION_FILE ]; then
  46. return
  47. fi
  48. if grep -Fxq "upgrade_installation_from_previous_versions" $COMPLETION_FILE; then
  49. return
  50. fi
  51. # upgrade from previous versions to stockholm
  52. sed -i 's|configure_email|install_email|g' $COMPLETION_FILE
  53. sed -i 's|install_dlna_server|install_dlna|g' $COMPLETION_FILE
  54. sed -i 's|install_gnu_social_theme|install_gnusocial_theme|g' $COMPLETION_FILE
  55. sed -i 's|install_gnu_social|install_gnusocial|g' $COMPLETION_FILE
  56. sed -i 's|install_irc_server|install_irc|g' $COMPLETION_FILE
  57. sed -i 's|voip_turn|turn|g' $COMPLETION_FILE
  58. sed -i 's|install_voip|install_mumble|g' $COMPLETION_FILE
  59. sed -i 's|install_rss_reader|install_rss|g' $COMPLETION_FILE
  60. sed -i 's|install_tox_node|install_tox|g' $COMPLETION_FILE
  61. sed -i 's|intrusion_detection|install_tripwire|g' $COMPLETION_FILE
  62. sed -i 's|GNU Social|gnusocial|g' $COMPLETION_FILE
  63. sed -i 's|XMPP|xmpp|g' $COMPLETION_FILE
  64. sed -i 's|voip|mumble|g' $COMPLETION_FILE
  65. sed -i 's|VoIP|mumble|g' $COMPLETION_FILE
  66. sed -i 's|SIP|sip|g' $COMPLETION_FILE
  67. if [ -f /usr/local/bin/zeronetavahi ]; then
  68. rm /usr/local/bin/zeronetavahi
  69. fi
  70. echo 'upgrade_installation_from_previous_versions' >> $COMPLETION_FILE
  71. }
  72. # NOTE: deliberately no exit 0