Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{--
- This is an SSH Alias----V
- --}}
- @servers([ "remote" => "liberty", "local" => "localhost" ])
- @setup
- $timestamp = date("Ymdhis");
- $basedir = "/var/www/vhosts/example.com";
- $shared = "{$basedir}/shared";
- $uploads = "{$basedir}/releases/{$timestamp}/wp-content/uploads";
- $runner = "apache";
- $group = "wrl_users";
- @endsetup
- @task("create-directory", ["on" => "remote"])
- cd "{{ $basedir }}/releases/"
- echo "Creating Directory \"{{ $basedir }}/releases/{{ $timestamp }}\""
- mkdir "{{ $timestamp }}" && cd "{{ $timestamp }}"
- @endtask
- @task("copy-files", ["on" => "remote"])
- # copy files from public to new release
- echo "Starting Remote RSYNC..."
- rsync -r "{{ $basedir }}/public/" ./
- echo "Finished with RSYNC."
- @endtask
- @task("create-symlinks", ["on" => "remote"])
- # create uploads symlink
- if [ -e "{{ $uploads }}" ]
- then
- rm -R "{{ $uploads }}"
- fi
- echo "Linking 'uploads' folder..."
- ln -nfs "{{ $shared }}/uploads" "{{ $basedir }}/releases/{{ $timestamp }}/wp-content/uploads"
- @endtask
- @task("rsync-local", ["on" => "local"])
- echo "Syncing development files to remote server..."
- rsync -rv --rsh=ssh --exclude "wp-content/uploads" ./ "wrlliberty:{{ $basedir }}/releases/{{ $timestamp }}/"
- @endtask
- @task("symlink-public", ["on" => "remote"])
- cd "{{ $basedir }}"
- unlink "public" && ln -nfs "{{ $basedir }}/releases/{{ $timestamp }}" "public"
- @endtask
- @task("ownership", ["on" => "remote"])
- echo "Fixing Ownership Issues from RSYNC..."
- chown {{ $runner }}:{{ $group }} "{{ $basedir }}/releases/{{ $timestamp }}" -Rf
- find "{{ $basedir }}/releases/{{ $timestamp }}" -type f -exec chmod 0664 {} \;
- find "{{ $basedir }}/releases/{{ $timestamp }}" -type d -exec chmod 0775 {} \;
- @endtask
- @macro("deploy")
- create-directory
- copy-files
- rsync-local
- create-symlinks
- symlink-public
- ownership
- @endmacro
Advertisement
Add Comment
Please, Sign In to add comment