source: projects/vine-notify-update/data/check-reboot.lua @ 9642

Revision 9642, 1.6 KB checked in by daisuke, 9 years ago (diff)

add initial version of vine-notify-update

Line 
1-- This is a helper script to check installation of reboot-required
2-- packages.
3-- This script runs just after changes are commited to rpm database.
4
5filename = "/usr/share/vine-notify-update/reboot.list"
6
7
8-- Function to extract real package name from allow-duplicated packages.
9function realname(name)
10    local s, e, name = string.find(name, "(.+)#")
11    return name
12end
13
14-- Open list of packages that requires system reboot,
15-- Then read it and store package name into local table.
16local reboot = {}
17
18file = io.open(filename, "r")
19if not file then
20    print("error: can't open configuration file at "..filename)
21    return
22else
23    for line in io.lines(filename) do
24        local s, e = string.find(line, "reboot:")
25        if e then
26            table.insert(reboot, string.sub(line, e+1))
27        end
28    end
29    file:close()
30end
31
32-- Check configuration string RPM::RootDir:: to stop miss detection
33-- of reboot-required packages under vbootstrap/vbuilder chroot.
34-- (this string is usually blank, but vbootstrap set it)
35if confget("RPM::RootDir", "default") ~= "default" then
36   return
37end
38
39-- Check packages that is installed just now, and compare it with
40-- extraced list, Then check if reboot is required.
41local found = false
42
43for i, pkg in pairs(pkgs_install) do
44    local name = realname(pkgname(pkg))
45    if not name then
46        name = pkgname(pkg)
47    end
48    for i, name_r in pairs(reboot) do
49        if name == name_r then
50            found = true
51        end
52    end
53end
54
55if found then
56    print ("Reboot required.")
57    os.execute("touch /var/run/reboot-required")
58end
Note: See TracBrowser for help on using the repository browser.