Change output format to match Tollef Fog Heen's proposal as this is easier to parse than tabs
Javier Fernandez-Sanguino
6 years ago
189 | 189 |
diverted = None
|
190 | 190 |
|
191 | 191 |
dpkgQuery = ["dpkg-query", "--search"] + list(programs.keys())
|
192 | |
if verbose and not machineOutput:
|
|
192 |
if verbose:
|
193 | 193 |
print("[DEBUG] Running: %s" % ' '.join(dpkgQuery))
|
194 | 194 |
dpkgProc = subprocess.Popen(dpkgQuery, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
195 | 195 |
env = lc_all_c_env)
|
|
326 | 326 |
print("These are the initd scripts:")
|
327 | 327 |
print('\n'.join(restartInitCommands))
|
328 | 328 |
print()
|
|
329 |
else:
|
|
330 |
for package in restartable:
|
|
331 |
for process in package.processes:
|
|
332 |
print('SERVICE:%s,%s,%s' % (package.name, process.pid,process.program))
|
329 | 333 |
|
330 | 334 |
if len(nonrestartable) == 0:
|
331 | 335 |
sys.exit(0)
|
|
340 | 344 |
print("\t%s\t%s" % (process.pid,process.program))
|
341 | 345 |
else:
|
342 | 346 |
for process in package.processes:
|
343 | |
print 'no-init\t%s\t%s\t%s' % (package.name,process.pid,process.program)
|
|
347 |
print('OTHER:%s,%s,%s' % (package.name,process.pid,process.program))
|
344 | 348 |
|
345 | 349 |
|
346 | 350 |
def lsoffilescheck(blacklist = None):
|
11 | 11 |
.SH NAME
|
12 | 12 |
checkrestart \- check which processes need to be restarted after an upgrade
|
13 | 13 |
.SH SYNOPSIS
|
14 | |
.B checkrestart [ -hvpan ] [ -b blacklist_file ] [ -i package_name ] [ -e pid ]
|
|
14 |
.B checkrestart [ -hvpanm ] [ -b blacklist_file ] [ -i package_name ] [ -e pid ]
|
15 | 15 |
.SH DESCRIPTION
|
16 | 16 |
The
|
17 | 17 |
.B checkrestart
|
|
61 | 61 |
simultaneously with the
|
62 | 62 |
.B -p
|
63 | 63 |
option.
|
|
64 |
|
|
65 |
.TP
|
|
66 |
\fB-m\fP, \fB\-\-machine\fP
|
|
67 |
Generate machine readable output. One line is printed per program which must be
|
|
68 |
restarted: "TYPE:package_name,pid,program". Where TYPE is
|
|
69 |
.B INIT
|
|
70 |
, if a systemd service file or an init script is available to restart the program, and
|
|
71 |
.B OTHER
|
|
72 |
otherwise.
|
64 | 73 |
|
65 | 74 |
.TP
|
66 | 75 |
\fB\-b\fP \fIfile\fP, \fB\-\-blacklist=\fP\fIfile\fP
|
|
157 | 166 |
isc-dhcp-client:
|
158 | 167 |
3775 /sbin/dhclient
|
159 | 168 |
|
|
169 |
This is another example to show the machine-readable output:
|
|
170 |
|
|
171 |
# checkrestart --machine
|
|
172 |
init bcfg2-server 6974 /usr/sbin/bcfg2-server
|
|
173 |
init exim4-daemon-light 857 /usr/sbin/exim4
|
|
174 |
no-init aptitude 11679 /usr/bin/aptitude-curses
|
|
175 |
no-init xscreensaver 6562 /usr/bin/xscreensaver
|
|
176 |
|
160 | 177 |
.SH BUGS
|
161 | 178 |
This program might fail if the output of the \fBlsof(8)\fP utility changes since it
|
162 | 179 |
depends on it to detect which deleted files are used by processes. It might
|