Changes between Version 5 and Version 6 of setup_suexec_directory


Ignore:
Timestamp:
Apr 6, 2008, 8:02:25 PM (13 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • setup_suexec_directory

    v5 v6  
    66
    77{{{
    8 # Ensure suexec is enabled (reload apache if necessary)
    9 user=$USER
    10 a2enmod suexec
     8#!/bin/bash
     9# Script to create cgi-bin directory for /var/www/members-cgi-in
    1110
    1211base=/var/www/members-cgi-bin
    1312
    14 if [ ! -d "$base" ]; then mkdir "$base"; fi
     13if [ -z "$1" ]; then
     14  echo "Please pass the user to create the cgi directory for."
     15  exit
     16fi
     17
     18user="$1"
    1519
    1620sitepath=$(getent passwd "$user" | cut -d: -f6 | cut -d/ -f1-6)
     
    1822group=$(echo "$sitepath" | cut -d/ -f4)
    1923
    20 if [ ! -d "$base/$site" ]; then
    21   mkdir "$base/$site"
    22   chown "$user:$group" "$base/$site"
     24if [ -z "$sitepath" ]; then
     25  echo "The user '$user' does not seem to exist"
     26  exit
    2327fi
    2428
    25 if [ ! -h "$sitepath/cgi-bin/suexec" ]; then
    26   ln -s "$base/$site" "$sitepath/cgi-bin/suexec"
     29# Build directories
     30
     31if [ ! -d "$base" ]; then mkdir "$base"; fi
     32
     33if [ ! -d "$base/$site" ]; then
     34  echo "Creating '$base/$site'"
     35  mv "$sitepath/cgi-bin" "$base/$site"
     36  chown "$user:$group" "$base/$site"
     37  ln -s "$base/$site" "$sitepath/cgi-bin"
    2738fi
    2839
     40# Ensure suexec is enabled (reload apache if necessary)
     41if [ ! -h /etc/apache2/mods-enabled/suexec.load ]; then
     42  echo "suexec not enabled, enabling and reloading apache"
     43  /usr/sbin/a2enmod suexec
     44  /etc/init.d/apache2 reload
     45fi
    2946}}}
    3047