Plesk Automatic Global Script Repository
Had a client who wanted to have a global scripts/ for his clients under FTP.Now, usually a symlink would suffice but (as the proftpd docs state) in a chroot environment this isn't possible. Instead one has to do some tedius mount --bind stuff for each domain they want to have a global alias on.
SO... We made this script which does it for you;
--SNIP--
PHP Code:
#!/bin/bash
#
# Startup script to provide a global alias to a common scripts directory
# from proftpd's chroot system in Plesk.
#
# chkconfig: 2345 08 92
#
# description: Automatic scripts/ directory setup.
#
# This is an interactive program, we need the current locale
case "$1" in
start)
echo -n $"Applying global scripts/: "
echo
cd /home/httpd/vhosts
for domain in $( ls . )
do
if [ $domain = "scripts" ] ; then
continue
fi
mkdir $domain/scripts 2> /dev/null
if [ -n "`mount | grep $domain`" ] ; then
umount $domain/scripts 2> /dev/null
fi
if [ -z "`mount | grep $domain`" ] ; then
mount --bind /home/httpd/vhosts/scripts $domain/scripts
fi
done
;;
stop)
echo -n $"Removing global scripts/: "
echo
cd /home/httpd/vhosts
for domain in $( ls . )
do
if [ $domain = "scripts" ] ; then
continue
fi
if [ -n "`mount | grep $domain`" ] ; then
`umount "$domain/scripts" 2> /dev/null`
fi
done
;;
restart)
# "restart" is really just "start" as this isn't a daemon,
# This is really only here to make those who expect it happy
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
We stuck it in the users /etc/rc.d/init.d, ran chkconfig to have it start at start up then made a one liner in cron.hourly to run globalaliases start.
This has only been tested for PSA5 RPM but a bit of modification should help it work out for just about all proftpd installs (particularly Plesk).
scripts/ in this case is at /home/httpd/vhosts/scripts/
Cheers,
Stuart