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

Contents 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.1 - (show annotations) (download)
Sat Feb 18 17:06:46 2017 UTC (7 years, 4 months ago) by stephdl
Branch: MAIN
CVS Tags: smeserver-yum-2_6_0-9_el7_sme
* Sat Feb 18 2017 stephane de Labrusse <stephdl@de-labrusse.fr> 2.6.0-9.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 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 +++ smeserver-yum-2.6.0.bz8705.new/root/usr/lib/yum-plugins/smeserver.py 2017-02-18 17:59:40.293143635 +0100
4 @@ -14,72 +14,250 @@
5 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 +servicenames['dovecot']='dovecot','pop3','pop3s'
37 +
38
39 smechange = False
40 ourfile = False
41
42 def report_yum_status(status):
43 - fileHandle = open(status_file, 'w')
44 - fileHandle.write(status)
45 - fileHandle.close()
46 + fileHandle = open(status_file, 'w')
47 + fileHandle.write(status)
48 + fileHandle.close()
49
50 def predownload_hook(conduit):
51 - report_yum_status('predownload')
52 + report_yum_status('predownload')
53
54 def postdownload_hook(conduit):
55 - report_yum_status('postdownload')
56 + report_yum_status('postdownload')
57
58 def prereposetup_hook(conduit):
59 - global ourfile
60 - ourfile = True
61 - report_yum_status('prereposetup')
62 + global ourfile
63 + global eventlist
64 + global actionlist
65 + global templateslist
66 + global serviceslist
67 +
68 + ourfile = True
69 + report_yum_status('prereposetup')
70
71 def postreposetup_hook(conduit):
72 - report_yum_status('postreposetup')
73 + report_yum_status('postreposetup')
74
75 def exclude_hook(conduit):
76 - report_yum_status('exclude')
77 + report_yum_status('exclude')
78
79 def preresolve_hook(conduit):
80 - report_yum_status('preresolve')
81 + report_yum_status('preresolve')
82
83 def postresolve_hook(conduit):
84 - report_yum_status('postresolve')
85 + report_yum_status('postresolve')
86
87 def pretrans_hook(conduit):
88 - report_yum_status('pretrans')
89 - ts = conduit.getTsInfo()
90 + report_yum_status('pretrans')
91 + # Prefetch filelist for packages to be removed,
92 + # otherwise for updated packages headers will not be available
93 + ts = conduit.getTsInfo()
94 + removes = ts.getMembersWithState(output_states=TS_REMOVE_STATES)
95 +
96 + global eventlist
97 + global actionlist
98 + global templateslist
99 + global serviceslist
100 +
101 + for tsmem in removes:
102 + (n, a, e, v, r) = tsmem.po.pkgtup
103 + print 'Package: ' + tsmem.name + ' remove'
104 + smeevent = tsmem.name + '-update'
105 + if os.path.isdir(events_path + os.sep + smeevent):
106 + tmppath = events_path + os.sep + smeevent + os.sep
107 + eventlist[tsmem.name] = smeevent
108 +
109 + if os.path.isdir(tmppath + "templates2expand" + os.sep):
110 + tmppathtmpl = tmppath + "templates2expand" + os.sep
111 + for subdir, dirs, files in os.walk(tmppathtmpl):
112 + for file in files:
113 + mytmptemplate = os.path.join(subdir, file).replace(tmppathtmpl,os.sep)
114 + if not templateslist.has_key(mytmptemplate):
115 + templateslist[mytmptemplate]=mytmptemplate
116 + #tmptmplpath = subdir + os.sep + file
117 + #print (file)
118 +
119 + if os.path.isdir(tmppath + "services2adjust" + os.sep):
120 + tmppathsrv = tmppath + "services2adjust" + os.sep
121 + files = [f for f in os.listdir(tmppathsrv)]
122 + for f in files:
123 + if os.path.islink(tmppathsrv + f):
124 + #print "link " + f + ": " + (os.readlink(tmppathsrv + f))
125 + mytmpserv = os.readlink(tmppathsrv + f)
126 + if not serviceslist.has_key(f):
127 + serviceslist[f]=mytmpserv
128 + else:
129 + print "old value: " + serviceslist[f]
130 + print "new value: " + mytmpserv
131 +
132 + if mytmpserv == "restart":
133 + print "overriding all signals, forcing restart"
134 + serviceslist[f]="restart"
135 +
136 + else:
137 + if n.startswith('smeserver') or n.startswith('e-smith'):
138 + smechange = True
139
140 def posttrans_hook(conduit):
141 - global smechange
142 - report_yum_status('posttrans')
143 - ts = conduit.getTsInfo()
144 - for tsmem in ts.getMembers():
145 - smeevent = 'yum-reconfigure-' + tsmem.name
146 - if os.path.isdir(events_path + '/' + smeevent):
147 - print "smeservers signal-event: " + smeevent
148 - os.spawnl(os.P_WAIT,
149 - signal_event, signal_event, smeevent)
150 -
151 - (n, a, e, v, r) = tsmem.po.pkgtup
152 - if n.startswith('sme') or n.startswith('e-smith') or n.startswith('kernel') or r.endswith('sme'):
153 - smechange = True
154 -
155 - if smechange:
156 - os.spawnl(os.P_WAIT, config_set, config_set, 'set', 'UnsavedChanges', 'yes')
157 - os.spawnl(os.P_WAIT, initialize_database, initialize_database)
158 - os.spawnl(os.P_WAIT, navigation_conf, navigation_conf)
159 + report_yum_status('posttrans')
160 + ts = conduit.getTsInfo()
161 +
162 + global smechange
163 + global eventlist
164 + global actionlist
165 + global templateslist
166 + global serviceslist
167 +
168 + for tsmem in ts.getMembers():
169 + (n, a, e, v, r) = tsmem.po.pkgtup
170 +
171 + # we're upgrading/installing/removing a rebootpkgs package.. a reboot is required
172 + for pkg in rebootpkgs:
173 + if n.startswith(pkg):
174 + #print 'Package: ' + tsmem.name + ' triggers reboot'
175 + smechange = True
176 +
177 +
178 + # check if we're upgrading a restartpkgs rpm
179 + for pkg in restartpkgs:
180 + #print pkg
181 + if n.startswith(pkg):
182 + if servicenames[pkg]:
183 + #print 'lista'
184 + for name in servicenames[pkg]:
185 + #print name
186 + if not serviceslist.has_key(name):
187 + serviceslist[name] = 'restart'
188 + else:
189 + print pkg
190 + if not serviceslist.has_key(pkg):
191 + serviceslist[pkg] = 'restart'
192 +
193 + #print serviceslist
194 +
195 + #if smechange is true we can ignore the following part
196 + if not smechange:
197 +
198 + smeevent = tsmem.name + '-update'
199 + if os.path.isdir(events_path + os.sep + smeevent):
200 + tmppath = events_path + os.sep + smeevent + os.sep
201 + eventlist[tsmem.name] = smeevent
202 +
203 + files = [f for f in os.listdir(tmppath)]
204 + for f in files:
205 + if os.path.islink(tmppath + f):
206 +
207 + mytmpaction = os.path.realpath(os.readlink(tmppath + f)).replace("/root/rpmbuild/RPMS",events_path)
208 + #print "link " + f + ": " + mytmpaction
209 +
210 + if not actionlist.has_key(mytmpaction):
211 + actionlist[mytmpaction] = mytmpaction
212 +
213 + if os.path.isdir(tmppath + "templates2expand" + os.sep):
214 + tmppathtmpl = tmppath + "templates2expand" + os.sep
215 + for subdir, dirs, files in os.walk(tmppathtmpl):
216 + for file in files:
217 + mytmptemplate = os.path.join(subdir, file).replace(tmppathtmpl,os.sep)
218 + if not templateslist.has_key(mytmptemplate):
219 + templateslist[mytmptemplate]=mytmptemplate
220 + #tmptmplpath = subdir + os.sep + file
221 + #print (file)
222 +
223 + if os.path.isdir(tmppath + "services2adjust" + os.sep):
224 + tmppathsrv = tmppath + "services2adjust" + os.sep
225 + files = [f for f in os.listdir(tmppathsrv)]
226 + for f in files:
227 + if os.path.islink(tmppathsrv + f):
228 + #print "link " + f + ": " + (os.readlink(tmppathsrv + f))
229 + mytmpserv = os.readlink(tmppathsrv + f)
230 + if not serviceslist.has_key(f):
231 + serviceslist[f]=mytmpserv
232 + else:
233 + print "old value: " + serviceslist[f]
234 + print "new value: " + mytmpserv
235 +
236 + if mytmpserv == "restart":
237 + print "overriding all signals, forcing restart"
238 + serviceslist[f]="restart"
239 +
240 + else:
241 + if n.startswith('smeserver') or n.startswith('e-smith'):
242 + smechange = True
243 +
244 + # check if smechange is true or if eventlist has items.. in both cases we must initialize databases
245 + if smechange == True or len(eventlist)>0:
246 + os.spawnl(os.P_WAIT, initialize_database, initialize_database)
247 +
248 + # now, if smechange is false (no reboot needed), we can execute actions, expan templates and adjust services
249 + if not smechange:
250 +
251 + if len(actionlist)>0:
252 + print "Executing actions"
253 + for kactions in actionlist:
254 + #print kactions
255 + os.spawnl(os.P_WAIT, kactions, kactions)
256 +
257 + if len(templateslist)>0:
258 + print "Expanding templates"
259 + for ktemplates in templateslist:
260 + #print ktemplates
261 + os.spawnl(os.P_WAIT, expand_template, expand_template, ktemplates)
262 +
263 + if len(serviceslist)>0:
264 + print "Adjusting services"
265 + for kservices in serviceslist:
266 + print kservices + ": " + serviceslist[kservices]
267 + os.spawnl(os.P_WAIT, service, service, kservices, serviceslist[kservices])
268 +
269 +
270 + if smechange:
271 + os.spawnl(os.P_WAIT, config_set, config_set, 'set', 'UnsavedChanges', 'yes')
272 + os.spawnl(os.P_WAIT, navigation_conf, navigation_conf)
273
274 def close_hook(conduit):
275 - if ourfile and os.path.isfile('/var/run/yum.status'):
276 - os.unlink('/var/run/yum.status')
277 + if ourfile and os.path.isfile('/var/run/yum.status'):
278 + os.unlink('/var/run/yum.status')
279
280 - if smechange:
281 - print "\n=============================================================="
282 - print "WARNING: You now need to run BOTH of the following commands"
283 - print "to ensure consistent system state:\n"
284 - print "signal-event post-upgrade; signal-event reboot\n"
285 - print "You should run these commands unless you are certain that"
286 - print "yum made no changes to your system."
287 - print "=============================================================="
288 + if smechange:
289 + print "\n=============================================================="
290 + print "WARNING: You now need to run BOTH of the following commands"
291 + print "to ensure consistent system state:\n"
292 + print "signal-event post-upgrade; signal-event reboot\n"
293 + print "You should run these commands unless you are certain that"
294 + print "yum made no changes to your system."
295 + print "=============================================================="
296

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