| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | VERSION=$1; |
|---|
| 4 | TO_DIR=$2; |
|---|
| 5 | TO_DIR_DEFAULT='/home/r2/www/icms_build'; |
|---|
| 6 | |
|---|
| 7 | SRC_DIR='/home/r2/www/icms'; |
|---|
| 8 | DISTR_NAME='instantCMS_'`date +%Y%m%d`'_v'$VERSION'.zip'; |
|---|
| 9 | |
|---|
| 10 | if [[ $VERSION = "" ]] |
|---|
| 11 | then |
|---|
| 12 | echo "Usage: build.sh VERSION [TARGET_PATH]"; |
|---|
| 13 | echo "Example: build.sh 1.2.1 /var/www/icms_build"; |
|---|
| 14 | echo ""; |
|---|
| 15 | exit 1; |
|---|
| 16 | fi |
|---|
| 17 | |
|---|
| 18 | if [[ $TO_DIR = "" ]] |
|---|
| 19 | then |
|---|
| 20 | TO_DIR=$TO_DIR_DEFAULT; |
|---|
| 21 | fi |
|---|
| 22 | |
|---|
| 23 | echo ""; |
|---|
| 24 | echo "Building version: $VERSION"; |
|---|
| 25 | echo "Building to: $TO_DIR"; |
|---|
| 26 | echo ""; |
|---|
| 27 | |
|---|
| 28 | echo "Copying files..."; |
|---|
| 29 | cp -R $SRC_DIR/. $TO_DIR/. && chmod -R 777 $TO_DIR |
|---|
| 30 | |
|---|
| 31 | echo "Deleting SVN folders..."; |
|---|
| 32 | find $TO_DIR -type d -iname '.svn' -print0 | xargs -0 rm -rf |
|---|
| 33 | |
|---|
| 34 | echo "Deleting .tmp files..."; |
|---|
| 35 | find $TO_DIR -type f -iname '*.tmp' -print0 | xargs -0 rm -f |
|---|
| 36 | |
|---|
| 37 | echo "Deleting configuration file..."; |
|---|
| 38 | rm -f $TO_DIR/includes/config.inc.php |
|---|
| 39 | |
|---|
| 40 | echo "Deleting cache..."; |
|---|
| 41 | rm -f $TO_DIR/cache/*; |
|---|
| 42 | |
|---|
| 43 | echo "Deleting backups..."; |
|---|
| 44 | rm -f $TO_DIR/backups/*.sql; |
|---|
| 45 | rm -f $TO_DIR/backups/*.sql~; |
|---|
| 46 | |
|---|
| 47 | echo "Deleting RSS cache..."; |
|---|
| 48 | rm -f $TO_DIR/includes/rss/cache/*; |
|---|
| 49 | |
|---|
| 50 | echo "Deleting files in root..."; |
|---|
| 51 | find $TO_DIR -maxdepth 1 -mindepth 1 -type f -not -name cron.php -not -name .htaccess -not -name url_rewrite.php -not -name readme.txt -not -name version_log.txt -not -name license.txt -not -name license.rus.win.txt -not -name license.rus.utf.txt -not -name index.php -not -name $DISTR_NAME -print0 | xargs -0 rm -f; |
|---|
| 52 | echo ""; |
|---|
| 53 | |
|---|
| 54 | echo "Building archive..."; |
|---|
| 55 | cd $TO_DIR; |
|---|
| 56 | zip -r -q $TO_DIR/distr.zip * .htaccess; |
|---|
| 57 | |
|---|
| 58 | echo "Renaming archive to $DISTR_NAME..."; |
|---|
| 59 | mv $TO_DIR/distr.zip $TO_DIR/$DISTR_NAME; |
|---|
| 60 | |
|---|
| 61 | echo "Cleaning target directory..."; |
|---|
| 62 | find $TO_DIR -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 rm -rf; |
|---|
| 63 | find $TO_DIR -maxdepth 1 -mindepth 1 -type f -not -name $DISTR_NAME -print0 | xargs -0 rm -f; |
|---|
| 64 | |
|---|
| 65 | echo ""; |
|---|
| 66 | echo "Finished."; |
|---|
| 67 | echo ""; |
|---|
| 68 | |
|---|
| 69 | nautilus $TO_DIR &> /dev/null & |
|---|