wiki:setup_suexec_directory

Version 6 (modified by Jamie McClelland, 16 years ago) ( diff )

--

How do I setup an suExec directory for a member?

Only MFPL admins have permission to take this step. If you would like suExec enabled for your site, please follow our suExec FAQ.

Run the following script, replacing $USER with the username provided by the member.

#!/bin/bash
# Script to create cgi-bin directory for /var/www/members-cgi-in

base=/var/www/members-cgi-bin

if [ -z "$1" ]; then
  echo "Please pass the user to create the cgi directory for."
  exit
fi

user="$1"

sitepath=$(getent passwd "$user" | cut -d: -f6 | cut -d/ -f1-6)
site=$(echo "$sitepath" | cut -d/ -f6)
group=$(echo "$sitepath" | cut -d/ -f4)

if [ -z "$sitepath" ]; then
  echo "The user '$user' does not seem to exist"
  exit
fi

# Build directories

if [ ! -d "$base" ]; then mkdir "$base"; fi

if [ ! -d "$base/$site" ]; then
  echo "Creating '$base/$site'"
  mv "$sitepath/cgi-bin" "$base/$site"
  chown "$user:$group" "$base/$site"
  ln -s "$base/$site" "$sitepath/cgi-bin"
fi

# Ensure suexec is enabled (reload apache if necessary)
if [ ! -h /etc/apache2/mods-enabled/suexec.load ]; then
  echo "suexec not enabled, enabling and reloading apache"
  /usr/sbin/a2enmod suexec
  /etc/init.d/apache2 reload
fi
Note: See TracWiki for help on using the wiki.