SFS-Remover

Miscellaneous tools
Message
Author
stemsee

#21 Post by stemsee »

Just cleaned up sfs -remover (rmsfs)

Code: Select all

#!/bin/sh 
#sfs remover by stemsee 
#
#For removing all files in an sfs module that has been added to main sfs 
#by remastering or added flat (manually copied in) to a full install or savefile etc. Requires original 
#( or any) sfs module for building list of files to be removed. 
#for example a devx_vivid_beta.sfs to remove development files. 
#The list that is built can also be used as an installed file list in 
#~/.packages/ . So that running this script before creating an sfs module 
#from a dir and saving the resultant list to $HOME/.packages/${name}.files 
#will give the option to uninstall files using ppm or slocategui 
#and apptree. 
# 
[[ "$(whoami)" != "root" ]] && exec sudo -E -S ${0} "$\""
export FPROG="$0"
export PROG=$(basename "$0")
running=$(ps -e | grep "$FPROG" | wc -l) 
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export OUTPUT_CHARSET=UTF-8

for i in yad tree
do
	not=$(busybox which $i)
	[[ -z "$not" ]] && echo "$i" >> /tmp/missdeps
done
keg=$(cat /tmp/missdeps 2>/dev/null)
[[ ! -z "$keg" ]] && xmessage -center "Without these missing dependencies
$keg

- rmsfs may not be fully functional

rmsfs copyright (c) 2018 Marcos Contant
GPL 3.0 license applies.
Version 1.2" -fore black -back green -timeout 4
if [ ! -z "$1" ]; then
	hit="$1"		
else
	hit=$(yad --title "Enter /path/to/*.sfs" --entry)
	[[ $? -eq 1 ]] && exit
fi
[[ -z "$hit" ]] && exit
export hitmd=$(echo "$hit" | rev | cut -f1 -d '/' | rev)

rmfn () { 
[[ -d /tmp/"$hitmd" ]] && umount -l /tmp/"$hitmd" 2>/dev/null 
sleep 3 
[[ -d /tmp/"$hitmd" ]] && rm -rf /tmp/"$hitmd" 
} 
deps=$(busybox which tree)
if [ -z "$deps" ]; then 
	echo "Please install tree" 
	sleep 4 
	exit 0 
fi 
if [ -f "$hit" ]; then 
	rmfn 
	mkdir /tmp/"$hitmd" 
	mount -loop -t squashfs "$hit" /tmp/"$hitmd"
	size=$(du -chk /tmp/$hitmd | tail -1 | cut -f1 -d 't' | rev | cut -c2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 |rev)
	size=$(echo "$size"K)
	sleep 2 
	cd /tmp/"$hitmd"
fi
tree -fiF --noreport | sed '/\/$/d' > /tmp/rmsfs.lst 
sed -i 's|./|/|' /tmp/rmsfs.lst 
sed -i 1d /tmp/rmsfs.lst 
sed -i 's/ .*//g' /tmp/rmsfs.lst 
geany /tmp/rmsfs.lst & 

yad --title "Enter yes to remove files or no to make list or q to quit" --text "Ready to remove displayed files from running system 'yes'? 
If not then 'no' for a '$hitmd'.files list to be made in '/root/.packages/
or 'q' to quit" --width=600 --entry
ret=$?
[[ $ret -eq 1 ]] && exit
read hut
case $hut in 
yes) while read line 
   do 
    [[ -e "$line" ]] && rm -rf $line 
   done < /tmp/rmsfs.lst 
   ldconfig 
   cd ../;; 
no) cp /tmp/rmsfs.lst $HOME/.packages/"$hitmd".files 
   ins=$(cat /root/.packages/user-installed-packages | grep "$hitmd")
   if [[ -z "$ins" ]]; then 
      echo "$hitmd|$hitmd|||Utility|$size||$hitmd||sfs module file list||||" >> /root/.packages/user-installed-packages
      yaf-splash -text "Uninstall list added" & 
   fi 
   ;; 
q*) rmfn
sleep 3
exit 0;; 
esac 
rmfn
echo "done"
exit 0 

Post Reply