Guest User

Untitled

a guest
Jul 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #!/usr/local/bin/bash
  2. #
  3. # deploy.sh - script for web applications deployment
  4. # author:
  5. #
  6.  
  7. # application archive's filename
  8. ZIP_ARCHIVE=deploy.zip
  9.  
  10. SPECIAL_DIRS="htdocs/data system/logs system/cache"
  11.  
  12. # Database options
  13.  
  14. DB_HOST=localhost
  15. DB_USER=user
  16. DB_PASS=pass
  17. DB_NAME=db
  18.  
  19. DUMP_FILE=dump.sql
  20.  
  21. ##############################################
  22. #################### Let's GO! ###############
  23. ##############################################
  24.  
  25. # 1. unzip application from archive
  26.  
  27. unzip -o $ZIP_ARCHIVE
  28.  
  29. if [ $? -ne 0 ]
  30. then
  31. echo "***** UNZIP ERROR. EXIT *****";
  32. exit 1
  33. fi
  34.  
  35. # 2. set required permissions
  36.  
  37. # for all
  38. for i in `ls -R .`
  39. do
  40. if [ -f $i ]
  41. then
  42. chmod 0644 $i
  43. elif [ -d $i ]
  44. then
  45. chmod 0755 $i
  46. fi
  47. done
  48.  
  49. # for special dirs
  50. chmod -R 0777 $SPECIAL_DIRS
  51.  
  52. # for special files
  53. for i in `find ./ -type f -name "*index*" -o -name "*main*"`
  54. do
  55. chmod 0444 $i
  56. done
  57.  
  58. # 3. MySQL dump
  59.  
  60. # if dump is OK remove dump file
  61. mysql -h$DB_HOST -u$DB_USER -p$DB_PASS -D$DB_NAME < $DUMP_FILE && rm $DUMP_FILE
  62.  
  63. # 4. remove archive and deployment script
  64. rm $ZIP_ARCHIVE && rm $0
  65.  
  66. exit 0
Add Comment
Please, Sign In to add comment