quick Skeleton Directory Management script for Auto Created homedirs
Chris Tusa <[email protected]> Wed, 7 Dec 2005 01:19:45 -0600
| Newsgroups | gmane.network.pureftpd.user |
|---|---|
| Message-ID | <[email protected]> |
Pure-FTPd users, I whipped up this script as a solution to managing the auto created home directories. In our setup, we have a MySQL CMS website running XOOPS (xoops.org). We are using the same username/password database to authenticate, this way FTP users can manage their passwords from the website. The MySQL backend is 5.0, and we are using a view table to concat the UID,GID, and home directory information. No matter what your setup is, this script is independent of the authenication type. I am posting this script below, and it is also available via ANON ftp at ftp://ftp.linisys.com/pub/scripts/skelcheck/ The way it works, it to check for the existence of a file called .skel_installed in the user's home directory. My skeleton directory includes this file and a few others. Mine looks like this: web# ls -la .skel/ total 8 drwxr-xr-x 3 www www 512 Dec 7 01:02 . drwxr-xr-x 20 www www 512 Dec 7 01:41 .. -r--r--r-- 1 www www 1000 Dec 6 23:02 .banner -rw-r--r-- 1 root www 0 Dec 7 01:02 .skel_installed The rest is self-explanatory. Put it in a cron job, run it from a webscript, whatever. This is just a helpful hint for those looking for a quick fix. This one works fine for our needs have lots of fun! Sincerely, Chris Tusa --- CUT HERE --- #!/bin/sh # # skelcheck.sh : # # Author: Chris Tusa <[email protected]> # Date: 2005-12-07 # Updates: ftp://ftp.linisys.com/pub/scripts/skelcheck # Purpose: # # This is a quick script to check the pure-ftpd server's # user folders to see if the skeleton files have been # populated. Pure-FTPd allows the possibility of creating # user's home directories on the fly if it does not exist # the first time the user logs in. # # There is no facility to generate skeleton files, so this # script is intended to run as a cronjob to check. # # Compatability: # # FreeBSD - YES, tested # OpenBSD - should workd # NetBSD - should work # Linux - Should work # # Setup: # # 1) Define the variables below # 2) Add a cron job - based on your OS, this may vary # # ### Base Directory # # Where your user's home directories are located: # user_base=/usr/local/www/data/users ### Skeleton Directory # # Location of the skeleton directory # (NOTE: trailing slash must exist!) # skel_folder=$user_base/.skel/ ##################################################### # -------------------------- # all code below this line # -------------------------- for dirs in `ls -1 $user_base` do curdir=$user_base/$dirs echo checking $curdir if [ -e $curdir/.skel_installed ]; then echo "skeleton already installed - [OK]" else echo "skeleton missing [INSTALLING]" cp -Rp $skel_folder $curdir if [ $? -eq 0 ]; then echo "ADDED! [OK]" else echo "[FAILED!]" fi fi done; --- STOP --- -- Chris Tusa [email protected] http://people.linisys.com/ctusa --------------------------------------------------------------------- To post a new message, e-mail: [email protected] To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]