Remove a folder after a 'true' uninstall....


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Remove a folder after a 'true' uninstall....
# 1  
Old 05-18-2012
Remove a folder after a 'true' uninstall....

Okay, I need some nerd magic here! LOL!

Using a bash script, I have a folder that I'd like to remove upon uninstalling a package. That part is simple but what isn't simple is taking into consideration a 'reinstall' or 'upgrade' of that same package.

By default, 'reinstalling' or 'upgrading' a package runs the 'Install' process as well as the 'Uninstall' process...in that order?!?! I don't know why it's done this way but it is what it is.

Sooo, is there a way for a bash script to identify if a package is 'truly' being uninstalled...not being reinstalled or upgraded? If so, what would this bash script look like?

I'm just pulling at straws here since I'm not good at bash scripting...

Code:
 
#There's more script prior to this...
 
DIR="/private/var/mobile/MYFOLDER"
 
if [ $# -ne 1 ]
then
echo "Usage: $0 {/private/var/mobile/MYFOLDER}"
exit 0
fi
 
#Should it look something like this????? PLEASE HELP
if [ -d "$DIR" ]
elif [[ $1 == uninstall]]; then
rm -r "$DIR"   
fi
 
declare -a cydia
cydia=($CYDIA) 
 
if [[ ${CYDIA+@} ]]; then
        eval "echo 'finish:restart' >&${cydia[0]}" 
fi
 
exit

Thanx in advance!

Last edited by thazsar; 05-18-2012 at 12:11 PM..
# 2  
Old 05-18-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
# 3  
Old 05-18-2012
Replies will be faster at some times of the day than others. If you don't get a reply immediately, either wait or post more information. Sometimes, people aren't posting because they don't quite know what you want and aren't sure what to ask, either.

What's your system? How do you usually install packages?
# 4  
Old 05-18-2012
I just sent a reply to ur message. I sincerely apologize for violating the rules. My apology. :-(

---------- Post updated at 09:47 AM ---------- Previous update was at 09:44 AM ----------

I'm running Ubuntu but this application is being used in Cydia (iPhone jailbreak community). Thanx again for the reply! Sorry for the trouble...
# 5  
Old 05-18-2012
How is this cydia application typically used? Does it print options when you do cydia --help? I can't find a manual page for it which really limits what I can figure out about it.
# 6  
Old 05-18-2012
I apologize for my ignorance. I'm not sure if a --help page even exists for Cydia.

Cydia is an iPhone application similar to the Apple AppStore which hosts applications (specifically Debian packages). AFAIK, it's Linux-Based. Since it installs Debian packages, each package must have a DEBIAN folder that includes a 'control' file. If desirable, someone could include preinst, postinst, prerm & postrm files using bash script.

My specific bash script is in the postrm file which will initiate a soft-reboot after the uninstall, reinstall, or upgrade is completed.

Not sure if any of that info helps...
# 7  
Old 05-18-2012
It helps a fair bit actually, since we now know what context your script's being run inside.

What I would do is env > /tmp/cydia-env-$$ which should dump all available variables in the script to a unique temporary file($$ is the process ID, which changes every time). Then check to see if cydia's setting any relevant variables.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove folder contents

for dir in BKP/*/ do echo You are in :$dir done O/P -- BKP/201448/ BKP/201449/ BKP/201450/ BKP/201451/ BKP/201452/ BKP/201501/ BKP/201502/ BKP/201503/ BKP/201504/ BKP/201505/ BKP/201506/ BKP/201507/ (3 Replies)
Discussion started by: rocking77
3 Replies

2. Shell Programming and Scripting

Remove trailing space from file and folder names

I have a folder that contains many sub folders and files. This tree has to be backed up to an archive system. According to the tech support, one of the archives is failing to back up due to the possibility of trailing spaces on file and folder names. Therefore, I would like to have a script... (16 Replies)
Discussion started by: vipertech
16 Replies

3. Shell Programming and Scripting

Remove all folders within another folder except the lastest 1, 2 or 3.

I am using this command to remove all files and folders older than 24 hours; find /databackup/dbs/* -maxdepth 0 -type d -mtime +0 -exec rm -rf {} \; However, if/when backups to this folder fail and are not updated, it will completely destroy any backups we have in that folder. What can I add... (14 Replies)
Discussion started by: damang111
14 Replies

4. Shell Programming and Scripting

recursively remove javascript from all folder index files

Hi All, A site I manage had some javascript inserted into each folders index file. Can anyone priovide me with some ideas on how to use awk, sed or some other bash script to parse through each of the site folders and remove this code? If I have to do it by hand I'm going to go insane. :eek: ... (2 Replies)
Discussion started by: lsalsich
2 Replies

5. UNIX for Dummies Questions & Answers

Unable to remove folder in linux

Hi I am using red hat linux, In my folder a strange folder is created i.e. " -a " , folder name is preceded with hyphen. Now if i try to remove with rm -rf -1 , i am unable to do it. Can anyone please let me know how to do it, & what this kind of folder means Thanks Sarbjit (3 Replies)
Discussion started by: sarbjit
3 Replies

6. Shell Programming and Scripting

remove all duplicate lines from all files in one folder

Hi, is it possible to remove all duplicate lines from all txt files in a specific folder? This is too hard for me maybe someone could help. lets say we have an amount of textfiles 1 or 2 or 3 or... maximum 50 each textfile has lines with text. I want all lines of all textfiles... (8 Replies)
Discussion started by: lowmaster
8 Replies

7. BSD

Remove (uninstall) games and mail in netbsd

hi all, I am currently only need several basic applications for my box (basically : asterisk,apache-php,ssh) . However, i somehow running out of 1 Giga of my compact flash because the base installation in netbsd includes some softwares that I occasionally use Does any of you could guide me... (0 Replies)
Discussion started by: dsp
0 Replies

8. Shell Programming and Scripting

Remove zero bytes files in folder

Hi, Please shed some light on how to quickly remove all the zero bytes in which there are some mixtures of more than zero bytes in it. For eg: > ls -lrt -rw-r--r-- 1 ab noen 0 Jul 27 15:47 supplier_mp.unl -rw-rw-r-- 1 ab noen 507 Aug 5 14:13... (2 Replies)
Discussion started by: cedrichiu
2 Replies

9. Solaris

Perl - How to uninstall? Will pkgrm uninstall all versions?

Hello, I'm working on a Solaris 9/Sparc machine and it has the Solaris 10 version of Perl (5.8.8) installed on it, which always requires all kinds of library files that Solaris 9 doesn't come with. I think the best way to do is to uninstall this wrong version and install the correct Solaris 9... (1 Reply)
Discussion started by: alanlh
1 Replies
Login or Register to Ask a Question