Jump to content
4 posts in this topic

Recommended Posts

OK,

 

So I want to create a simple preinstall bash script to go along with my PackageMaker project that will back up the kernel and then remove it to allow the installation of a new kernel. Here is my script:

 

#!/bin/bash
cp -r /mach_kernel /P35Backup/
rm -r /mach_kernel

 

Would that be correct? And what extension would I save it in to allow me to import it into PackageMaker? .sh shell script extension?

 

Thanks

~pcwis :P

Link to comment
https://www.insanelymac.com/forum/topic/91578-bash-scripts/
Share on other sites

So just save the script as plain text and import it? How would I chmod it? Like this?:

 

chmod +x ~/Desktop/script.sh

 

Thx

 

EDIT: Also, do I need to add "exit 0" to the end of the script? I saw this being done.

 

EDIT2: So I made a sample script just to check if I was doing things right:

 

!#/bin/bash
mkdir /P35Backup/
cp /mach_kernel /P35Backup

 

I save it as script.sh on the Desktop. Then I go to terminal and chmod it:

 

chmod +x ~/Desktop/script.sh

 

Then I run the script from within Terminal

 

sudo ~/Desktop/script.sh

 

The script is executed properly and P35Backup is made, mach kernel is copied and all but I get this warning in Terminal:

 

script.sh: line 1: !#/bin/bash: No such file or directory

 

Like I mean the script works, but I get that. Is that anything to worry about?

 

EDIT3:

 

AHA, I switched around the ! and the # and it works fine with no errors! AM I GOOD TO GO? :D :D :D

Link to comment
https://www.insanelymac.com/forum/topic/91578-bash-scripts/#findComment-653291
Share on other sites

×
×
  • Create New...