title: How to execute bash script after rsync
body: <p>When I deploy on my dev server I use rsync. But after rsync I need to execute a .sh file for "after" deploy operations like clear cache...</p>
  
  <p>Usually I do this via SSH, but if I deploy very often it's boring write:</p>
  
  <ul>
  <li>ssh ...</li>
  <li>write password</li>
  <li>cd /var/www/myapp/web</li>
  <li>./after_deploy.sh</li>
  </ul>
  
  <p>There is a way to do this quickly? This is my rsync.sh:</p>
  
  <pre><code>#!/bin/bash
  host=""
  directory="/var/www/myapp/web"
  password=""
  usage(){
          echo "Cant do rsync";
          echo "Using:";
          echo "   $0 direct";
          echo "Or:";
          echo "   $0 dry";
  }
  echo "Host: $host";
  echo "Directory: $directory"
  if [ $# -eq 1 ]; then
          if [ "$1" == "dry" ]; then
                  echo "DRY-RUN mode";
                  rsync -CvzrltD --force --delete --exclude-from="app/config/rsync_exclude.txt" -e "sshpass -p '$password' ssh -p22" ./ $host:$directory --dry-run
          elif [ "$1" == "direct" ]; then
                  echo "Normal mode";
                  rsync -CvzrltD --force --delete --exclude-from="app/config/rsync_exclude.txt" -e "sshpass -p '$password' ssh -p22" ./ $host:$directory
          else
                  usage;
          fi;
  else
          usage;
  fi
  </code></pre>