#!/bin/sh
mkdir -m 1777 /tmp 2> /dev/null
chown root.root /tmp 2> /dev/null
chmod 1777 /tmp 2> /dev/null
if [ ! -d /tmp ]; then
    echo "Warning, there's something wrong with /tmp"
    exit 1
fi
for i in /var /usr /usr/local ; do
    if [ ! -e $i/tmp ]; then
        cd $i && ln -s ../../tmp tmp
    else
echo $i
        if [ -d $i/tmp -o -L $i/tmp ]; then
echo $i/tmp work
	    cd $i && (
               ( cd tmp && mv * .[A-Za-z0-9]* /tmp 2> /dev/null )
               rm -rf tmp
               ln -s ../../tmp tmp )
        fi
    fi
    if [ ! -L $i/tmp ]; then
        echo "Warning: $i/tmp is not a symlink to /tmp"
    fi
done
