2011-05-02 13:56:54 +02:00
|
|
|
Index: InitScriptCheck.py
|
|
|
|
===================================================================
|
|
|
|
--- InitScriptCheck.py.orig
|
2008-04-17 04:52:37 +02:00
|
|
|
+++ InitScriptCheck.py
|
2014-02-21 15:54:14 +01:00
|
|
|
@@ -30,6 +30,10 @@ lsb_tags_regex = re.compile('^# ([\w-]+)
|
2008-04-17 04:52:37 +02:00
|
|
|
lsb_cont_regex = re.compile('^#(?:\t| )(.*?)\s*$')
|
2011-05-31 13:31:05 +02:00
|
|
|
use_subsys = Config.getOption('UseVarLockSubsys', True)
|
|
|
|
|
2011-05-02 13:56:54 +02:00
|
|
|
+stop_on_removal_regex=re.compile('/etc/init.d/\$service stop > /dev/null')
|
|
|
|
+restart_on_update_regex=re.compile('/etc/init.d/\$service try-restart > /dev/null')
|
|
|
|
+insserv_cleanup_regex=re.compile('^\s*/sbin/insserv /etc/init.d$', re.MULTILINE)
|
2011-05-31 13:31:05 +02:00
|
|
|
+
|
2009-08-21 18:19:06 +02:00
|
|
|
LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop', 'Should-Start',
|
|
|
|
'Should-Stop', 'Default-Start', 'Default-Stop',
|
2011-05-31 13:31:05 +02:00
|
|
|
'Short-Description', 'Description')
|
2014-02-21 15:54:14 +01:00
|
|
|
@@ -47,6 +51,13 @@ class InitScriptCheck(AbstractCheck.Abst
|
2008-04-17 04:52:37 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
initscript_list = []
|
|
|
|
+
|
2009-08-21 18:19:06 +02:00
|
|
|
+
|
2008-04-17 04:52:37 +02:00
|
|
|
+ # check chkconfig call in %post and %preun
|
2012-09-13 18:01:40 +02:00
|
|
|
+ postin = pkg[rpm.RPMTAG_POSTIN] or pkg.scriptprog(pkg[rpm.RPMTAG_POSTINPROG])
|
|
|
|
+ preun = pkg[rpm.RPMTAG_PREUN] or pkg.scriptprog(pkg[rpm.RPMTAG_PREUNPROG])
|
|
|
|
+ postun = pkg[rpm.RPMTAG_POSTUN] or pkg.scriptprog(pkg[rpm.RPMTAG_POSTUNPROG])
|
2008-04-17 04:52:37 +02:00
|
|
|
+
|
2009-08-21 18:19:06 +02:00
|
|
|
for fname, pkgfile in pkg.files().items():
|
2008-04-17 04:52:37 +02:00
|
|
|
|
2011-04-21 12:12:02 +02:00
|
|
|
if not fname.startswith('/etc/init.d/') and \
|
2014-02-21 15:54:14 +01:00
|
|
|
@@ -61,20 +72,16 @@ class InitScriptCheck(AbstractCheck.Abst
|
2012-09-13 18:01:40 +02:00
|
|
|
if "." in basename:
|
2011-04-21 12:12:02 +02:00
|
|
|
printError(pkg, 'init-script-name-with-dot', fname)
|
2012-09-13 18:01:40 +02:00
|
|
|
|
2011-04-21 12:12:02 +02:00
|
|
|
- # check chkconfig call in %post and %preun
|
2012-09-13 18:01:40 +02:00
|
|
|
- postin = pkg[rpm.RPMTAG_POSTIN] or \
|
|
|
|
- pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
|
2011-04-21 12:12:02 +02:00
|
|
|
- if not postin:
|
|
|
|
- printError(pkg, 'init-script-without-chkconfig-postin', fname)
|
|
|
|
- elif not chkconfig_regex.search(postin):
|
|
|
|
- printError(pkg, 'postin-without-chkconfig', fname)
|
2011-05-02 13:56:54 +02:00
|
|
|
-
|
2012-09-13 18:01:40 +02:00
|
|
|
preun = pkg[rpm.RPMTAG_PREUN] or \
|
|
|
|
pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
|
2011-05-02 13:56:54 +02:00
|
|
|
- if not preun:
|
2011-04-21 12:12:02 +02:00
|
|
|
- printError(pkg, 'init-script-without-chkconfig-preun', fname)
|
|
|
|
- elif not chkconfig_regex.search(preun):
|
|
|
|
- printError(pkg, 'preun-without-chkconfig', fname)
|
2011-05-02 13:56:54 +02:00
|
|
|
+ if not preun or not stop_on_removal_regex.search(preun):
|
2011-04-21 12:12:02 +02:00
|
|
|
+ printError(pkg, 'init-script-without-%stop_on_removal-preun', fname)
|
2008-04-17 04:52:37 +02:00
|
|
|
+
|
2011-05-02 13:56:54 +02:00
|
|
|
+ if not postun or not restart_on_update_regex.search(postun):
|
2011-04-21 12:12:02 +02:00
|
|
|
+ printError(pkg, 'init-script-without-%restart_on_update-postun', fname)
|
2011-05-02 13:56:54 +02:00
|
|
|
+
|
|
|
|
+ if not postun or not insserv_cleanup_regex.search(postun):
|
|
|
|
+ printError(pkg, 'init-script-without-%insserv_cleanup-postun', fname)
|
2008-04-17 04:52:37 +02:00
|
|
|
|
2011-04-21 12:12:02 +02:00
|
|
|
status_found = False
|
|
|
|
reload_found = False
|
2014-02-21 15:54:14 +01:00
|
|
|
@@ -276,6 +283,17 @@ of chkconfig don't work as expected with
|
2008-04-17 04:52:37 +02:00
|
|
|
'init-script-non-executable',
|
|
|
|
'''The init script should have at least the execution bit set for root
|
|
|
|
in order for it to run at boot time.''',
|
|
|
|
+
|
|
|
|
+'init-script-without-%stop_on_removal-preun',
|
|
|
|
+'''The init script should have a %preun script that calls %stop_on_removal.''',
|
|
|
|
+
|
|
|
|
+'init-script-without-%insserv_cleanup-postun',
|
|
|
|
+'''The package doesn't have a %insserv_cleanup call in %postun''',
|
|
|
|
+
|
2011-04-21 12:12:02 +02:00
|
|
|
+'init-script-without-%restart_on_update-postun',
|
|
|
|
+''' The package has an init script but is missing the %restart_on_update
|
|
|
|
+call in %postun to automatically restart the daemon. This is optional,
|
|
|
|
+but in most cases it is wanted. Please check.'''
|
2008-04-17 04:52:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# InitScriptCheck.py ends here
|