Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Creating and applying a patch to a file  (Read 2273 times)

0 Members and 1 Guest are viewing this topic.

Aby

  • Guest
Creating and applying a patch to a file
« on: January 21, 2014, 02:03:31 pm »
Creating and applying a patch to a file

What's a patch? 
Say you've got a file, let's use the /etc/exim.conf as an example, and you need to make changes to that file many times over.
This may be the case if you have many servers, and you want all of them to have the same changes made.
The best way to make the same changes to the exim.conf, but to also allow the default exim.conf to have differences in other areas, is to use a patch.


Creating a patch


1) To create a patch, first copy your original:

cd /etc
cp exim.conf exim.conf.orig


2) Now manually make all the changes you want to your exim.conf:

nano exim.conf

3) Create the patch:

diff -u exim.conf.orig exim.conf > exim.conf.patch

You've now got a patch file which can be applied to the original exim.conf for other systems, or if you re-install, etc..
Save it to a location on your website so it can be downloaded to other servers.

Applying your patch
You've got a patch file, and your default exim.conf, and your want your changes to be applied.

4) Save the patch beside the file:

cd /etc/
wget http://your.server.com/exim.conf.patch



5) Apply the patch:

patch -p0 < exim.conf.patch

And you're done, Your patched exim.conf should now have all of the changes that were manually done to the original.

!!


mohitht

  • Guest
Re: Creating and applying a patch to a file
« Reply #1 on: January 24, 2014, 01:34:53 pm »
Great  :)