LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1135|回复: 0

Turbolinux控制台UNICON启动脚本分析

[复制链接]
发表于 2002-11-23 15:04:30 | 显示全部楼层 |阅读模式
#!/bin/sh
#
# Tue Nov 7 2000 Go Taniguchi <go@turbolinux.co.jp>
# Fri Feb 23 2001 Merlin Ma <merlin@turbolinux.com.cn>
#

function modinstall ;首先检测模块加载命令是否存在
{
    /sbin/modprobe $1
    if [ ! "$?" = "0" ]; then
        echo Install driver $1 error.
        exit 3
    fi
}

if [ ! "$DISPLAY" = "" ] ; then  ;如果是在X下运行此脚本则无效
    echo Can not run unicon under X.
    exit 1
fi
if [ ! "$UID" = "0" ] ; then  ;只有root用户才能启动Unicon
    echo Can not install unicon drivers with non root user.
    exit 2
fi

if [ ! "$LC_ALL" = "" ] ; then
    UNICONLANG=$LC_ALL
elif [ ! "$LANG" == "" ] ; then
    UNICONLANG=$LANG
elif [ -e /etc/sysconfig/i18n ] ; then  ;检测当前Locale
    if grep -q GB18030 /etc/sysconfig/i18n ; then
        UNICONLANG=GBK
    elif grep -q GBK /etc/sysconfig/i18n ; then
        UNICONLANG=GBK
    elif grep -q GB /etc/sysconfig/i18n ; then
        UNICONLANG=GB2312
    elif grep -q TW /etc/sysconfig/i18n ; then
        UNICONLANG=BIG5
    elif grep -q HK /etc/sysconfig/i18n ; then
        UNICONLANG=BIG5-HKSCS
    elif grep -q ja /etc/sysconfig/i18n ; then
        UNICONLANG=JP
    elif grep -q ko /etc/sysconfig/i18n ; then
        UNICONLANG=KR
    else
        UNICONLANG=GBK
    fi
fi

if ! grep -q '[[:alnum:]]' /proc/fb ; then  ;加载FrameBuffer模块
  modinstall vga16fb
fi
modinstall unikey  ;加载键盘映射驱动模块
loadunimap /usr/lib/unicon/direct.uni

case $UNICONLANG in
        zh_CN.GB18030|GB18030)
                modinstall encode-gbk  ;加载GBK编码字体显示模块
                unicon --gbk   ;以GBK方式启动Unicon
                ;;
        zh_CN.GB2312|GBK)
                modinstall encode-gbk
                unicon --gbk
                ;;
        zh_CN.GBK|GBK)
                modinstall encode-gbk
                unicon --gbk
                ;;
        zh_CN.GB2312|GB2312)
                modinstall encode-gb
                unicon --gb
                ;;
        zh_TW.Big5|BIG5)
                modinstall encode-big5
                unicon --big5
                ;;
        zh_HK|BIG5-HKSCS)
                modinstall encode-big5
                unicon --big5
                ;;
        ja*|JP)       
                modinstall encode-jis
                unicon --jis
                ;;
        ko*|KR)
                modinstall encode-kscm
                unicon --kscm
                ;;
        *)       
                modinstall encode-gbk
                unicon --gbk
esac

if [ -f /var/lock/subsys/gpm ] ; then ;重新启动鼠标驱动GPM
    /etc/rc.d/init.d/gpm restart 1>/dev/null 2>/dev/null
fi
exit 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表