Created
February 19, 2020 14:07
-
-
Save 11808s8/f4c990f78203bada0bba6e3919d18070 to your computer and use it in GitHub Desktop.
Bash script that moves a Controller/Model/DTO project from /tmp/ to it's /var/www/ project destiny using RSYNC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Script for moving project generated files on the /tmp/ filesystem | |
| # and put them into a web project folder in /var/www/ | |
| # | |
| # Its base usage grabs, recursively, files inside a | |
| # /tmp/<type of project: api, crud, ...> folder and | |
| # follows a structure of Controller, Model and Data Transfer Object, | |
| # sending to the destiny folder maintaining the same structure | |
| # | |
| # Author: Adriano Gomes da Silva <[email protected]> | |
| # Version: 1.0.0 | |
| # | |
| # @TODO: Change Controller/Model/DTO to make it reusable | |
| usage() { | |
| cat << EOM | |
| Usage: | |
| $(basename) USER TYPE_OF_PROJECT MODULE_NAME DESTINY_PROJECT_NAME | |
| EOM | |
| } | |
| if [ 'S#' -ne 4 ] | |
| then | |
| usage | |
| exit 1 | |
| fi | |
| USER="${1}" | |
| TYPE_OF_PROJECT="${2}" | |
| MODULE_NAME="${3}" | |
| DESTINY_PROJECT_NAME="${4}" | |
| if [ ! -d "/tmp/$TYPE_OF_PROJECT"] || | |
| [ ! -d "/var/www/$DESTINY_PROJECT_NAME"]; | |
| then | |
| echo "Temporary project folder doesn't exist! Aborting" | |
| exit 1 | |
| fi | |
| chown -R $USER:$USER /tmp/$TYPE_OF_PROJECT | |
| chmod -R 775 /tmp/$TYPE_OF_PROJECT | |
| rsync -av /tmp/$TYPE_OF_PROJECT/Controlador/$MODULE_NAME /var/www/$DESTINY_PROJECT_NAME/Controladores/ | |
| rsync -av /tmp/$TYPE_OF_PROJECT/Modelo/$MODULE_NAME /var/www/$DESTINY_PROJECT_NAME/Modelos/ | |
| rsync -av /tmp/$TYPE_OF_PROJECT/DTO/$MODULE_NAME /var/www/$DESTINY_PROJECT_NAME/DTOS/ | |
| chown -R www-data:www-data /tmp/$TYPE_OF_PROJECT | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment