Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/bash
- #
- # deploy.sh - script for web applications deployment
- # author:
- #
- # application archive's filename
- ZIP_ARCHIVE=deploy.zip
- SPECIAL_DIRS="htdocs/data system/logs system/cache"
- # Database options
- DB_HOST=localhost
- DB_USER=user
- DB_PASS=pass
- DB_NAME=db
- DUMP_FILE=dump.sql
- ##############################################
- #################### Let's GO! ###############
- ##############################################
- # 1. unzip application from archive
- unzip -o $ZIP_ARCHIVE
- if [ $? -ne 0 ]
- then
- echo "***** UNZIP ERROR. EXIT *****";
- exit 1
- fi
- # 2. set required permissions
- # for all
- for i in `ls -R .`
- do
- if [ -f $i ]
- then
- chmod 0644 $i
- elif [ -d $i ]
- then
- chmod 0755 $i
- fi
- done
- # for special dirs
- chmod -R 0777 $SPECIAL_DIRS
- # for special files
- for i in `find ./ -type f -name "*index*" -o -name "*main*"`
- do
- chmod 0444 $i
- done
- # 3. MySQL dump
- # if dump is OK remove dump file
- mysql -h$DB_HOST -u$DB_USER -p$DB_PASS -D$DB_NAME < $DUMP_FILE && rm $DUMP_FILE
- # 4. remove archive and deployment script
- rm $ZIP_ARCHIVE && rm $0
- exit 0
Add Comment
Please, Sign In to add comment