Update script version and configure LightDM

Updated script version to 4.8 and added LightDM configuration for boot. Cleaned up help messages and ensured proper handling of display managers.
This commit is contained in:
LINUXexpert.org
2026-01-26 12:02:34 -07:00
committed by GitHub
parent f6b3a1f33f
commit 53569075a2
+62 -52
View File
@@ -20,7 +20,7 @@ set -euo pipefail
# ========================= # =========================
# Version # Version
# ========================= # =========================
SCRIPT_VERSION="4.7" SCRIPT_VERSION="4.8"
# ========================= # =========================
# Globals / Defaults # Globals / Defaults
@@ -115,10 +115,6 @@ Options:
--with-recommends Allow recommended packages (default: off) --with-recommends Allow recommended packages (default: off)
--yes Non-interactive / auto-confirm --yes Non-interactive / auto-confirm
--i-accept-the-risk Required for convert --i-accept-the-risk Required for convert
Notes:
- "plan" uses a temporary APT environment and does NOT modify your system's APT sources.
- "convert" modifies /etc/apt and installs Mint desktop/tooling packages on top of Ubuntu.
EOF EOF
} }
@@ -493,6 +489,45 @@ session_name_for_edition() {
esac esac
} }
ensure_lightdm_on_boot() {
# Make LightDM the default display manager and ensure graphical boot.
if [[ ! -d /run/systemd/system ]]; then
warn "systemd not detected; cannot enable LightDM on boot in this environment."
return 0
fi
info "Ensuring LightDM starts on boot (graphical.target + default display manager)..."
# Unmask LightDM in case something previously masked it
systemctl unmask lightdm >/dev/null 2>&1 || true
# Ensure the default DM marker is LightDM
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager || true
# Debian/Ubuntu DM selection often uses update-alternatives
if have_cmd update-alternatives; then
update-alternatives --set x-display-manager /usr/sbin/lightdm >/dev/null 2>&1 || true
fi
# Ensure graphical boot target
systemctl set-default graphical.target >/dev/null 2>&1 || true
systemctl enable graphical.target >/dev/null 2>&1 || true
# Enable LightDM for boot
systemctl enable lightdm >/dev/null 2>&1 || true
# Prevent GDM from stealing the greeter
if systemctl list-unit-files | awk '{print $1}' | grep -qx 'gdm3.service'; then
systemctl disable --now gdm3 >/dev/null 2>&1 || true
systemctl mask gdm3 >/dev/null 2>&1 || true
fi
# Restart the active DM if we can
systemctl restart lightdm >/dev/null 2>&1 || true
ok "LightDM configured to start on boot."
}
ensure_lightdm_defaults() { ensure_lightdm_defaults() {
local sess local sess
sess="$(session_name_for_edition)" sess="$(session_name_for_edition)"
@@ -501,11 +536,11 @@ ensure_lightdm_defaults() {
DEBIAN_FRONTEND=noninteractive apt-get install -y lightdm slick-greeter DEBIAN_FRONTEND=noninteractive apt-get install -y lightdm slick-greeter
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager || true # Keep Ubuntu's gdm3 installed (if present) but ensure it can't win.
if systemctl is-enabled gdm3 >/dev/null 2>&1; then if systemctl is-enabled gdm3 >/dev/null 2>&1; then
warn "Disabling gdm3 (keeping installed)." warn "Disabling gdm3 (keeping installed)."
systemctl disable --now gdm3 || true systemctl disable --now gdm3 || true
systemctl mask gdm3 || true
if [[ -f /etc/gdm3/custom.conf ]]; then if [[ -f /etc/gdm3/custom.conf ]]; then
sed -i 's/^[#[:space:]]*WaylandEnable=.*/WaylandEnable=false/' /etc/gdm3/custom.conf || true sed -i 's/^[#[:space:]]*WaylandEnable=.*/WaylandEnable=false/' /etc/gdm3/custom.conf || true
grep -q '^WaylandEnable=' /etc/gdm3/custom.conf || echo 'WaylandEnable=false' >> /etc/gdm3/custom.conf grep -q '^WaylandEnable=' /etc/gdm3/custom.conf || echo 'WaylandEnable=false' >> /etc/gdm3/custom.conf
@@ -530,6 +565,7 @@ greeter-session=slick-greeter
user-session=${sess} user-session=${sess}
EOF EOF
# Set default session for users
for homedir in /home/*; do for homedir in /home/*; do
[[ -d "$homedir" ]] || continue [[ -d "$homedir" ]] || continue
local user local user
@@ -560,10 +596,10 @@ EOF
chmod 644 "$dmrc" || true chmod 644 "$dmrc" || true
done done
systemctl enable lightdm || true # This is the baked-in boot behavior you asked for:
systemctl restart lightdm || true ensure_lightdm_on_boot
ok "LightDM configured; default session set to ${sess}." ok "LightDM defaults applied; default session set to ${sess}."
} }
# ========================= # =========================
@@ -602,24 +638,11 @@ post_install_sanity() {
echo "FAIL" echo "FAIL"
fi fi
echo echo
echo "APT sources (Mint):" echo "LightDM boot settings:"
grep -R --line-number -E '^[[:space:]]*deb .*packages\.linuxmint\.com' /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null || true echo "default-display-manager: $(cat /etc/X11/default-display-manager 2>/dev/null || echo MISSING)"
echo echo "lightdm enabled: $(systemctl is-enabled lightdm 2>/dev/null || echo unknown)"
echo "LightDM default-display-manager:" echo "gdm3 enabled: $(systemctl is-enabled gdm3 2>/dev/null || echo not-installed)"
cat /etc/X11/default-display-manager 2>/dev/null || true echo "default target: $(systemctl get-default 2>/dev/null || echo unknown)"
echo
echo "Xsession has_option sanity:"
if [[ -f /etc/X11/Xsession.d/20x11-common_process-args ]]; then
echo "OK: 20x11-common_process-args exists"
else
echo "MISSING: /etc/X11/Xsession.d/20x11-common_process-args"
fi
echo
echo "Session entries:"
ls -1 /usr/share/xsessions 2>/dev/null | egrep 'cinnamon|mate|xfce|ubuntu|gnome' || true
echo
echo "Broken packages:"
dpkg -C || true
echo echo
} > "$out_file" } > "$out_file"
@@ -824,10 +847,9 @@ convert() {
} }
# ========================= # =========================
# NEW: Parse args in any order # Parse args in any order
# ========================= # =========================
parse_args_any_order() { parse_args_any_order() {
# Allows: script [options] <command> [options] [rollback_dir]
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
doctor|plan|convert|rollback) doctor|plan|convert|rollback)
@@ -837,34 +859,22 @@ parse_args_any_order() {
CMD="$1" CMD="$1"
shift 1 shift 1
if [[ "$CMD" == "rollback" ]]; then if [[ "$CMD" == "rollback" ]]; then
# First non-option token after rollback is the dir
if [[ $# -gt 0 && "${1:-}" != --* ]]; then if [[ $# -gt 0 && "${1:-}" != --* ]]; then
ROLLBACK_DIR="$1" ROLLBACK_DIR="$1"
shift 1 shift 1
fi fi
fi fi
;; ;;
--edition) --edition) EDITION="${2:-}"; shift 2;;
EDITION="${2:-}"; shift 2;; --target) TARGET_MINT="${2:-}"; shift 2;;
--target) --mint-mirror) MINT_MIRROR="${2:-}"; shift 2;;
TARGET_MINT="${2:-}"; shift 2;; --keep-ppas) KEEP_PPAS="yes"; shift 1;;
--mint-mirror) --preserve-snap) PRESERVE_SNAP="yes"; shift 1;;
MINT_MIRROR="${2:-}"; shift 2;; --with-recommends) WITH_RECOMMENDS="yes"; shift 1;;
--keep-ppas) --yes) ASSUME_YES="yes"; shift 1;;
KEEP_PPAS="yes"; shift 1;; --i-accept-the-risk) I_ACCEPT_RISK="yes"; shift 1;;
--preserve-snap) -h|--help|help) usage; exit 0;;
PRESERVE_SNAP="yes"; shift 1;; *) die "Unknown argument: $1" ;;
--with-recommends)
WITH_RECOMMENDS="yes"; shift 1;;
--yes)
ASSUME_YES="yes"; shift 1;;
--i-accept-the-risk)
I_ACCEPT_RISK="yes"; shift 1;;
-h|--help|help)
usage; exit 0;;
*)
die "Unknown argument: $1"
;;
esac esac
done done
} }