[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: slink is gone, goals for potato?



On Tue, Mar 02, 1999 at 12:45:23AM +0000, Edward Betts wrote:
> Filesystem Hierarchy Standard (FHS)
>   Changes needed, off the top of my head - 
>     * move /usr/doc/*    to /usr/share/doc/*
>     * move /usr/info/*   to /usr/share/info/*
>     * move /usr/man/*    to /usr/share/man/*
>     * move /var/lib/dpkg to /var/state/dpkg


To make the move, I have write a bash-script: fs-translation
I have not test it.

It test the arguments from fs-translation and make, after the move, a
symlink at the old place to the new.

Have a look on it.
You can start it. It make nothing. Only verbose output...

The bash-script:
-----------------------------------------------------------------------
#!/bin/bash


VERBOSE=1;
DONT=1;
FREESIZE=102400


vecho () {
if [ $VERBOSE -gt 0 ]; then
	echo $*
fi
}

dirstatus () {
echo "Status"
if [ ! `echo $1|sed -e "s/\(.\).*/\1/"` = "/" ]; then
	echo "$1 is not absolut!!"
	exit -1
else
	vecho "$1 is absolut. OK"
fi
if [ ! `echo $2|sed -e "s/\(.\).*/\1/"` = "/" ]; then
	echo "$2 is not absolut!!"
	exit -1
else
	vecho "$2 is absolut. OK"
fi
if [ ! -d $1 ]; then
	echo "$1 is not a directory!!"
	exit -1
else	
	vecho "$1 is a directory. OK"
fi
DEST=`dirname $2`
if [ ! -d $DEST ]; then
	echo "$DEST is not a directory!!"
	exit -1
else	
	vecho "$DEST is a directory. OK"
fi
if [ -d $2 ]; then
	echo "$2 is a directory!!"
	echo "please check it, I can't move $1 to $2"
	exit -1
else
	vecho "$2 is not a directory. OK"
fi
if [ -e $2 ]; then
	echo "$2 exists!!"
	echo "please check it, I can't move $1 to $2"
	exit -1
else
	vecho "$2 is not in the filesystem. OK"
fi
touch $DEST/$$.test || exit -1
if [ `find $1 -name "$$.test"` ]; then
	rm $DEST/$$.test
	echo "$DEST is in $1 !!"
	exit -1
else
	vecho "$DEST is not in $1. OK"
fi

SIZE1=`du -sk $1|cut -f1`
SIZE2=`df $DEST|tail -1|sed -e "s/[^ ]* *[^ ]* *[^ ]* *\([^ ]*\).*/\1/"`
LOCA1=`df $1|tail -1|cut -f1 -d " "`
LOCA2=`df $DEST|tail -1|cut -f1 -d " "`


printf "%30s is on %10s and use  %10s kByte      \n" $1 $LOCA1 $SIZE1 
printf "%30s is on %10s and have %10s kByte free \n" $2 $LOCA2 $SIZE2 


if [ $LOCA1 = $LOCA2 ];then
	echo $1 and $2 an the same device
	if [ $DONT -gt 0 ]; then
		vecho  = mv $1 $2
		vecho  = cd `dirname $1`
		vecho  = ln -s $2 `basename $1`
	else
		mv $1 $2
		(cd `dirname $1`
		ln -s $2 `basename $1`)
	fi
else
	echo $1 and $2 not an the same device
	echo after the move you have $[$SIZE2-$SIZE1] kByte free on $LOCA2
	if [ $[$SIZE2-$SIZE1-$FREESIZE] -gt 0 ];then
		if [ $DONT -gt 0 ]; then
			vecho  = mv $1 `dirname $1`/tmp.$$
			vecho  = mkdir $2
			vecho  = cp -a `dirname $1`/tmp.$$/* $2
			vecho  = cd `dirname $1`
			vecho  = ln -s $2 `basename $1`
			vecho  = rm -rf `dirname $1`/tmp.$$
		else
			mv $1 `dirname $1`/tmp.$$
			mkdir $2
			cp -a `dirname $1`/tmp.$$/* $2
			(cd `dirname $1`
			ln -s $2 `basename $1`)
			rm -rf $1.$$
		fi
	else
		echo "not enough free space!!"
		exit -1
	fi
fi
}

dirstatus $1 $2
-----------------------------------------------------------------------

if the programm should move the dir, change DONT=1 in DONT=0.

the output from the Programm:
root@titanic:~> ./fs-translation /usr/doc/ /usr/share/doc
Status
/usr/doc/ is absolut. OK
/usr/share/doc is absolut. OK
/usr/doc/ is a directory. OK
/usr/share is a directory. OK
/usr/share/doc is not a directory. OK
/usr/share/doc is not in the filesystem. OK
/usr/share is not in /usr/doc/. OK
                     /usr/doc/ is on  /dev/hdc3 and use      129095 kByte
                /usr/share/doc is on  /dev/hdc3 and have      84248 kByte free
/usr/doc/ and /usr/share/doc an the same device
= mv /usr/doc/ /usr/share/doc
= cd /usr
= ln -s /usr/share/doc doc


Grisu
-- 
Michael Bramer -- a Debian Linux Developer        http://www.debian.org
PGP: finger grisu@master.debian.org   --   Linux Sysadmin   --  Use Debian Linux
"Now let me explain why this makes intuitive sense."  --- Prof. Larry Wasserman

Attachment: pgp3Dyk62Hqkr.pgp
Description: PGP signature


Reply to: