Thanks for the quick reply, 4-stroke. Your answer is clear, but I already use that part
I am looking for tools that let me relocate extensions & their dependencies - a sort of "local" set of extension manager tools. Sometimes I have an extension in /tce/optional that I'd like to move to /tce for the next boot. Sometimes I have things that I don't want to pop up on the next boot (move /tce -> /tce/optional). I don't think the app manager is designed to do these ... is it?
I have a dirty but effective pair of working scripts (below), but I imagine I've missed something stock.
I do figure it's bad form to recurse my scripts, so I don't think these are the smartest way of going about this problem. I'd rather make a list of all dependencies, then edit the list, then only move the files that need to be moved. Right now, disable-tce.sh moves some files twice ...
It works, but ... I'm looking for somebody else's solution.
enable-tce.sh: a dirty "move that extension from /tce/optional to /tce, or check that all its pieces made it from /tce/optional to /tce"
#!/bin/sh
#dentonlt, Nov 2009 - for TC 2.6
#Enable an extension, or check that it is properly stored in the main tce directory. So either:
#(1) move it from /tce/optional to /tce, OR
#(2) check an extension in /tce to be sure it has all of its dependencies from /tce/optional
if [ -z "$1" ]; then
echo "enable-tce.sh: move an extension and all of its dependencies to the main extension directory"
echo -e "USAGE: enable-tce.sh [-c] [FILENAME] \n"
echo -e "Include the correct extension (tcz, tczl, or otherwise) on FILENAME.\n"
echo -e "To check an extension's dependencies, call enable-tce.sh from the main extension directory."
exit 1
fi
#the file we want to enable
EXTENSION=$1
#get the current tce directory
TCEDIR=`cat /opt/.tce_dir`
#change to the tce directory:
CALLDIR=$PWD
#When called from TCEDIR, check the dependencies of an extension currently in the TCE directory
if [ $CALLDIR = $TCEDIR ] && [ -f $EXTENSION ]; then
echo "Checking $EXTENSION dependencies are in $TCEDIR: "
if [ -f "./$EXTENSION.dep" ]; then
cat "$EXTENSION.dep" |
while read FILE
do
if [ -f "./$FILE" ]; then #if the file is in $TCEDIR, move on.
echo "$FILE was okay."
continue
elif [ -f "./optional/$FILE" ]; then
mv -f ./optional/$FILE* ./
echo "Moved $FILE* to $TCEDIR."
fi
done
fi
#and get any other parts of the extension out of optional, too
cd optional
if [ -f $EXTENSION* ]; then
echo "Moving $TCEDIR/optional/$EXTENSION* to $TCEDIR"
mv -f $EXTENSION* ../
fi
echo "... done!"
cd $CALLDIR
exit 1
else #not called from $TCEDIR ... so go to the optional directory and enable the extension there.
cd $TCEDIR/optional
fi
#check to see that the extension exists
if [ ! -f "$EXTENSION" ]; then
if [ -f "../$EXTENSION" ]; then
cd ..
enable-tce.sh $EXTENSION >/dev/null #check dependencies by recursing.
echo "I found $EXTENSION in $TCEDIR - it was already enabled. I've checked its dependencies, too."
exit 1
fi
echo "I couldn't find $EXTENSION in $TCEDIR or $TCEDIR/optional. Check the file name to be sure you're correct."
exit 1
fi
#look for a dependency file
if [ ! -f "$TCEDIR/optional/$1.dep" ]; then
echo "$EXTENSION has no dependencies or the dep file is missing. Moving $EXTENSION*."
mv -f $EXTENSION* ../
echo "done!"
exit 1
fi
echo "Moving files:"
cat $EXTENSION.dep |
while read FILE
do
if [ -f "$FILE" ]; then
if [ -f "$FILE.dep" ]; then
echo -n "$FILE* and dependencies, "
enable-tce.sh $FILE >/dev/null
else
echo -n "$FILE*, "
mv -f $FILE* ../
fi
fi
done
echo -n "$EXTENSION* "
mv -f $EXTENSION* ../
echo -e "... done!\n"
cd $CALLDIR
disable-tce.sh: a dirty "go the other way."#!/bin/sh
#dentonlt, Nov 2009. For TC 2.6
#move an extension and all of its dependencies to the optional extension directory
if [ -z "$1" ]; then
echo "disable-tce: move an extension and all of its dependencies to the main extension directory"
echo -e "USAGE: disable-tce [FILENAME] \n"
echo -e "Include the correct extension (tcz, tczl, or otherwise) on FILENAME.\n"
exit 1
fi
#get the current tce directory
TCEDIR=`cat /opt/.tce_dir`
#check to see that the extension exists
if [ ! -e "$TCEDIR/$1" ]; then
echo -e "I could not find $TCEDIR/$1. Check the file name. Is $TCEDIR mounted?\n"
exit 1
fi
#look for a dependency file
if [ ! -e "$TCEDIR/$1.dep" ]; then
echo "$1 has no dependencies or the dep file is missing. Moving $1*."
mv -f $1* ./optional/
echo "done!"
exit 1
fi
#change to the tce directory:
CALLDIR=$PWD
cd $TCEDIR
echo "Moving files:"
cat $1.dep |
while read FILE
do
if [ -f "$FILE" ]; then
if [ -f "$FILE.dep" ]; then
echo -n "$FILE* and dependencies, "
disable-tce.sh $FILE >/dev/null
else
echo -n "$FILE*, "
mv -f $FILE* ./optional/
fi
fi
done
echo -n "$1* "
mv -f $1* ./optional/
#now that all the files have been moved to the optional directory, we have to be sure that we didn't remove any dependencies.
#go through all the files in $TCEDIR and check that they are enabled.
echo -e "Rechecking dependencies ... "
cd $TCEDIR
ls -1 $TCEDIR/*.dep |
while read FILE
do
if [ -f $FILE ]; then
cat $FILE |
while read DEPFILE
do
enable-tce.sh $DEPFILE >/dev/null
done # reading dependency file
fi # if it was actually a file
done # searching directory for dep files
echo -e " ... done!\n"
cd $CALLDIR