Table of Contents
Watching Autodir while doing its job is great learning process. What follows is the step by step process to have fun with Autodir.
We will create some 1000 user accounts on the local system. First download users.txt file. It contains all the account names to be created. Then execute the following shell script as root user.
-----------SCRIPT START------------
#!/bin/sh
#
# Script to add user accounts to the local system
# for use by Autodir.
#
homebase="/test"
for user in `cat users.txt`
do
echo "adding user $user"
useradd $user -d "$homebase/$user" -M
done
--Output from script-- adding user user_1000 adding user user_1001 adding user user_1002 adding user user_1003 adding user user_1004 adding user user_1005 adding user user_1006 adding user user_1007 adding user user_1008 ... ... ...
In the above shell script, we add users with home directory /test as base. We do not use /home for these accounts as home directory so you can feel comfortable and in control. Option -M causes not to create actual home directories in the directory /test so that we can simulate as if we imported these accounts from LDAP/SQL/NIS.
Autodir has foreground mode that can be enabled with -f option. In this mode, Autodir output all log messages to console. Open a new root console and start autodir with -f option and also with -V option for verbose logging.
# modprobe autofs4 # autodir -d /test \ -m /usr/lib/autodir/autohome.so \ -f -V autodir info: giving up unnecessary root privileges autodir notice: using default value '/autohome' for 'realpath' autodir notice: using default value '/etc/skel' for 'skel' autodir notice: using default value '2' for 'level' autodir notice: using default value '0700' for 'mode' autodir info: starting autodir version 0.92.1
Get to another console and issue following commands.
# cd /test/user_1000 # ls -a . .autohome .bash_profile .canna .gtkrc .test .. .bash_logout .bashrc .emacs .kde .zshrc # cd #
Autodir output log messages on the console which might look like:
autodir info: home /autohome/u/us/user_1000 does not exist. creating autodir info: mounting /autohome/u/us/user_1000 on /test/user_1000 autodir info: unmounting /test/user_1000
Now explore /autohome directory for the changes being made.
So far you only scratched the surface. We use programs written in C that emulate typical Unix daemons and backup programs that take this game to very extreme -- squeezing out every resource available on the system and sometimes this goes for days and nights without interruptions!
But for most people, the following automated shell script is good start instead of using cd command to check manually everything.
-----------SCRIPT START------------
#!/bin/sh
#
base="/test"
while true
do
for user in `cat users.txt`
do
dircd="$base/$user"
echo "changing to directory $dircd"
cd $dircd
cd
done
done
--Output from script-- changing to directory /test/user_1000 changing to directory /test/user_1001 changing to directory /test/user_1002 changing to directory /test/user_1003 changing to directory /test/user_1004 changing to directory /test/user_1005 changing to directory /test/user_1006 changing to directory /test/user_1007 changing to directory /test/user_1008 changing to directory /test/user_1009 ... ... ...
This document, Playing with Autodir, is copyrighted (c) 2005 by Venkata Ramana Enaganti. This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.