~charmers/charms/trusty/crashdump/trunk

« back to all changes in this revision

Viewing changes to hooks/crashdump_hooks.py

  • Committer: Louis Bouchard
  • Date: 2015-07-24 13:35:08 UTC
  • Revision ID: louis.bouchard@ubuntu.com-20150724133508-4ggy0f94yanf6cf2
Replace reboot path by variable

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
)
14
14
import os
15
15
 
 
16
REBOOT_REQUIRED = '/var/run/reboot-required'
16
17
KDUMP_CONF = '/etc/default/kdump-tools'
17
18
_EBAD = -1
18
19
 
23
24
def install():
24
25
    apt_update(fatal=True)
25
26
    apt_install(["linux-crashdump"], fatal=True)
26
 
    open('/var/run/reboot-required', 'w').close()
 
27
    open(REBOOT_REQUIRED, 'w').close()
27
28
 
28
29
 
29
30
@hooks.hook('upgrade-charm')
35
36
    if not os.path.exists("{}.ref".format(KDUMP_CONF)):
36
37
        shutil.copy("{}".format(KDUMP_CONF), "{}.ref".format(KDUMP_CONF))
37
38
    sed("{}".format(KDUMP_CONF), "USE_KDUMP=0", "USE_KDUMP=1")
38
 
    if os.path.isfile("/var/run/reboot-required"):
39
 
        os.remove("/var/run/reboot-required")
 
39
    if os.path.isfile(REBOOT_REQUIRED):
 
40
        os.remove(REBOOT_REQUIRED)
40
41
        subprocess.call(["juju-reboot", "--now"])
41
42
 
42
43