Why is my bash script merging folders?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why is my bash script merging folders?
# 1  
Old 05-03-2012
Why is my bash script merging folders?

I hope this thread is in the right forum...

This is for a .deb package that will be installed on Cydia.

Pre'note': I am installing a custom 'hosts' file and AdSheet.app directory. My problem is during a reinstall/upgrade. Cydia will run the entire installation process again, which means it executes the preinst file and postrm file (I don't know why it runs both during a reinstall). For some reason (?) the AdSheet.app directory will merge the 'original' folder and my 'custom' folder together and be placed back in /Applications.

During reinstalls/upgrades, I created a method for moving the original files from the Ads_Suck folder to the Just_In_Case folder so as to preserve those files.

I'm thinking, though, that if I make a script in the preinst file to check 'if' the Applications/AdSheet.app is = 0, 'then' STOP the rest of the installation.

Again, thanx in advance for any help...

PREINST:

Code:
#!/bin/bash

mkdir /private/var/mobile/Ads_Suck

mkdir /private/var/mobile/Just_In_Case

cp -R /private/var/mobile/Ads_Suck/hosts /private/var/mobile/Just_In_Case

cp -R /etc/hosts /private/var/mobile/Ads_Suck

rm -r /etc/hosts

cp -R /private/var/mobile/Ads_Suck/AdSheet.app /private/var/mobile/Just_In_Case

RESULTS_SIZE=`stat -c %s /Applications/AdSheet.app`
if [ "$RESULTS_SIZE" -eq 0 ]
then

    echo "AdSheet.app is 0kB in size. I'm not replacing it..." 
    exit 1;

else

    cp -R /Applications/AdSheet.app /private/var/mobile/Ads_Suck
    rm -r /Applications/AdSheet.app

fi

echo "Original files are in var/mobile/Ads_Suck"

echo "Original files are in var/mobile/Ads_Suck"

echo "Original files are in var/mobile/Ads_Suck"

echo "Original files are in var/mobile/Ads_Suck"

declare -a cydia
cydia=($CYDIA)

if [[ $1 == install || $1 == upgrade ]]; then
    if [[ ${CYDIA+@} ]]; then
        eval "echo 'finish:restart' >&${cydia[0]}"
    fi
fi

exit

POSTRM:


Code:
#!/bin/bash

rm -r /etc/hosts

rm -r /Application/AdSheet.app

cp -R /private/var/mobile/Ads_Suck/hosts /etc

cp -R /private/var/mobile/Ads_Suck/AdSheet.app /Applications

echo "Restoring the original files"

echo "Restoring the original files"

echo "Restoring the original files"

DIR="/private/var/mobile/Just_In_Case/AdSheet.app"

if [ $# -ne 1 ]
then
    echo "found AdSheet.app"
    exit 0
fi

if [ -d "$DIR" ]
then
   rm -r /Applications/AdSheet.app
   cp -R "$DIR" /Applications 
   rm -r "$DIR"
fi

DIR="/private/var/mobile/Just_In_Case/hosts"

if [ $# -ne 1 ]
then
    echo "found 'hosts' file"
    exit 0
fi

if [ -f "$DIR" ]
then
   rm -r /etc/hosts
   cp -R "$DIR" /etc
   rm -r "$DIR"
fi

rm -r /private/var/mobile/Ads_Suck

rm -r /private/var/mobile/Just_In_Case

declare -a cydia
cydia=($CYDIA) 

if [[ ${CYDIA+@} ]]; then
        eval "echo 'finish:restart' >&${cydia[0]}"    
fi

exit

# 2  
Old 05-05-2012
BUMP...

Anyone????
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

How can i move folders and its content if folder is older than 1,5 days and keep subdirs in bash?

Hello all, do you know any way i can i move folders and its content if folder is older than 1,5 days in bash? I tried: find /home/xyz/DATA/* -type d -ctime +1.5 -exec mv "{}" /home/xyz/move_data_here/ \;All i got was that Files from DATA /home/xyz/DATA/* ended messed up in... (1 Reply)
Discussion started by: ZerO13
1 Replies

3. Shell Programming and Scripting

Bash directory loop, but only choose those folders with specific word in it

Hello, how in bash i can get directory loop, but only choose those folders with specific word in it, so it will only echo those with specific word #!/bin/bash for filename in /home/test/* do if ; then echo $filename; fithx! (4 Replies)
Discussion started by: ZerO13
4 Replies

4. Shell Programming and Scripting

Bash to list all folders in a specific directory

The below bash is trying to list the folders in a specific directory. It seems close but adds the path to the filename, which basename could strip off I think, but not sure why it writes the text file created? This list of folders in the directory will be used later, but needs to only be the... (5 Replies)
Discussion started by: cmccabe
5 Replies

5. Shell Programming and Scripting

Bash to add folder to exsisting folders in directory

I am trying to create subdirectories in each folder in /home/cmccabe/Desktop/NGS/test/*. When I use echo I can see each folder in the directory, but I can not seem to add the commented out portion in bold. These are the sub-directories and sub-folders I am trying to add to each folder in... (1 Reply)
Discussion started by: cmccabe
1 Replies

6. Shell Programming and Scripting

Bash to move specific files from folders in find file

I have a directory /home/cmccabe/nfs/exportedReports that contains multiple folders in it. The find writes the name of each folder to out.txt. A new directory is then created in a new location /home/cmccabe/Desktop/NGS/API, named with the date. What I am trying to do, unsuccessfully at the moment,... (7 Replies)
Discussion started by: cmccabe
7 Replies

7. Shell Programming and Scripting

Bash to download specific files and save in two folders

I am trying to download all files from a user authentication, password protected https site, with a particular extension (.bam). The files are ~20GB each and I am not sure if the below is the best way to do it. I am also not sure how to direct the downloaded files to a folder as well as external... (7 Replies)
Discussion started by: cmccabe
7 Replies

8. Shell Programming and Scripting

Bash selective copy folders and content to another location

I'm looking for a bash scrypt to copy some folders and some of the content to another location. I'm a teacher and very noobish with programming language anyway what I'm looking for , I have this director structure Main director "Students" with subfolders "john";"daisy";"work" etc .. and some of... (2 Replies)
Discussion started by: brickleul
2 Replies

9. Shell Programming and Scripting

bash script for testing existence of files/folders and creating if neither exist

Hi, I am new to shell-scripting, and doing a lot of reading. I am having some trouble getting started with a simple testing of scripting. I have been experimenting with if, loops, for, test, etc., but still unsure. I seem to have the hang of it when it comes to creating a single file or... (6 Replies)
Discussion started by: me2
6 Replies

10. Shell Programming and Scripting

moving multiple folders/files in subversion using bash script

Hi, I'm new here an dlearning a lot from this forum. i didnt find any solution for this in the forum. I have already checked in folders in subversion named HTT01,... HTT21.. and have files in each folder like below: HTT01/HTT01_00000.hex HTT01/HTT01_00000_fb_result.hex... (2 Replies)
Discussion started by: ravishan21
2 Replies
Login or Register to Ask a Question