From fa76ba5a7afa03ecb9edf7df36a9456b49d1d8da Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Wed, 23 Dec 2009 16:48:39 -1000 Subject: [PATCH] add support for copying dhclient.conf.template from a default file if it isn't found --- other/dhclient.conf.template | 3 --- other/dhclient.conf.template.default | 22 ++++++++++++++++++++++ setup.py | 2 +- wicd/wicd-daemon.py | 5 +++++ 4 files changed, 28 insertions(+), 4 deletions(-) delete mode 100644 other/dhclient.conf.template create mode 100644 other/dhclient.conf.template.default diff --git a/other/dhclient.conf.template b/other/dhclient.conf.template deleted file mode 100644 index e5ff6b2..0000000 --- a/other/dhclient.conf.template +++ /dev/null @@ -1,3 +0,0 @@ -# wicd will replace $_HOSTNAME in the following line with -# the appropriate hostname for this system -send host-name "$_HOSTNAME"; diff --git a/other/dhclient.conf.template.default b/other/dhclient.conf.template.default new file mode 100644 index 0000000..0ddfe57 --- /dev/null +++ b/other/dhclient.conf.template.default @@ -0,0 +1,22 @@ +# If you're reading this, you're probably reading either: +# /etc/wicd/dhclient.conf.template.default +# or +# /etc/wicd/dhclient.conf.template +# or +# a generated dhclient configuration in /var/run +# (these files could be in different locations, as determined by your +# packager or system administrator, but those are the default pathes) +# +# Here's what you need to know: +# The .default file is copied by wicd to dhclient.conf.template if +# dhclient.conf.template does not exist. If dhclient.conf.template +# does exist, the .default file is not used. This is to allow +# upgrades of the package without destroying user changes. +# +# In other words, if you want to change the generated dhclient +# configuration, you need to change dhclient.conf.template, +# NOT dhclient.conf.template.default + +# wicd will replace $_HOSTNAME in the following line with +# the appropriate hostname for this system +send host-name "$_HOSTNAME"; diff --git a/setup.py b/setup.py index b65e6b5..23980a3 100644 --- a/setup.py +++ b/setup.py @@ -473,7 +473,7 @@ try: data = [ (wpath.dbus, ['other/wicd.conf']), (wpath.log, []), - (wpath.etc, ['other/dhclient.conf.template']), + (wpath.etc, ['other/dhclient.conf.template.default']), (wpath.encryption, [('encryption/templates/' + b) for b in os.listdir('encryption/templates') if not b.startswith('.')]), (wpath.networks, []), diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 2a5f9e8..51eb1ba 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -34,6 +34,7 @@ class WirelessDaemon() -- DBus interface to managed the wireless network. # import os +import shutil import sys import time import getopt @@ -66,6 +67,7 @@ misc.RenameProcess("wicd") wireless_conf = wpath.etc + "wireless-settings.conf" wired_conf = wpath.etc + "wired-settings.conf" +dhclient_conf = wpath.etc + "dhclient.conf.template" class WicdDaemon(dbus.service.Object): """ The main wicd daemon class. @@ -936,6 +938,9 @@ class WicdDaemon(dbus.service.Object): open(wired_conf, "w").close() b_wired.CreateWiredNetworkProfile("wired-default", default=True) + if not os.path.isfile(dhclient_conf): + print "dhclient.conf.template not found, copying..." + shutil.copy(dhclient_conf + ".default", dhclient_conf) # Hide the files, so the keys aren't exposed. print "chmoding configuration files 0600..." os.chmod(app_conf.get_config(), 0600)