SugarCRM — Permissions Script

Posted on Sat 21 June 2014 in Tech

I use salt quite extensively to deploy SugarCRM installs and I wanted a scriptable way to setup the correct permissions for Sugar running on a linux box. This script is based on the Sugar documentation and this handy post here.

Simply fill in your apache user details and the path to the Sugar install and you're away.

#!/bin/bash
APACHEUSER='www-data:www-data'
SUGARPATH='/var/www/sugarcrm'

find -P $SUGARPATH/ -type d -exec chmod 755 {} \\;
find -P $SUGARPATH/ -type f -exec chmod 644 {} \\;
find -P $SUGARPATH/ -name *.js -exec chmod 755 {} \\;

chmod 664 $SUGARPATH/config.php
chmod 664 $SUGARPATH/config_override.php
chmod 664 $SUGARPATH/sugarcrm.log

find -P $SUGARPATH/cache -type d -exec chmod 775 {} \\;
find -P $SUGARPATH/custom -type d -exec chmod 775 {} \\;
find -P $SUGARPATH/data -type d -exec chmod 775 {} \\;
find -P $SUGARPATH/modules -type d -exec chmod 775 {} \\;
find -P $SUGARPATH/include -type d -exec chmod 775 {} \\;
find -P $SUGARPATH/upload -type d -exec chmod 775 {} \\;

find -P $SUGARPATH/cache -type f -exec chmod 664 {} \\;
find -P $SUGARPATH/custom -type f -exec chmod 664 {} \\;
find -P $SUGARPATH/data -type f -exec chmod 664 {} \\;
find -P $SUGARPATH/modules -type f -exec chmod 664 {} \\;
find -P $SUGARPATH/include -type f -exec chmod 664 {} \\;
find -P $SUGARPATH/upload -type f -exec chmod 664 {} \\;

chown -R $APACHEUSER $SUGARPATH

And the salt config to get this running.

sugar_permissions:

  cmd.script:
    - source: salt://deploy/dev/sugar/permissions.sh
    - user: root
    - group: root
    - shell: /bin/bash

If you see any issues with the script/salt config please let me know.

Thanks!