用户使用GDM登录后,怎么运行脚本?
Environment
-
Red Hat Enterprise Linux 3
-
Red Hat Enterprise Linux 4
- Red Hat Enterprise Linux 5
Issue
Origin:https://access.redhat.com/knowledge/solutions/3965
* 用户使用GDM登录后,怎么运行脚本?
Resolution
- 在会话开始之前和会话结束时,GDM有一系列脚本需要在登录之后运行。
在使用文本console时、像~/.bash_profile一样,/etc/X11/gdm/PreSession/Default
可以在用户登录后被运行。
-
在编辑这个文件时,确认添加行都是在“exec”命令后添加的,从而在这之后的任何东西都不会被处理:
#!/bin/sh # # Note that any setup should come before the sessreg command as # that must be 'exec'ed for the pid to be correct (sessreg uses the parent # pid) # # Note that output goes into the .xsession-errors file for easy debugging # PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin" # this is a good place to add custom command lines to be executed date > /tmp/last_X_login.txt gdmwhich () { COMMAND="$1" OUTPUT= IFS=: for dir in $PATH do if test -x "$dir/$COMMAND" ; then if test "x$OUTPUT" = "x" ; then OUTPUT="$dir/$COMMAND" fi fi done unset IFS echo "$OUTPUT" } XSETROOT=`gdmwhich xsetroot` if [ "x$XSETROOT" != "x" ] ; then # Try to snarf the BackgroundColor from the config file BACKCOLOR=`grep '^BackgroundColor' /etc/X11/gdm/gdm.conf | sed 's/^.*=\\(.*\\)$/\\1/'` if [ "x$BACKCOLOR" = "x" ]; then BACKCOLOR="#76848F" fi "$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR" fi SESSREG=`gdmwhich sessreg` if [ "x$SESSREG" != "x" ] ; then # some output for easy debugging echo "$0: Registering your session with wtmp and utmp" echo "$0: running: $SESSREG -a -w /var/log/wtmp -u /var/run/utmp -x \\"$X_SERVERS\\" -h \\"$REMOTE_HOST\\" -l \\"$DISPLAY\\" \\"$USER\\"" exec "$SESSREG" -a -w /var/log/wtmp -u /var/run/utmp -x "$X_SERVERS" -h "$REMOTE_HOST" -l "$DISPLAY" "$USER" # This section will not be read. Do not add scripts here. fi # some output for easy debugging echo "$0: could not find the sessreg utility, cannot update wtmp and utmp" exit 0
-
/etc/X11/gdm/PostSession/Default
可以被编辑从而得到像~/.bash_logout一样的一些东西。 -
虽然脚本可以以root用户运行,但是
$HOME
, `$USER以及类似的环境变量会因为用户的登录而被恰当的设定。
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments