Chris@1577: #!/bin/bash Chris@1577: Chris@1577: set -e Chris@1577: Chris@1589: # We might be running in one of two ways: Chris@1589: # Chris@1589: # 1. The code directory is already at /var/www/code, either because a Chris@1589: # previous provisioning step has imported it there or because this Chris@1589: # script has been run before -- in this situation all we do is Chris@1589: # re-check the ownership and permissions. OR Chris@1589: # Chris@1589: # 2. The code directory has not yet been copied to /var/www/code, in Chris@1589: # which case we expect to find it at /code-to-deploy, e.g. as a Chris@1589: # Vagrant shared folder, and we copy it over from there. (We don't Chris@1589: # deploy directly from shared folders as we might not be able to Chris@1589: # manipulate ownership and permissions properly there.) Chris@1589: Chris@1577: if [ ! -d /var/www/code ]; then Chris@1587: if [ ! -d /code-to-deploy ]; then Chris@1589: echo "ERROR: Expected to find code tree at /var/www/code or /code-to-deploy: is the deployment script being invoked correctly?" Chris@1587: exit 2 Chris@1587: fi Chris@1587: cp -a /code-to-deploy /var/www/code Chris@1577: fi Chris@1577: Chris@1587: chown -R code.www-data /var/www/code Chris@1605: chmod 755 /var/www/code Chris@1587: find /var/www/code -type d -exec chmod g+s \{\} \; Chris@1587: