vincent_n

GLPI Update

Jun 22nd, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.13 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Deletion of files from previous update that may disturb the script
  4. echo 'We delete all files in /tmp with \"glpi\" in it that may disturb the script'
  5. rm -RI /tmp/*glpi*
  6.  
  7. # Settling of variables for the update
  8. read -p 'Enter the path of actual GLPI (example: /var/www/html/glpi):' glpi
  9.  
  10. # Go in working directory
  11. #echo 'We go into a working directory'
  12. #cd /tmp
  13.  
  14. # Save of in-prod glpi and database
  15. echo 'We save files and database'
  16. cp -R $glpi /tmp/glpibackup
  17. read -p 'Files saved. What is your GLPI database name ?' db
  18. read -p 'Who is your glpi database owner?' user
  19. read -s -p 'What is your glpi database owner password ?' passwd
  20. mysqldump -u $user -p$passwd $db > /tmp/$db'save'.sql
  21. echo 'OK'
  22.  
  23. # Link download
  24. read -p 'Enter the direct download link:' link
  25. wget $link
  26. echo 'Downloaded'
  27.  
  28. # extraction then deletion of archive
  29. echo 'Extraction then deletion of archive'
  30. tar -zxf glpi*.tgz -C /tmp
  31. rm /tmp/glpi*.tgz
  32. echo 'OK'
  33.  
  34. # Deletion of files folder in new glpi
  35. echo 'Now we delete files folder of new GLPI'
  36. rm -RI /tmp/glpi/files
  37. echo 'OK'
  38.  
  39. # Moving of old glpi into working directory + renaming
  40. echo 'We move in-prod glpi into the working folder'
  41. mv $glpi /tmp/glpi_old
  42. echo 'OK'
  43.  
  44. # Cleaning of old glpi "files"
  45. echo 'We will now clean the files folder'
  46. rm -RI /tmp/glpi_old/files/_*/*
  47.  
  48. # Copy of files that are in prod into new glpi
  49. echo 'Then we copy in-prod files folder and db config file into new glpi'
  50. cp -R /tmp/glpi_old/files /tmp/glpi/
  51. cp /tmp/glpi_old/config/config_db.php /tmp/glpi/config/
  52. echo 'OK'
  53.  
  54. # Moving of new glpi into web folder
  55. echo 'We delete old glpi'
  56. rm -RI /tmp/glpi_old
  57. echo 'OK'
  58.  
  59. echo 'We move new glpi into web folder'
  60. mv /tmp/glpi $glpi
  61. echo 'OK'
  62.  
  63. # Settling of owner + rights
  64. echo 'We set the rights and owner'
  65. read -p 'Who is your web user ? (example: apache)' webuser
  66. read -p 'Who is your web group ? (example: apache)' webgroup
  67. chown -R $webuser:$webgroup $glpi
  68. chmod -R 770 $glpi
  69. find $glpi -type d -exec chmod 750 {} \;
  70. find $glpi -type f -exec chmod 740 {} \;
  71. echo 'OK'
  72.  
  73. echo 'The update is almost done. Now connect into the web interface to continue. Goodbye'
Add Comment
Please, Sign In to add comment