/[smeserver]/rpms/smeserver-yum/sme10/smeserver-yum-2.6.0.bz8705.avoidReboot.patch
ViewVC logotype

Annotation of /rpms/smeserver-yum/sme10/smeserver-yum-2.6.0.bz8705.avoidReboot.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Sun Feb 19 21:05:27 2017 UTC (7 years, 4 months ago) by stephdl
Branch: MAIN
CVS Tags: smeserver-yum-2_6_0-12_el7_sme, smeserver-yum-2_6_0-20_el7_sme, smeserver-yum-2_6_0-17_el7_sme, smeserver-yum-2_6_0-60_el7_sme, smeserver-yum-2_6_0-39_el7_sme, smeserver-yum-2_6_0-28_el7_sme, smeserver-yum-2_6_0-29_el7_sme, smeserver-yum-2_6_0-48_el7_sme, smeserver-yum-2_6_0-21_el7_sme, smeserver-yum-2_6_0-46_el7_sme, smeserver-yum-2_6_0-34_el7_sme, smeserver-yum-2_6_0-52_el7_sme, smeserver-yum-2_6_0-62_el7_sme, smeserver-yum-2_6_0-49_el7_sme, smeserver-yum-2_6_0-44_el7_sme, smeserver-yum-2_6_0-47_el7_sme, smeserver-yum-2_6_0-51_el7_sme, smeserver-yum-2_6_0-45_el7_sme, smeserver-yum-2_6_0-40_el7_sme, smeserver-yum-2_6_0-50_el7_sme, smeserver-yum-2_6_0-25_el7_sme, smeserver-yum-2_6_0-31_el7_sme, smeserver-yum-2_6_0-27_el7_sme, smeserver-yum-2_6_0-22_el7_sme, smeserver-yum-2_6_0-24_el7_sme, smeserver-yum-2_6_0-61_el7_sme, smeserver-yum-2_6_0-64_el7_sme, smeserver-yum-2_6_0-13_el7_sme, smeserver-yum-2_6_0-23_el7_sme, smeserver-yum-2_6_0-15_el7_sme, smeserver-yum-2_6_0-36_el7_sme, smeserver-yum-2_6_0-26_el7_sme, smeserver-yum-2_6_0-32_el7_sme, smeserver-yum-2_6_0-58_el7_sme, smeserver-yum-2_6_0-55_el7_sme, smeserver-yum-2_6_0-19_el7_sme, smeserver-yum-2_6_0-37_el7_sme, smeserver-yum-2_6_0-14_el7_sme, smeserver-yum-2_6_0-41_el7_sme, smeserver-yum-2_6_0-30_el7_sme, smeserver-yum-2_6_0-33_el7_sme, smeserver-yum-2_6_0-35_el7_sme, smeserver-yum-2_6_0-16_el7_sme, smeserver-yum-2_6_0-57_el7_sme, smeserver-yum-2_6_0-54_el7_sme, smeserver-yum-2_6_0-42_el7_sme, smeserver-yum-2_6_0-56_el7_sme, smeserver-yum-2_6_0-53_el7_sme, smeserver-yum-2_6_0-43_el7_sme, smeserver-yum-2_6_0-18_el7_sme, smeserver-yum-2_6_0-10_el7_sme, smeserver-yum-2_6_0-59_el7_sme, smeserver-yum-2_6_0-38_el7_sme, smeserver-yum-2_6_0-11_el7_sme, smeserver-yum-2_6_0-63_el7_sme
Changes since 1.1: +59 -31 lines
* Sat Feb 18 2017 stephane de Labrusse <stephdl@de-labrusse.fr> 2.6.0-10.sme
- Added smeserver-yum-2.6.0.bz8705.avoidReboot.patch
- code by stefano zamboni <zamboni@mind-at-work.it>
- Avoid to reboot after the installation of a smeserver-* package

