Sunday 17 February 2008

A Script to do the plesk directory permisson setup

I have previously posted about changes to the plesk httpdocs directory to get it to work well with Joomla. This is a little bash script I knocked up to do the job. Just pass the username as param 1


#!/bin/bash

# First check that this is a valid username
grep "^${1}:" /etc/passwd > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "Sorry, cannot find user ${1} in /etc/passwd or you didn't supply a username"
echo "Usage: ${0} "

exit 1
fi

userdir=`grep "^${1}:" /etc/passwd | cut -d: -f6`

if [ -d ${userdir} ] ; then
echo "Changing to directory ${userdir}"
cd ${userdir} && chown -R ${1}:psacln httpdocs && chmod -R g+w httpdocs && find httpdocs -type d -exec chmod g+s {} \; && /etc/init.d/httpd reload
fi

No comments: