forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overlay: 15fcos: add systemd unit to migrate to systemd-resolved
This systemd unit migrates the /etc/resolv.conf file on systems to point to ../run/systemd/resolve/stub-resolv.conf if users haven't set up a custom resolv.conf. It will only run on Fedora 33 systems and will only execute once (a single migration). Fixes: coreos/fedora-coreos-tracker#646 (cherry picked from commit 56b0ceb)
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
17 changes: 17 additions & 0 deletions
17
overlay.d/15fcos/usr/lib/systemd/system/coreos-migrate-to-systemd-resolved.service
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This unit is used to migrate existing systems running default | ||
# configurations to systemd-resolved as part of the Fedora 33 change. | ||
# https://fedoraproject.org/wiki/Changes/systemd-resolved | ||
[Unit] | ||
Description=CoreOS Migrate to Systemd Resolved | ||
Documentation=https://github.com/coreos/fedora-coreos-tracker/issues/646 | ||
# Run before NetworkManager and systemd-resolved start | ||
Before=NetworkManager.service | ||
Before=systemd-resolved.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=true | ||
ExecStart=/usr/libexec/coreos-migrate-to-systemd-resolved | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
35 changes: 35 additions & 0 deletions
35
overlay.d/15fcos/usr/libexec/coreos-migrate-to-systemd-resolved
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/bash | ||
set -euo pipefail | ||
|
||
# This script will migrate a FCOS system running the default configuration | ||
# to systemd-resolved, which is standard for Fedora 33. For non OSTree Fedora | ||
# systems the RPM post scriptlet takes care of the transition. | ||
# https://fedoraproject.org/wiki/Changes/systemd-resolved | ||
# https://github.com/coreos/fedora-coreos-tracker/issues/646 | ||
|
||
# If we're not on f33 yet then hard exit. | ||
source /usr/lib/os-release | ||
if [ "$VERSION_ID" == "32" ]; then | ||
echo 'Delaying systemd-resolved migration until Fedora 33' | ||
exit 0 | ||
fi | ||
|
||
# Here we have a bit of logic: | ||
# | ||
# - Does /etc/resolv.conf exist? | ||
# - It should since tmpfiles will create it otherwise | ||
# - If it doesn't, do nothing. | ||
# - Is /etc/resolv.conf currently being managed by NetworkManager? | ||
# - This is the default configuration in <F33. | ||
# - If yes, then create symlink to stub-resolv.conf | ||
# | ||
if [ -f /etc/resolv.conf ]; then | ||
if [ "$(head -n 1 /etc/resolv.conf)" == '# Generated by NetworkManager' ]; then | ||
echo 'Detected that NetworkManager is managing resolv.conf' | ||
echo 'Migrating to systemd-resolved for Fedora 33 change' | ||
ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf | ||
fi | ||
fi | ||
|
||
# Only run this on Fedora 33 once | ||
systemctl disable coreos-migrate-to-systemd-resolved.service |