autowrupdate.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/sh
  2. ######################## CONFIG SECTION ########################
  3. #dialog
  4. DIALOG="dialog"
  5. #fetch software
  6. FETCH="/usr/bin/wget"
  7. #tar binary
  8. TAR="/usr/bin/tar"
  9. # path to your apache data dir
  10. APACHE_DATA_PATH="/var/www/html/"
  11. # wolf recorder path
  12. WOLFRECORDER_PATH="wr/"
  13. #update log file
  14. LOG_FILE="/var/log/wolfrecorderupdate.log"
  15. #restore point dir
  16. RESTORE_POINT="/tmp/wr_restore"
  17. #defaults
  18. WOLFRECORDER_RELEASE_URL="http://WolfRecorder.com/"
  19. WOLFRECORDER_RELEASE_NAME="wr.tgz"
  20. ######################## INTERFACE SECTION ####################
  21. if [ $# -ne 1 ]
  22. then
  23. #interactive mode
  24. $DIALOG --title "WolfRecorder update" --msgbox "This wizard help you to update your WolfRecorder installation to the the latest stable or current development release" 10 40
  25. clear
  26. $DIALOG --menu "Choose a WolfRecorder release branch to which you want to update." 11 65 6 \
  27. STABLE "WolfRecorder latest stable release (recommended)"\
  28. CURRENT "WolfRecorder current development snapshot"\
  29. 2> /tmp/auprelease
  30. clear
  31. BRANCH=`cat /tmp/auprelease`
  32. rm -fr /tmp/auprelease
  33. #last chance to exit
  34. $DIALOG --title "Check settings" --yesno "Are all of these settings correct? \n \n WolfRecorder release: ${BRANCH}\n Installation full path: ${APACHE_DATA_PATH}${WOLFRECORDER_PATH}\n" 9 70
  35. AGREE=$?
  36. clear
  37. else
  38. #getting branch from CLI 1st param in batch mode
  39. BRANCH=$1
  40. AGREE="0"
  41. fi
  42. case $BRANCH in
  43. STABLE)
  44. WOLFRECORDER_RELEASE_URL="http://WolfRecorder.com/"
  45. WOLFRECORDER_RELEASE_NAME="wr.tgz"
  46. ;;
  47. CURRENT)
  48. WOLFRECORDER_RELEASE_URL="http://snaps.wolfrecorder.com/"
  49. WOLFRECORDER_RELEASE_NAME="wr_current.tgz"
  50. ;;
  51. esac
  52. ######################## END OF CONFIG ########################
  53. case $AGREE in
  54. 0)
  55. echo "=== Start WolfRecorder auto update ==="
  56. cd ${APACHE_DATA_PATH}${WOLFRECORDER_PATH}
  57. echo "=== Downloading new release ==="
  58. $FETCH ${WOLFRECORDER_RELEASE_URL}${WOLFRECORDER_RELEASE_NAME}
  59. if [ -f ${WOLFRECORDER_RELEASE_NAME} ];
  60. then
  61. echo "=== Creating restore point ==="
  62. mkdir ${RESTORE_POINT} 2> /dev/null
  63. rm -fr ${RESTORE_POINT}/*
  64. echo "=== Move new release to safe place ==="
  65. cp -R ${WOLFRECORDER_RELEASE_NAME} ${RESTORE_POINT}/
  66. echo "=== Backup current data ==="
  67. mkdir ${RESTORE_POINT}/config
  68. mkdir ${RESTORE_POINT}/content
  69. mkdir ${RESTORE_POINT}/howl
  70. # backup of actual configs and administrators
  71. cp .htaccess ${RESTORE_POINT}/ 2> /dev/null
  72. cp favicon.ico ${RESTORE_POINT}/ 2> /dev/null
  73. cp ./config/alter.ini ${RESTORE_POINT}/config/
  74. cp ./config/mysql.ini ${RESTORE_POINT}/config/
  75. cp ./config/ymaps.ini ${RESTORE_POINT}/config/
  76. cp ./config/yalf.ini ${RESTORE_POINT}/config/
  77. cp ./config/binpaths.ini ${RESTORE_POINT}/config/
  78. cp -R ./content/users ${RESTORE_POINT}/content/
  79. cp -R ./content/backups ${RESTORE_POINT}/content/
  80. cp -R ./config/mymodeltemplates ${RESTORE_POINT}/config/
  81. mv ./howl/* ${RESTORE_POINT}/howl/
  82. echo "=== web directory cleanup ==="
  83. rm -fr ${APACHE_DATA_PATH}${WOLFRECORDER_PATH}/*
  84. echo "=== Unpacking new release ==="
  85. cp -R ${RESTORE_POINT}/${WOLFRECORDER_RELEASE_NAME} ${APACHE_DATA_PATH}${WOLFRECORDER_PATH}/
  86. echo ${BRANCH} >> ${LOG_FILE}
  87. echo `date` >> ${LOG_FILE}
  88. echo "====================" >> ${LOG_FILE}
  89. $TAR zxvf ${WOLFRECORDER_RELEASE_NAME} 2>> ${LOG_FILE}
  90. rm -fr ${WOLFRECORDER_RELEASE_NAME}
  91. echo "=== Restoring configs ==="
  92. mv ${RESTORE_POINT}/howl/* ./howl/
  93. cp -R ${RESTORE_POINT}/* ./
  94. rm -fr ${WOLFRECORDER_RELEASE_NAME}
  95. echo "=== Setting FS permissions ==="
  96. chmod -R 777 content/ config/ exports/ howl/
  97. echo "=== Updating autoupdater ==="
  98. cp -R ./dist/presets/debian121/autowrupdate.sh /bin/
  99. echo "=== Executing post-install API callback ==="
  100. /bin/wrapi "autoupdatehook" 2>> ${LOG_FILE}
  101. echo "=== Deleting restore poing ==="
  102. rm -fr ${RESTORE_POINT}
  103. NEW_RELEASE=`cat RELEASE`
  104. echo "SUCCESS: WolfRecorder update successfully completed. Now your installation release is: ${NEW_RELEASE}"
  105. #release file not dowloaded
  106. else
  107. echo "ERROR: No new WolfRecoder release file found, update aborted"
  108. fi
  109. ;;
  110. 1)
  111. echo "Update has been canceled"
  112. exit
  113. ;;
  114. esac