summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Howard <ben.howard@ubuntu.com>2012-06-22 09:10:22 -0600
committerusd-importer <ubuntu-server@lists.ubuntu.com>2012-07-13 13:33:37 +0000
commit9cb6642db12e07ff41df95f5ee36865d91b59991 (patch)
treefad38784ec071f7c88af5f26094a7e6510aa941e
parent342dba6f6102a286979361c86b89f8c65496c8f5 (diff)
downloadvyos-walinuxagent-9cb6642db12e07ff41df95f5ee36865d91b59991.tar.gz
vyos-walinuxagent-9cb6642db12e07ff41df95f5ee36865d91b59991.zip
Microsoft provided walinuxagent does not include the
Gbp-Pq: 000_ubuntu_init_resolvconf.patch.
-rw-r--r--waagent108
1 files changed, 84 insertions, 24 deletions
diff --git a/waagent b/waagent
index c6c8440..d2a6737 100644
--- a/waagent
+++ b/waagent
@@ -1970,6 +1970,26 @@ esac
exit $RETVAL
"""
+Init_Ubuntu = """\
+#walinuxagent - start Windows Azure agent
+
+description "walinuxagent"
+author "Ben Howard <ben.howard@canonical.com>"
+
+start on (filesystem and started rsyslog)
+
+pre-start script
+ if [ ! -x /usr/sbin/waagent ]; then
+ exit 1
+ fi
+
+ #Load the udf module
+ modprobe -b udf
+end script
+
+exec /usr/sbin/waagent -daemon
+"""
+
Init_Debian = """\
#!/bin/sh
### BEGIN INIT INFO
@@ -2135,18 +2155,30 @@ def Install():
os.remove(GetLastPathElement(a))
shutil.move(a, ".")
Warn("Moved " + a + " -> " + LibDir + "/" + GetLastPathElement(a) )
- filename = "waagent"
- filepath = "/etc/init.d/" + filename
- distro = IsRedHat() + IsDebian() * 2 + IsSuse() * 3
- if distro == 0:
- Error("Unable to detect Linux Distribution.")
- return 1
- init = [[Init_RedHat, "chkconfig --add " + filename],
- [Init_Debian, "update-rc.d " + filename + " defaults"],
- [Init_Suse, "insserv " + filename]][distro - 1]
- SetFileContents(filepath, init[0])
- os.chmod(filepath, 0755)
- Run(init[1])
+
+ if IsUbuntu():
+ # Support for Ubuntu's upstart configuration
+ filename="waagent.conf"
+ filepath = "/etc/init/" + filename
+ SetFileContents(filepath, Init_Ubuntu)
+ os.chmod(filepath, 0644)
+
+ else:
+ # Regular init.d configurations
+ filename = "waagent"
+ filepath = "/etc/init.d/" + filename
+
+ distro = IsRedHat() + IsDebian() * 2 + IsSuse()
+ if distro == 0:
+ Error("Unable to detect Linux Distribution.")
+ return 1
+ init = [[Init_RedHat, "chkconfig --add " + filename],
+ [Init_Debian, "update-rc.d " + filename + " defaults"],
+ [Init_Suse, "insserv " + filename]][distro - 1]
+ SetFileContents(filepath, init[0])
+ os.chmod(filepath, 0755)
+ Run(init[1])
+
if os.path.isfile("/etc/waagent.conf"):
try:
os.remove("/etc/waagent.conf.old")
@@ -2179,17 +2211,26 @@ def Uninstall():
Warn("Moved " + LibDir + "/" + GetLastPathElement(a) + " -> " + a )
except:
pass
+
+ filepath = "/etc/init.d/"
filename = "waagent"
- a = IsRedHat() + IsDebian() * 2 + IsSuse() * 3
- if a == 0:
- Error("Unable to detect Linux Distribution.")
- return 1
- Run("service " + filename + " stop")
- cmd = ["chkconfig --del " + filename,
- "update-rc.d -f " + filename + " remove",
- "insserv -r " + filename][a - 1]
- Run(cmd)
- for f in os.listdir(LibDir) + ["/etc/init.d/" + filename, "/etc/waagent.conf", "/etc/logrotate.d/waagent", "/etc/sudoers.d/waagent"]:
+
+ if IsUbuntu():
+ Run("stop " + filename)
+ filepath = "/etc/init/"
+ filename = "waagent.conf"
+ else:
+ a = IsRedHat() + IsDebian() * 2 + IsSuse() * 3
+ if a == 0:
+ Error("Unable to detect Linux Distribution.")
+ return 1
+ Run("service " + filename + " stop")
+ cmd = ["chkconfig --del " + filename,
+ "update-rc.d -f " + filename + " remove",
+ "insserv -r " + filename][a - 1]
+ Run(cmd)
+
+ for f in os.listdir(LibDir) + [filepath + filename, "/etc/waagent.conf", "/etc/logrotate.d/waagent", "/etc/sudoers.d/waagent"]:
try:
os.remove(f)
except:
@@ -2217,7 +2258,12 @@ def Deprovision(force, deluser):
print("WARNING! The waagent service will be stopped.")
print("WARNING! All SSH host key pairs will be deleted.")
- print("WARNING! Nameserver configuration in /etc/resolv.conf will be deleted.")
+
+ if IsUbuntu():
+ print("WARNING! Nameserver configuration in /etc/resolvconf/resolv.conf.d/{tail,originial} will be deleted.")
+ else:
+ print("WARNING! Nameserver configuration in /etc/resolv.conf will be deleted.")
+
print("WARNING! Cached DHCP leases will be deleted.")
delRootPass = Config.get("Provisioning.DeleteRootPassword")
@@ -2253,7 +2299,21 @@ def Deprovision(force, deluser):
Run("rm -f " + a + "/*")
# Clear LibDir, remove nameserver and root bash history
- for f in os.listdir(LibDir) + ["/etc/resolv.conf", "/root/.bash_history", "/var/log/waagent.log"]:
+ fileBlackList = [ "/root/.bash_history", "/var/log/waagent.log" ]
+
+ # Ubuntu uses resolvconf, so we want to preserve the ability to use resolvconf
+ if IsUbuntu():
+ if os.path.realpath('/etc/resolv.conf') != '/run/resolvconf/resolv.conf':
+ Log("resolvconf is not configured. Removing /etc/resolv.conf")
+ fileBlackList.append('/etc/resolv.conf')
+ else:
+ Log("resolvconf is enabled; leaving /etc/resolv.conf intact")
+ resolvConfD = '/etc/resolvconf/resolv.conf.d/'
+ fileBlackList.extend([resolvConfD + 'tail', resolvConfD + 'originial' ])
+ else:
+ fileBlackList.append(os.listdir(LibDir) + '/etc/resolv.conf')
+
+ for f in os.listdir(LibDir) + fileBlackList:
try:
os.remove(f)
except: