fix: switch profile.d script to more robust technique

- Now uses `sh`-style single-bracket `[]` POSIX syntax instead of the truly old-school `test` syntax. Both are equivalent and equally portable. In fact, `man test` explains everything that `[]` can do.

- We now symlink the user's autostart file to the uBlue image's own file, and we do it in a backwards-compatible way which replaces the user's current legacy script file (if any). The previous system dumped a permanent file in the user's home-directory which never updated again after that, which meant that OS updates could never fix or improve the autostart scripts in the future. That's now possible, thanks to being a symlink.

- If the user uninstalls uBlue, or switches to a flavor without `yafti`, then the leftover "autostart" symlink will simply be a minor nuisance that only causes some soft, invisible syslog warnings about the "broken symlink", which is an improvement over the previous system which kept a full `.desktop` file that attempted to run a binary and failed to find it.
This commit is contained in:
Arcitec
2023-05-13 02:00:54 +02:00
committed by Eino Rauhala
parent ec4d01caa8
commit c4b6b47606

View File

@@ -1,6 +1,15 @@
if test "$(id -u)" -gt "0" && test -d "$HOME"; then
if test ! -e "$HOME"/.config/autostart/ublue-firstboot.desktop; then
# Only process users with home directories, but skip the "root" user.
if [ "$(id -u)" != "0" ] && [ -d "$HOME" ]; then
# Ensure target file exists and is a symlink (not a regular file or dir).
if [ ! -L "$HOME"/.config/autostart/ublue-firstboot.desktop ]; then
# Remove any leftovers or incorrect (non-link) files with the same name.
rm -rf "$HOME"/.config/autostart/ublue-firstboot.desktop
# Create symlink to uBlue's autostart runner.
# Note that "broken autostart symlinks" are harmless if they remain
# after distro switching, and just cause a minor syslog warning. The
# user can manually delete this file if they migrate away from uBlue.
mkdir -p "$HOME"/.config/autostart
cp -f /usr/etc/skel.d/.config/autostart/ublue-firstboot.desktop "$HOME"/.config/autostart
ln -s "/usr/share/ublue-os/firstboot/launcher/autostart.desktop" "$HOME"/.config/autostart/ublue-firstboot.desktop
fi
fi
fi