Editing scripts from packages safely (was Re: * Synchronizing clock to ntp.ubuntulinux.org... ??? [on breezy startup])

Joe(theWordy)Philbrook jtwdyp at ttlc.net
Fri Aug 11 16:05:10 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It would appear that on Thu Aug 3, Daniel Pittman did say:
> "Joe(theWordy)Philbrook" <jtwdyp at ttlc.net> writes:
> > It would appear that on Aug 2, Derek Broughton did say:
> >
> >> The problem with moving any script is that it will tend to be
> >> reinstalled if the package is upgraded.
> >
> > That would be a pain...<sigh>
> 
> Actually, it doesn't have to be.  The dpkg system, which underlays
> Ubuntu packages, has good support for this.
> 
> You can use the 'dpkg-divert' tool to "divert" files from packages to
> another location.  This is used by some Ubuntu packages to extend the
> functionality of other packages, but you can use it yourself:
> 
>   sudo dpkg-divert --local --add /path/to/my/file
> 
> See the manual page for other options, including the ability to remove
> existing diversions and to direct the diverted file somewhere else.
> 
> That way you can add the diversion, make your local changes, and be
> comfortable that upgrades will not upset your local system changes.
> 
> Regards,
>         Daniel

Thanks for the idea Daniel... dpkg-divert appears to be a powerful tool.
However I figured out a personal kludge that I like better... I copied
the original ntpdate script someplace I can find it if I find reason to
put it back. Then edited it to contain one line " exit 0 " then wrote a
root script to test for modification (and automatically preserve, fix, and
notify me if updated. Then so that it would run at boot time I made a
symlink in /etc/rcS.d...

The version for my dapper installation is as follows:

#! /bin/bash
# zapFTPtimeupdate check that local time is NOT being auto-corrected,
# fix if changed, Notify jtwdyp via mail if fixed...
# to disable autoExecute rm link "/etc/rcS.d/S38zapFTPtimeupdate"
siZe=`wc -l /etc/network/if-up.d/ntpdate`
case $siZe in
	1*)echo "/etc/network/if-up.d/ntpdate is 1 line...GOOD";;
	 *)echo "WaRnInGwArNiNg /etc/network/if-up.d/ntpdate WAS updated";
	   echo "/etc/network/if-up.d/ntpdate WAS updated">/etc/network/if-up.NOT.d/TXT.ntpdate;
	   echo "detected & fixed by /root/bin/zapFTPtimeupdate on:">>/etc/network/if-up.NOT.d/TXT.ntpdate;
	   scaNdate=`date +%b_%d_%Y`;
	   date>>/etc/network/if-up.NOT.d/TXT.ntpdate;
	   echo "---<snip>---">>/etc/network/if-up.NOT.d/TXT.ntpdate;
	   cat /etc/network/if-up.d/ntpdate>>/etc/network/if-up.NOT.d/TXT.ntpdate;
	   cp /etc/network/if-up.d/ntpdate /etc/network/if-up.NOT.d/ntpdate_${scaNdate};
	   echo "exit 0">/etc/network/if-up.d/ntpdate;
	  mail jtwdyp -s "/etc/network/if-up.d/ntpdate WAS UPDATED!" </etc/network/if-up.NOT.d/TXT.ntpdate;;
esac

   #############################################################
   ##_if_you'd_prefer_an_clearsigned_".asc"_text_file_of_this_##
   ##message_as_an_mime_encoded_attachment,just_ask_me_while__##
   ##it's_STILL_IN_my_outbox_folder_._._._=+=+=+=+=+=+=+=+;-)_##
   #gpg sig for: Joe (theWordy) Philbrook DSA key ID 0x6C2163DE#
   # You can find my public gpg key at http://pgpkeys.mit.edu/ #
   #############################################################
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFE3Ju9RZ/61mwhY94RAmi5AJ902LIf9bBpcaOXs6MO3fNoXQd+KwCdEfEf
HswlHScmAhktfmduOEmxeYo=
=Cfbx
-----END PGP SIGNATURE-----
-- 
|   ---   ___
|   <0>   <->	   Joe (theWordy) Philbrook
|	^		J(tWdy)P
|    ~\___/~	     <<jtwdyp at ttlc.net>>




More information about the kubuntu-users mailing list