Last active
January 26, 2016 02:50
-
-
Save joemiller/ebbe41f9d3294a64547b to your computer and use it in GitHub Desktop.
search for systemd units in .wants or .requires dirs that are regular files and convert them back to symlinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| set -ex | |
| for i in $(find /etc/systemd/system/ -maxdepth 2 -mindepth 1 -type d); do | |
| if ! grep -qP '\.wants|\.requires' <<<"$i"; then | |
| continue | |
| fi | |
| for f in $(find $i -type f); do | |
| #echo $f is a regular file | |
| unit_name=$(basename $f) | |
| if [ -f "/etc/systemd/system/$unit_name" ]; then | |
| #echo $unit_name is in /etc/systemd/system | |
| ln -sf /etc/systemd/system/$unit_name $f | |
| elif [ -f "/usr/lib/systemd/system/$unit_name" ]; then | |
| #echo $unit_name is in /usr/lib/systemd/system | |
| ln -sf /usr/lib/systemd/system/$unit_name $f | |
| fi | |
| done | |
| done | |
| # explicit fix for [email protected]. Instantiated units will not have an exact match from the symlink | |
| # to the canonical unit file, but in our case we don't make use of instantiated services aside from | |
| # the [email protected] instance | |
| ln -sf /usr/lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment