mirror of
https://github.com/LukeHagar/omarchy.git
synced 2025-12-06 04:20:23 +00:00
Create migration to symlink systemd-resolved (#2313)
* Backup file if modified since system birth * Symlink /etc/resolv.conf -> systemd-resolve's stub resolver
This commit is contained in:
21
migrations/1759355846.sh
Normal file
21
migrations/1759355846.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
echo "Symlink systemd-resolved to /etc/resolv.conf"
|
||||
|
||||
# Backup if /etc/resolv.conf was modified after system birth
|
||||
system_birth=$(stat -c %W /)
|
||||
resolvconf_modified=$(stat -c %Y /etc/resolv.conf)
|
||||
|
||||
# Run a backup if resolv.conf isn't a symlink and was modified after install
|
||||
if [[ -s /etc/resolv.conf ]] && [[ ! -L /etc/resolv.conf ]] && [[ $resolvconf_modified > $system_birth ]]; then
|
||||
# Backup the destination file (with timestamp) to avoid clobbering (Ex: resolv.conf.bak.1753817951)
|
||||
backup_file="/etc/resolv.conf.bak.$(date +%s)"
|
||||
|
||||
# Create backup
|
||||
sudo cp -f /etc/resolv.conf "$backup_file" 2>/dev/null
|
||||
|
||||
# Inform users
|
||||
echo -e "\e[31mReplaced /etc/resolv.conf with symlink to systemd-resolved. \nSaved backup as ${backup_file}.\e[0m"
|
||||
echo -e "\e[31mSee https://wiki.archlinux.org/title/Systemd-resolved.\e[0m"
|
||||
fi
|
||||
|
||||
# Write the symlink
|
||||
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
||||
Reference in New Issue
Block a user