Home‎ > ‎Technical Stuff‎ > ‎

LXR Script

#!/bin/bash
ROOT=/usr/share/lxr
COM=$1
NAME=$2
PATH1=$3

if [ $# != 0 ] ; then
if [ $COM == "add" ] && [ $# == 3 ] ; then
if [ ! -e $ROOT/source/$NAME ] ; then
        rsync -aqL --progress --exclude=*.o --exclude=*.ko --exclude=*.*mod* --exclude *.*cmd* --delete $PATH1/ $ROOT/source/$NAME
        #cp -r $PATH1 $ROOT/source/$NAME
        echo $NAME >> $ROOT/source/versions
        cd $ROOT/source/$NAME
        /usr/bin/genxref
        /usr/local/bin/glimpseindex -H . .
        /bin/chown -R www-data.www-data $ROOT/
else
        echo "Directory already exists, choose other name"
fi
elif [ $COM == "remove" ] && [ $# == 2 ]; then
        echo "Confirmation : Type yes"
        read var
        if [ $var == "yes" ] ; then
                sed "/$NAME/d" $ROOT/source/versions > $ROOT/temp.10
                cat $ROOT/temp.10 > $ROOT/source/versions
                rm $ROOT/temp.10
                rm -rf $ROOT/source/$NAME
                /bin/chown -R www-data.www-data $ROOT/
        else
                echo "You typed something else, no action taken"
        fi
elif [ $COM == "refresh" ] && [ $# == 3 ]; then
        if [ ! -e $ROOT/source/$NAME ] ; then
                echo "No such directory"
        else
                rsync -aqL --progress --exclude=*.o --exclude=*.ko --exclude=*.*mod* --exclude *.*cmd* --delete $PATH1/ $ROOT/source/$NAME
                cd $ROOT/source/$NAME
                /usr/bin/genxref
                /usr/local/bin/glimpseindex -H . .
                /bin/chown -R www-data.www-data $ROOT/
        fi
elif [ $COM == "list" ] && [ $# == 1 ]; then
        cat $ROOT/source/versions
else
        echo "No action taken"
fi
else
        echo "Usage"
        echo "lxredit add <name> <path>"
        echo "lxredit refersh <name> <path>"
        echo "lxredit remove <name>"
        echo "lxredit list"
fi


Comments