如何自定义 CentOS 6.* 上随 gnome 桌面启动的默认应用程序集

如何自定义 CentOS 6.* 上随 gnome 桌面启动的默认应用程序集

背景我们运行一系列 CentOS 6.5 服务器,每个服务器都承载多个用户(约 100 个)通过 X-Window XDMP 从他们的 MS Windows 桌面进入。这些用户不需要启动的默认应用程序主机,如 pulse、volume-control、vino、polkit 等。因此,我们想自定义启动的默认应用程序集。但是,我们确实例行yum 更新在这些机器上,我们不希望我们的自定义被覆盖。Yum/rpm 包含一些用于保存指定配置文件更改的规定。

问题我们可以通过 1) 删除或 2) 在 /etc/xdg/autostart/ 中的相应 .desktop 文件中插入行“Hidden=true”来自定义启动的应用程序集,但是,这些 .desktop 文件中的几个文件未在安装它们的 RPM 包中指定为配置文件(例如 gnome-media、polkit-gnome、policycoreutils、vino)。这意味着如果包更新,这些文件可能会被 yum 更新操作覆盖。

建议的解决方案 (1)强力攻击:编写一个 after-yum-update 脚本,重新执行我们所做的更改。可以手动运行该脚本,也可以自定义 yum 使其自动运行。

建议的解决方案 (2)巧妙但冒险:创建我们自己的自定义 RPM 包,安装有更改的文件。然后强制安装此 RPM。将来想要更改文件的 RPM 更新将因冲突而停止。这将中断常规 yum 更新,我们将遵循手动程序来保留/恢复自定义。

欢迎提出其他解决方案、想法和批评!谢谢。

答案1

这是我针对暴力破解方法 #1 想出的脚本:

#!/bin/bash

filelist1='at-spi-registryd.desktop
bluetooth-applet.desktop
gdu-notification-daemon.desktop
gnome-at-session.desktop
gnome-keyring-daemon.desktop
gnome-screensaver.desktop
gnome-user-share.desktop
gnome-volume-control-applet.desktop
gpk-update-icon.desktop
nm-applet.desktop
polkit-gnome-authentication-agent-1.desktop
pulseaudio.desktop
restorecond.desktop
seahorse-daemon.desktop
spice-vdagent.desktop
user-dirs-update-gtk.desktop
vino-server.desktop'

if [ ! -d /etc/xdg/autostart ]; then
    echo "The assumptions of this script are flawed. Aborting"
    echo "Directory /etc/xdg/autostart does not exist."
    exit
fi
cd /etc/xdg/autostart
mkdir -p save
for f in $filelist1;do
    if [ -f $f ]; then
       mv $f save; 
    else
       echo "/etc/xdg/autostart/$f not found";
    fi
done


if [ ! -f /usr/share/gnome/autostart/libcanberra-login-sound.desktop ]; then
    echo "The assumptions of this script are flawed. Aborting"
    echo "The file /usr/share/gnome/autostart/libcanberra-login-sound.desktop does not exist."
    exit
fi
cd /usr/share/gnome/autostart
mkdir -p save
mv libcanberra-login-sound.desktop save
if [ ! -f /usr/share/gnome/shutdown/libcanberra-logout-sound.sh ]; then
    echo "The assumptions of this script are flawed. Aborting"
    echo "The file /usr/share/gnome/shutdown/libcanberra-logout-sound.sh does not exist."
    exit
fi
cd /usr/share/gnome/shutdown
mkdir -p save
mv libcanberra-logout-sound.sh save

相关内容