Added option "-o" for extensions in /tce/optional folder example: "tce-remove -o oo2"
reminder: it's good practice to only remove files you aren't using
removes only files on .list installed to ram
Example with Open Office oo2.tczl installed to ram:
"tce-load -i -r tce/optional oo2.tczl"
Mem: 509,124K used, 6160K free, 0K shrd, 3372K buff, 348,144K cached
"tce-remove -o oo2"
Mem: 193,568K used, 321716K free, 0K shrd, 4152K buff, 50,840K cached
#!/bin/ash
####### tce-remove script, by jpeters
######## Removes only files on .list
###### Updated to remove tce and tcz list files that are installed to ram
###### Comments: use only basename.
##### Example: "tce-remove gnumeric"
##### Option -o for /tce/optional: "tce-remove -o oo2"
MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
TCEDIR="$(cat /opt/.tce_dir)"
TCEOP="${TCEDIR}/optional"
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
if [ ${1} == "-o" ] ; then
A=${2}
APP="$(find $TCEOP/${2}* | grep -v dep | grep -v txt | sed "s@$TCEOP@@")"
else
APP="$(find $TCEDIR/${1}* | grep -v dep | grep -v txt | sed "s@$TCEDIR@@")"
A=${1}
fi
## tcz or tce?
case $APP in
*.tce*) EXT="tce" ;;
*.tcz*) EXT="tcz" ;;
esac
### Only remove tcz if installed to ram
if [ $EXT == "tcz" ]; then
if [ -e /tmp/tcloop/${A} ]; then
echo "tcz not installed to ram"
exit 1
fi
fi
sudo mkdir /tmp/tce-list
cd /tmp/tce-list
sudo wget ftp://$MIRROR/$EXT/$APP.list
LIST="$(cat *list)"
cd /
for I in $LIST
do
sudo rm $I
done
#### REPORT #########
for I in $LIST
do
[ -f $I ] || echo "file removed: $I " >>/tmp/report
[ -f $I ] && echo "file not removed: $I " >>/tmp/report
done
cat /tmp/report
#### Cleanup #####
[ -f /tmp/report ] && sudo rm /tmp/report
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list