chatwizrd
Verified User
- Joined
- Jul 3, 2005
- Messages
- 2,005
Hi.
I dont know if anyone has ever done this but the other day I noticed I had lost all the directories in /var/spool/virtual. Well I have written a script to rebuild those and set to the proper owners.
Enjoy!
Should work fine on Linux and Freebsd.
----
How to use:
Script:
I dont know if anyone has ever done this but the other day I noticed I had lost all the directories in /var/spool/virtual. Well I have written a script to rebuild those and set to the proper owners.
Enjoy!
Should work fine on Linux and Freebsd.
----
How to use:
Code:
Put the following script into a txt file in /var/spool/virtual
I named mine /var/spool/virtual/rebuild
Then type:
chmod 750 /var/spool/virtual/rebuild
Then type:
cd /var/spool/virtual
./rebuild
Script:
Code:
#!/bin/sh
pwd=$(pwd) # Keep set to pwd or set to full path to the pwd command.
whoami=$(whoami) # Keep set to whoami or set to full path of whoami command.
################### DO NOT TOUCH CODE UNDER HERE #####################
domainowners=$(cat /etc/virtual/domainowners | sed 's/://' | tr -s ' ' ':')
if [ $whoami != "root" ]; then
echo
echo "You must be root to run this program!"
echo
exit 1
elif [ $pwd != "/var/spool/virtual" ]; then
echo
echo "You must be in the /var/spool/virtual folder to run this program."
echo
exit 1
else
for i in $domainowners; do
# Create Domain Folder
echo $i | cut -f1 -d: > /tmp/domains.$$
mkdir $(cat /tmp/domains.$$)
# Chown Domain Folder
echo $i | cut -f2 -d: > /tmp/users.$$
chown $(cat /tmp/users.$$):$(cat /tmp/users.$$) $(cat /tmp/domains.$$)
done
fi
rm -rf /tmp/domains.$$ /tmp/users.$$
exit 0