質問: gdmログイン画面からユーザーを非表示にする方法 最近、qmailに必要な新しいユーザーをいくつか追加しました。これで、ログイン画面のボックスに表示されて混乱し、ユーザーを見つけるためにスクロールする必要があります。これらのユーザーをログインボックスから非表示にするにはどうすればよいですか?
回答: 今週末、スクリプト(gdm-greeter)を作成しました。 centos 6.2でうまく動作しますが、ubuntuに役立つのでしょうか?#!/bin/bash # # $lastchangeddate: 2012-02-17 09:13:10 +0100 (fri, 17 feb 2012) $ # $revision: 1627 $ # # get the default exlude list defaultexclude=`sed 's,</schema>,#,' /etc/gdm/gdm.schemas | \ tr '\n#' '#\n' | \ grep '>greeter/exclude<' | tr '\n#' '#\n' | \ grep '<default>' | \ sed -e 's,.*<default>,,' -e 's,</default>.*,,'` # get the exclude list from the config eval `grep '^exclude=' /etc/gdm/custom.conf 2> /dev/null` # if empty copy the default if [ "$exclude" = "" ] then exclude=$defaultexclude fi # collect all user accounts with a shell users="`grep 'sh$' /etc/passwd | awk -f: '{print $1}' | \ sort | tr '\n' ',' | sed 's/,$//'`" #------------------------------------------------------------------------------ # the functions area placeexclude() # $1 new exclude string { # create a .bak file if [ ! -f /etc/gdm/custom.conf.bak ] then cp /etc/gdm/custom.conf /etc/gdm/custom.conf.bak fi # create a tmp file without the exclude string cat /etc/gdm/custom.conf | tr '[\n' '\n[' | \ sed -e 's/^\(greeter[]].*\)[[]exclude=[^[]*\([[].*\)/\1\2/' | \ tr '[\n' '\n[' > /tmp/custom.conf.$$ # if the tmp file is there and we have non default exclude if [ -f /tmp/custom.conf.$$ ] then if [ "$1" = "$defaultexclude" ] then cat /tmp/custom.conf.$$ > /etc/gdm/custom.conf else # place the new exclude string cat /tmp/custom.conf.$$ | tr '[\n' '\n[' | \ sed -e "s/^greeter[]][[][[]/greeter][exclude=$1[[/" | \ tr '[\n' '\n[' > /etc/gdm/custom.conf fi fi rm -f cat /tmp/custom.conf.$$ } #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # command area add() # cmd (add a user to the greeter {<user> { userfilter=`echo $users | sed 's/,/|/g'` if ! echo $1 | egrep -w $userfilter &> /dev/null then echo "error: user $1 unknown" echo return 1 fi # only work with the users not in the default exclude list filter=`echo $defaultexclude | sed 's/,/|/g'` hidden=`echo $exclude | tr ',' '\n' | egrep -vw "$filter" | tr '\n' ','` # check if we need to do something if ! echo $hidden | tr ',' '\n' | grep -w $1 &> /dev/null then echo echo "user $1 is not hidden" echo else # remove the user from the exclude placeexclude "`echo $exclude | tr ',' '\n' | grep -vw $1 | \ tr '\n' ',' | sed 's/,$//'`" # tell the action echo "user $1 added to the greeter" echo fi } del() # cmd (delete/hide a user from the greeter {<user> { userfilter=`echo $users | sed 's/,/|/g'` if ! echo $1 | egrep -w $userfilter &> /dev/null then echo "error: user $1 unknown" echo return 1 fi # check if we need to do something if echo $exclude | tr ',' '\n' | grep -w $1 &> /dev/null then echo echo "user $1 is already excluded from the greeter" echo else # exclude the user placeexclude "$1,$exclude" # tell the action echo "user $1 hidden from the greeter" echo fi } hide() # cmd (delete/hide a user from the greeter {<user> { del $1 } hidden() # cmd (list the hidden users { { filter=`echo $defaultexclude | sed 's/,/|/g'` hidden=`echo $exclude | tr ',' '\n' | egrep -vw "$filter" | tr '\n' ','` if [ ${#hidden} -eq 0 ] then echo "no hidden users" echo else echo echo "users hidden from the greeter:" echo echo $hidden | tr ',' '\n' | sed 's/^/ /' fi } users() # cmd (list the users in the greeter { { filter=`echo $exclude | sed 's/,/|/g'` greeters=`echo $users | tr ',' '\n' | egrep -vw "$filter" | tr '\n' ','` if [ ${#greeters} -eq 0 ] then echo "no users in the greeter" echo else echo echo "users in the greeter:" echo echo $greeters | tr ',' '\n' | sed 's/^/ /' fi } list() # cmd (list the users in the greeter { { users } #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # framework area help() # cmd (command help {[command] { if [ "$1" = "" ] then cmd=help else cmd=$1 fi if ! grep \^${cmd}*\(\).*#.*cmd $0 > /dev/null 2>&1 then ( echo echo "error: unknown cmd" echo ) >&2 else ( echo echo "usage: `basename $0` $cmd `grep \^${cmd}*\(\).*#.*cmd $0 | \ sed 's/.* {//g'`" echo ) >&2 fi } # # main # if [ "$1" != "" ] && grep -i $1\(\).*#.*cmd $0 > /dev/null 2>&1 then $* else echo echo "usage: `basename $0` command [parm1] [parm2] [..]" echo echo " available commands:" echo grep \^[0-9a-z_a-z]*\(\).*#.*cmd $0 | \ awk -f\( '{printf "%-16s %s\n",$1,$3}' | sed 's/ {.*//g' | sort echo fi