Bug 38332 - Cleanup scripts not run if running join from cli
Cleanup scripts not run if running join from cli
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: System setup
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.0-1-errata
Assigned To: Erik Damrose
Alexander Kläser
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-04-23 13:24 CEST by Erik Damrose
Modified: 2015-05-07 17:43 CEST (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Damrose univentionstaff 2015-04-23 13:24:00 CEST
To join a system from the cli, univention-system-setup provides the script setup-join.sh. The is also called from the umc setup module.

However, we have several scripts which are to be executed after system setup is completely finished, placed in /usr/lib/univention-system-setup/cleanup-{pre.d,post.d}. However, these are only called as an at job from the UMC module.

No cleanup script will run when running setup-join.sh from the cli! This affects at least systems joining in ec2 and with cloud-init.
Comment 1 Alexander Kläser univentionstaff 2015-04-23 14:17:35 CEST
It would be nice to offer an option such as --run-cleanup for setup-join.sh.
Comment 2 Erik Damrose univentionstaff 2015-04-24 16:23:36 CEST
Or just the other way around: implement a --do-not-run-cleanup, which is used by system setup - because it is currently the only consumer who does it itself
Comment 3 Erik Damrose univentionstaff 2015-05-05 13:51:51 CEST
- I added a new parameter --do_not_run_cleanup, which is added by the UMC system setup module to the setup-join.sh call. If not given, run-parts calls are done at the end of the setup-join.sh script.
While i was at it, i modified the run-parts calls to print the executed filename. This will help debugging the setup.log file.

r60407 univention-system-setup 8.1.66-37.878.201505051342
r60408 2015-05-05-univention-system-setup.yaml
Comment 4 Alexander Kläser univentionstaff 2015-05-05 16:04:12 CEST
Looks very nice :) . I would suggest to replace the following lines
-------------------- 8< --------------------
[...]
if [ "$runcleanup" = true ]; then
	echo "=== Running cleanup-pre scripts $(date --rfc-3339=seconds)"
	run-parts -v /usr/lib/univention-system-setup/cleanup-pre.d
	echo "=== Running cleanup-post scripts $(date --rfc-3339=seconds)"
	run-parts -v /usr/lib/univention-system-setup/cleanup-post.d
else
[...]
-------------------- 8< --------------------

... with a call to /usr/lib/univention-system-setup/scripts/cleanup.py. This script is called via UMC, as well. It also takes care of copying the original scripts and executing their copies in order to prevent problems that might occur due to removing particular packages that ship cleanup scripts with them.
Comment 5 Alexander Kläser univentionstaff 2015-05-05 16:08:08 CEST
Another thing that I noticed... "run-parts -v" is not working as expected, it seems to write to stderr. Thus its output cannot be found in setup.log.
Comment 6 Erik Damrose univentionstaff 2015-05-05 17:24:52 CEST
(In reply to Alexander Kläser from comment #5)
> Another thing that I noticed... "run-parts -v" is not working as expected,
> it seems to write to stderr. Thus its output cannot be found in setup.log.
We identified that as an isolated problem during QA

Switched to cleanup script in:
r60424 univention-system-setup 8.1.66-39.880.201505051712
yaml updated
Comment 7 Alexander Kläser univentionstaff 2015-05-05 18:31:00 CEST
I just realized that cleanup.py redirects its stdout itself to /var/log/univention/setup.log... not sure whether this might collide when setup-join.sh is called with a redirection to setup.log? What do you think?
Comment 8 Erik Damrose univentionstaff 2015-05-06 11:42:55 CEST
(In reply to Alexander Kläser from comment #7)
> I just realized that cleanup.py redirects its stdout itself to
> /var/log/univention/setup.log... not sure whether this might collide when
> setup-join.sh is called with a redirection to setup.log? What do you think?

No it does not collide. cleanup.py redirects its output, and the caller setup-join.sh simply receives nothing on stdout/stderr to redirect. To be sure i tested it with 
# /usr/lib/univention-system-setup/scripts/setup-join.sh >>/var/log/univention/setup.log 2>&1
Comment 9 Alexander Kläser univentionstaff 2015-05-06 16:45:14 CEST
I like the last commit :) ...

univention-system-setup (8.1.66-41) [r60481]:
* Bug #38332: cleanup.py does no longer redirect its output by
  default. util.py has been adapted accordingly

Changes: OK
YAML: OK, minor adjustment [r60486].
Comment 10 Janek Walkenhorst univentionstaff 2015-05-07 17:43:15 CEST
<http://errata.univention.de/ucs/4.0/190.html>