1 stephdl 1.1 diff -Nur smeserver-yum-2.6.0.bz8705.old/root/usr/lib/yum-plugins/smeserver.py smeserver-yum-2.6.0.bz8705.new/root/usr/lib/yum-plugins/smeserver.py
2     --- smeserver-yum-2.6.0.bz8705.old/root/usr/lib/yum-plugins/smeserver.py 2013-01-31 17:35:08.000000000 +0100
3 stephdl 1.2 +++ smeserver-yum-2.6.0.bz8705.new/root/usr/lib/yum-plugins/smeserver.py 2017-02-19 22:03:21.922929438 +0100
4     @@ -14,72 +14,278 @@
5 stephdl 1.1 signal_event = '/sbin/e-smith/signal-event'
6     config_set = '/sbin/e-smith/config'
7     status_file = '/var/run/yum.status'
8     +expand_template = '/sbin/e-smith/expand-template'
9     +service = '/sbin/e-smith/service'
10     +
11     +eventlist = dict()
12     +actionlist = dict()
13     +templateslist = dict()
14     +serviceslist = dict()
15     +
16     +
17     +# list of packages that need a reboot
18     +# if a package name starts with one these names, a reboot is needed
19     +rebootpkgs = ['kernel', 'glibc', 'linux-firmware', 'systemd', 'udev', 'openssl-libs', 'gnutls', 'dbus', 'daemontools', 'lvm2', 'mdadm']
20     +
21     +# list of packages that need a service restart
22     +# if a package name starts with one of these values, a service restart is needed
23     +# since, for example, httpd means httpd-admin and httpd-e-smith, we won't use these names directly but via serviceslist (see below)
24     +restartpkgs = ['httpd', 'openssh', 'openldap', 'squid', 'dovecot', 'nut', 'freeradius', 'iptables', 'mysql', 'php', 'pptpd', 'proftp', 'qmail', 'qpsmtpd', 'samba', 'spamassassin']
25     +servicenames = dict()
26     +servicenames['httpd']='httpd-admin','httpd-e-smith'
27     +servicenames['openssh']='sshd',
28     +servicenames['openldap']='slapd',
29     +servicenames['freeradius']='radiusd',
30     +servicenames['iptables']='masq',
31     +servicenames['mysql']='mysqld',
32     +servicenames['php']='httpd-e-smith',
33     +servicenames['proftp']='proftpd',
34     +servicenames['samba']='smbd',
35     +servicenames['spamassassin']='spamd',
36 stephdl 1.2 +servicenames['squid']='squid',
37 stephdl 1.1 +servicenames['dovecot']='dovecot','pop3','pop3s'
38     +
39    
40     smechange = False
41     ourfile = False
42 stephdl 1.2 +erasing = False
43 stephdl 1.1
44     def report_yum_status(status):
45     - fileHandle = open(status_file, 'w')
46     - fileHandle.write(status)
47     - fileHandle.close()
48     + fileHandle = open(status_file, 'w')
49     + fileHandle.write(status)
50     + fileHandle.close()
51    
52     def predownload_hook(conduit):
53     - report_yum_status('predownload')
54     + report_yum_status('predownload')
55    
56     def postdownload_hook(conduit):
57     - report_yum_status('postdownload')
58     + report_yum_status('postdownload')
59    
60     def prereposetup_hook(conduit):
61     - global ourfile
62     - ourfile = True
63     - report_yum_status('prereposetup')
64     + global ourfile
65     +
66     + ourfile = True
67     + report_yum_status('prereposetup')
68    
69     def postreposetup_hook(conduit):
70     - report_yum_status('postreposetup')
71     + report_yum_status('postreposetup')
72    
73     def exclude_hook(conduit):
74     - report_yum_status('exclude')
75     + report_yum_status('exclude')
76    
77     def preresolve_hook(conduit):
78     - report_yum_status('preresolve')
79     + report_yum_status('preresolve')
80    
81     def postresolve_hook(conduit):
82     - report_yum_status('postresolve')
83     + report_yum_status('postresolve')
84    
85     def pretrans_hook(conduit):
86     - report_yum_status('pretrans')
87     - ts = conduit.getTsInfo()
88     + report_yum_status('pretrans')
89     + # Prefetch filelist for packages to be removed,
90     + # otherwise for updated packages headers will not be available
91     + ts = conduit.getTsInfo()
92     + removes = ts.getMembersWithState(output_states=TS_REMOVE_STATES)
93 stephdl 1.2 + global smechange
94 stephdl 1.1 + global eventlist
95     + global actionlist
96     + global templateslist
97     + global serviceslist
98 stephdl 1.2 + global erasing
99     +
100 stephdl 1.1 + for tsmem in removes:
101 stephdl 1.2 + erasing = True
102 stephdl 1.1 + (n, a, e, v, r) = tsmem.po.pkgtup
103 stephdl 1.2 + #only for debug
104     + #print 'Package: ' + tsmem.name + ' remove'
105 stephdl 1.1 + smeevent = tsmem.name + '-update'
106 stephdl 1.2 + #only for debug
107     + #print smeevent
108 stephdl 1.1 + if os.path.isdir(events_path + os.sep + smeevent):
109     + tmppath = events_path + os.sep + smeevent + os.sep
110     + eventlist[tsmem.name] = smeevent
111     +
112     + if os.path.isdir(tmppath + "templates2expand" + os.sep):
113     + tmppathtmpl = tmppath + "templates2expand" + os.sep
114     + for subdir, dirs, files in os.walk(tmppathtmpl):
115     + for file in files:
116     + mytmptemplate = os.path.join(subdir, file).replace(tmppathtmpl,os.sep)
117     + if not templateslist.has_key(mytmptemplate):
118     + templateslist[mytmptemplate]=mytmptemplate
119     + #tmptmplpath = subdir + os.sep + file
120     + #print (file)
121     +
122     + if os.path.isdir(tmppath + "services2adjust" + os.sep):
123     + tmppathsrv = tmppath + "services2adjust" + os.sep
124     + files = [f for f in os.listdir(tmppathsrv)]
125     + for f in files:
126     + if os.path.islink(tmppathsrv + f):
127     + #print "link " + f + ": " + (os.readlink(tmppathsrv + f))
128     + mytmpserv = os.readlink(tmppathsrv + f)
129     + if not serviceslist.has_key(f):
130     + serviceslist[f]=mytmpserv
131     + else:
132 stephdl 1.2 + #only for debug
133     + #print "old value: " + serviceslist[f]
134     + #print "new value: " + mytmpserv
135 stephdl 1.1 +
136     + if mytmpserv == "restart":
137     + print "overriding all signals, forcing restart"
138     + serviceslist[f]="restart"
139     +
140     + else:
141     + if n.startswith('smeserver') or n.startswith('e-smith'):
142     + smechange = True
143 stephdl 1.2 +
144     + #only for debug
145     + #print 'smechange: '+str(smechange)
146     + #print 'eventlist: '+ str(eventlist)
147     + #print 'templateslist: '+str(templateslist)
148     + #print 'serviceslist: '+str(serviceslist)
149 stephdl 1.1
150     def posttrans_hook(conduit):
151     - global smechange
152     - report_yum_status('posttrans')
153     - ts = conduit.getTsInfo()
154     - for tsmem in ts.getMembers():
155     - smeevent = 'yum-reconfigure-' + tsmem.name
156     - if os.path.isdir(events_path + '/' + smeevent):
157     - print "smeservers signal-event: " + smeevent
158     - os.spawnl(os.P_WAIT,
159     - signal_event, signal_event, smeevent)
160     -
161     - (n, a, e, v, r) = tsmem.po.pkgtup
162     - if n.startswith('sme') or n.startswith('e-smith') or n.startswith('kernel') or r.endswith('sme'):
163     - smechange = True
164     -
165     - if smechange:
166     - os.spawnl(os.P_WAIT, config_set, config_set, 'set', 'UnsavedChanges', 'yes')
167     - os.spawnl(os.P_WAIT, initialize_database, initialize_database)
168     - os.spawnl(os.P_WAIT, navigation_conf, navigation_conf)
169     + report_yum_status('posttrans')
170     + ts = conduit.getTsInfo()
171     +
172     + global smechange
173     + global eventlist
174     + global actionlist
175     + global templateslist
176     + global serviceslist
177 stephdl 1.2 + global erasing
178 stephdl 1.1 +
179 stephdl 1.2 +
180 stephdl 1.1 + for tsmem in ts.getMembers():
181     + (n, a, e, v, r) = tsmem.po.pkgtup
182 stephdl 1.2 +
183     + #print 'smechange: '+str(smechange)
184     +
185 stephdl 1.1 + # we're upgrading/installing/removing a rebootpkgs package.. a reboot is required
186     + for pkg in rebootpkgs:
187     + if n.startswith(pkg):
188     + #print 'Package: ' + tsmem.name + ' triggers reboot'
189     + smechange = True
190     +
191     +
192     + # check if we're upgrading a restartpkgs rpm
193     + for pkg in restartpkgs:
194     + #print pkg
195     + if n.startswith(pkg):
196     + if servicenames[pkg]:
197     + #print 'lista'
198     + for name in servicenames[pkg]:
199     + #print name
200     + if not serviceslist.has_key(name):
201     + serviceslist[name] = 'restart'
202     + else:
203 stephdl 1.2 + #only for debug
204     + #print pkg
205 stephdl 1.1 + if not serviceslist.has_key(pkg):
206     + serviceslist[pkg] = 'restart'
207     +
208     +
209     + #if smechange is true we can ignore the following part
210 stephdl 1.2 + if not smechange and not erasing:
211 stephdl 1.1 +
212 stephdl 1.2 + #smeevent = 'yum-reconfigure-' + tsmem.name
213 stephdl 1.1 + smeevent = tsmem.name + '-update'
214     + if os.path.isdir(events_path + os.sep + smeevent):
215     + tmppath = events_path + os.sep + smeevent + os.sep
216     + eventlist[tsmem.name] = smeevent
217     +
218     + files = [f for f in os.listdir(tmppath)]
219     + for f in files:
220     + if os.path.islink(tmppath + f):
221     +
222     + mytmpaction = os.path.realpath(os.readlink(tmppath + f)).replace("/root/rpmbuild/RPMS",events_path)
223     + #print "link " + f + ": " + mytmpaction
224     +
225     + if not actionlist.has_key(mytmpaction):
226     + actionlist[mytmpaction] = mytmpaction
227     +
228     + if os.path.isdir(tmppath + "templates2expand" + os.sep):
229     + tmppathtmpl = tmppath + "templates2expand" + os.sep
230     + for subdir, dirs, files in os.walk(tmppathtmpl):
231     + for file in files:
232     + mytmptemplate = os.path.join(subdir, file).replace(tmppathtmpl,os.sep)
233     + if not templateslist.has_key(mytmptemplate):
234     + templateslist[mytmptemplate]=mytmptemplate
235     + #tmptmplpath = subdir + os.sep + file
236     + #print (file)
237     +
238     + if os.path.isdir(tmppath + "services2adjust" + os.sep):
239     + tmppathsrv = tmppath + "services2adjust" + os.sep
240     + files = [f for f in os.listdir(tmppathsrv)]
241     + for f in files:
242     + if os.path.islink(tmppathsrv + f):
243     + #print "link " + f + ": " + (os.readlink(tmppathsrv + f))
244     + mytmpserv = os.readlink(tmppathsrv + f)
245     + if not serviceslist.has_key(f):
246     + serviceslist[f]=mytmpserv
247     + else:
248 stephdl 1.2 + #only for debug
249     + #print "old value: " + serviceslist[f]
250     + #print "new value: " + mytmpserv
251 stephdl 1.1 +
252     + if mytmpserv == "restart":
253 stephdl 1.2 + #only for debug
254 stephdl 1.1 + print "overriding all signals, forcing restart"
255     + serviceslist[f]="restart"
256     +
257     + else:
258     + if n.startswith('smeserver') or n.startswith('e-smith'):
259     + smechange = True
260     +
261 stephdl 1.2 +
262     + #only for debug
263     + #print 'smechange: '+str(smechange)
264     + #print 'post-trans'
265     + #print 'eventlist: '+ str(eventlist)
266     + #print 'templateslist: '+str(templateslist)
267     + #print 'serviceslist: '+str(serviceslist)
268     +
269 stephdl 1.1 + # check if smechange is true or if eventlist has items.. in both cases we must initialize databases
270     + if smechange == True or len(eventlist)>0:
271 stephdl 1.2 + print 'Initializing databases'
272 stephdl 1.1 + os.spawnl(os.P_WAIT, initialize_database, initialize_database)
273     +
274     + # now, if smechange is false (no reboot needed), we can execute actions, expan templates and adjust services
275 stephdl 1.2 + #if not smechange:
276 stephdl 1.1 +
277 stephdl 1.2 + if len(actionlist)>0:
278     + print "Executing actions"
279     + for kactions in actionlist:
280     + #print kactions
281     + if os.path.isfile(kactions):
282 stephdl 1.1 + os.spawnl(os.P_WAIT, kactions, kactions)
283     +
284 stephdl 1.2 + if len(templateslist)>0:
285     + print "Expanding templates"
286     + for ktemplates in templateslist:
287     + #print ktemplates
288     + if os.path.isfile(ktemplates):
289 stephdl 1.1 + os.spawnl(os.P_WAIT, expand_template, expand_template, ktemplates)
290     +
291 stephdl 1.2 + if len(serviceslist)>0:
292     + print "Adjusting services"
293     + for kservices in serviceslist:
294     + print kservices + ": " + serviceslist[kservices]
295     + os.spawnl(os.P_WAIT, service, service, kservices, serviceslist[kservices])
296 stephdl 1.1 +
297     +
298     + if smechange:
299     + os.spawnl(os.P_WAIT, config_set, config_set, 'set', 'UnsavedChanges', 'yes')
300     + os.spawnl(os.P_WAIT, navigation_conf, navigation_conf)
301    
302     def close_hook(conduit):
303     - if ourfile and os.path.isfile('/var/run/yum.status'):
304     - os.unlink('/var/run/yum.status')
305     + if ourfile and os.path.isfile('/var/run/yum.status'):
306     + os.unlink('/var/run/yum.status')
307    
308     - if smechange:
309     - print "\n=============================================================="
310     - print "WARNING: You now need to run BOTH of the following commands"
311     - print "to ensure consistent system state:\n"
312     - print "signal-event post-upgrade; signal-event reboot\n"
313     - print "You should run these commands unless you are certain that"
314     - print "yum made no changes to your system."
315     - print "=============================================================="
316     + if smechange:
317     + print "\n=============================================================="
318     + print "WARNING: You now need to run BOTH of the following commands"
319     + print "to ensure consistent system state:\n"
320     + print "signal-event post-upgrade; signal-event reboot\n"
321     + print "You should run these commands unless you are certain that"
322     + print "yum made no changes to your system."
323     + print "=============================================================="
324    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed