桌面图标:
[Desktop Entry]
Name = Ubuntu 中文自动配置
Comment = 调整输入法、字体、解码器等
Exec = x-terminal-emulator -e sh -c 'wget -O- http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script | bash ; read E'
Icon = gnome-system
Terminal = false
MultipleArgs = false
Type = Application
Categories = Application ; System ;
GenericName = 自动配置中文相关
具体执行脚本:
#
!
/
bin
/
bash
# ubuntu-cn autosetup
# 自动配置 Ubuntu 中文支持
# jhuangjiahua ( at ) gmail . com
#############################
# 将放在 http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script
# 可以 wget -O- http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script | bash ; read E
# 或在 . desktop 里执行 x-terminal-emulator -e sh -c 'wget -O- http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script | bash ; read E'
##########################
# 附上示例 ubuntu-cn-autosetup . desktop
E = "
[Desktop Entry]
Name=Ubuntu 中文自动配置
Comment=调整输入法、字体、解码器等
Exec=x-terminal-emulator -e sh -c 'wget -O- http://www.hiweed.com/files/tip/ubuntu-cn-autosetup.script | bash ; read E'
Icon=gnome-system
Terminal=false
Type=Application
Categories=Application;System;
GenericName=自动配置中文相关
"
##########################
echo ' # 这个脚本会设置一些基本的 Ubuntu-cn 环境'
###################
MSG () {
echo " 信息: $@ "
zenity --info --text " $@ "
}
DIE () {
echo " 错误: $@ "
zenity --info --text " $@ "
exit 1
}
grep Ubuntu / etc / lsb-release || DIE " 只支持 Ubuntu "
#####################
## 修改源 ######################################################################
echo ' # 添加 Ubuntu-cn 源,在 / etc / apt / sources . list . d / ubuntu-cn . list'
DIST =$( grep DISTRIB_CODENAME / etc / lsb-release | cut -d = -f2 )
[ -z " $DIST " ] && DIE '探测 Ubuntu 版本失败'
echo " deb http://archive.ubuntu.org.cn/ubuntu-cn $DIST main universe multiverse restricted " | sudo tee / etc / apt / sources . list . d / ubuntu-cn . list
echo ' # 增加 cn99 的 universe 部分,在 / etc / apt / sources . list . d / cn99-universe . list'
echo " deb http://ubuntu.cn99.com/ubuntu/ $DIST multiverse universe " | sudo tee / etc / apt / sources . list . d / cn99-universe . list
echo ' # 更新软件仓库'
sudo apt-get update
## 安装中文包 ######################################################################
echo ' # 安装中文相关'
set -x
# 解码器,播放器 , 字幕,输入法,字体
sudo apt-get -y --force-yes install w32codecs totem-xine libxine1-gnome libxine-extracodecs xine-fonts-cn mozilla-mplayer fcitx scim-pinyin im-switch scim-qtimm ttf-arphic-uming
# GST 的解码器
sudo apt-get -y --force-yes install gstreamer0 . 10 -plugins-bad gstreamer0 . 10 -plugins-ugly gstreamer0 . 10 -ffmpeg
# chm 查看器
sudo apt-get -y --force-yes install chmsee
# cyclone qq
sudo apt-get -y --force-yes install cyclone
# ntfs-3g
sudo apt-get -y --force-yes install ntfs-3g
sudo apt-get -y --force-yes install ntfs-config
## 修复依赖
sudo apt-get -f install
set + x
## 中文设置 ###########################################################################
echo ' # 设置中文相关'
set -v
# GST 中文标签
grep -q GST_ID3_TAG_ENCODING / etc / X11 / Xsession . d / 85setenv || echo 'export GST_ID3_TAG_ENCODING = GBK' | sudo tee -a / etc / X11 / Xsession . d / 85setenv
# LC_CTYPE
grep -q LC_CTYPE / etc / environment || echo 'LC_CTYPE = " zh_CN.UTF-8 " ' | sudo tee -a / etc / environment
# 字体区域
sudo fontconfig-voodoo -f zh_CN
# 全局输入法
sudo im-switch -z all_ALL -s scim
# 中文 locales
grep zh_CN . UTF- 8 / var / lib / locales / supported . d / zh || echo 'zh_CN . UTF- 8 UTF- 8 ' | sudo tee -a / var / lib / locales / supported . d / zh
locale -a | grep zh_CN || locale-gen
# 改善 wine 程序速度
sudo sed -i -e ' / GBK /,/ ^} / d' / usr / share / X11 / locale / zh_CN . UTF- 8 / XLC_LOCALE
# mplayer 字幕设置
mkdir -p ~ /. mplayer
[ -e / usr / share / fonts / truetype / arphic / uming . ttf ] && ln -sf / usr / share / fonts / truetype / arphic / uming . ttf ~ /. mplayer / subfont . ttf
# OOo 字体替换
sudo mkdir -p / usr / lib / openoffice / share / fonts / truetype
[ -e / usr / share / fonts / truetype / arphic / uming . ttf ] && sudo ln -sf / usr / share / fonts / truetype / arphic / uming . ttf / usr / lib / openoffice / share / fonts / truetype /
# ntfs-3g
[ -x / usr / bin / ntfs-3g ] && sudo ln -sf / usr / bin / ntfs-3g / sbin / mount . ntfs
gksudo ntfs-config &
set + v
## 其他设置 ###################################################################
##################################################
##
# echo ' # 优化内核参数'
# set -x
# if ( ! grep " elevator=cfq " / boot / grub / menu . lst > / dev / null 2 > & 1 ); then
# echo " Kernel process scheduler changed to CFQ "
# sudo sed -ie ' /# defoptions / s / splash / splash elevator = cfq / ' / boot / grub / menu . lst
# sudo update-grub
# else
# echo " Kernel process scheduler is already CFQ "
# fi
# set + x
##
echo ' # 禁用 ipv6 , 优化网络速度'
set -v
grep -q " net-pf-10 off " / etc / modprobe . d / aliases || echo " alias net-pf-10 off " | sudo tee -a / etc / modprobe . d / aliases
grep -q " ipv6 off " / etc / modprobe . d / aliases || echo " alias ipv6 off " | sudo tee -a / etc / modprobe . d / aliases
set + v
##
echo ' # 优化 Gnome 速度'
set -x
gconftool- 2 -- set -- type boolean / desktop / gnome / interface / enable_animations false
gconftool- 2 -- set -- type boolean / apps / panel / global / enable_animations false
gconftool- 2 -- set -- type string / apps / nautilus / preferences / preview_sound never
set + x
##
echo ' # 优化 Ext3 分区'
for volume in $( mount 2 > / dev / null| grep ext3 | awk '{ print $ 1 }' ); do
# echo " Enabled dir_index ext3 option for $volume "
echo " # 在 $volume 打开 ext3 的 dir_index 选项 "
echo sudo tune2fs -O dir_index " $volume "
sudo tune2fs -O dir_index " $volume "
done
##
echo ' # 优化启动服务'
# for service in hplip ppp festival bluez-utils mdadm apmd brltty lvm evms pppd-dns waitnfs . sh ; do
for service in ppp festival bluez-utils mdadm apmd brltty lvm evms pppd-dns waitnfs . sh ; do
[ -x / etc / init . d /$ service ] || continue
echo " # 禁用 $service 服务 "
sudo / etc / init . d /$ service stop
sudo update-rc . d -f $ service remove
done
##
# echo 'sudo 不要密码'
# set -x
# sudo sed -ie ' / ^%admin / s / ALL $/ NOPASSWD: ALL / ' / etc / sudoers
# sudo sed -ie ' / NOPASSWD / s / NOPASSWD: // ' / etc / sudoers
# set + x
echo ' ###################################################### '
echo ' # 完成'
echo ' # 按回车确定' ; read E
# ubuntu-cn autosetup
# 自动配置 Ubuntu 中文支持
# jhuangjiahua ( at ) gmail . com
#############################
# 将放在 http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script
# 可以 wget -O- http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script | bash ; read E
# 或在 . desktop 里执行 x-terminal-emulator -e sh -c 'wget -O- http: // www . hiweed . com / files / tip / ubuntu-cn-autosetup . script | bash ; read E'
##########################
# 附上示例 ubuntu-cn-autosetup . desktop
E = "
[Desktop Entry]
Name=Ubuntu 中文自动配置
Comment=调整输入法、字体、解码器等
Exec=x-terminal-emulator -e sh -c 'wget -O- http://www.hiweed.com/files/tip/ubuntu-cn-autosetup.script | bash ; read E'
Icon=gnome-system
Terminal=false
Type=Application
Categories=Application;System;
GenericName=自动配置中文相关
"
##########################
echo ' # 这个脚本会设置一些基本的 Ubuntu-cn 环境'
###################
MSG () {
echo " 信息: $@ "
zenity --info --text " $@ "
}
DIE () {
echo " 错误: $@ "
zenity --info --text " $@ "
exit 1
}
grep Ubuntu / etc / lsb-release || DIE " 只支持 Ubuntu "
#####################
## 修改源 ######################################################################
echo ' # 添加 Ubuntu-cn 源,在 / etc / apt / sources . list . d / ubuntu-cn . list'
DIST =$( grep DISTRIB_CODENAME / etc / lsb-release | cut -d = -f2 )
[ -z " $DIST " ] && DIE '探测 Ubuntu 版本失败'
echo " deb http://archive.ubuntu.org.cn/ubuntu-cn $DIST main universe multiverse restricted " | sudo tee / etc / apt / sources . list . d / ubuntu-cn . list
echo ' # 增加 cn99 的 universe 部分,在 / etc / apt / sources . list . d / cn99-universe . list'
echo " deb http://ubuntu.cn99.com/ubuntu/ $DIST multiverse universe " | sudo tee / etc / apt / sources . list . d / cn99-universe . list
echo ' # 更新软件仓库'
sudo apt-get update
## 安装中文包 ######################################################################
echo ' # 安装中文相关'
set -x
# 解码器,播放器 , 字幕,输入法,字体
sudo apt-get -y --force-yes install w32codecs totem-xine libxine1-gnome libxine-extracodecs xine-fonts-cn mozilla-mplayer fcitx scim-pinyin im-switch scim-qtimm ttf-arphic-uming
# GST 的解码器
sudo apt-get -y --force-yes install gstreamer0 . 10 -plugins-bad gstreamer0 . 10 -plugins-ugly gstreamer0 . 10 -ffmpeg
# chm 查看器
sudo apt-get -y --force-yes install chmsee
# cyclone qq
sudo apt-get -y --force-yes install cyclone
# ntfs-3g
sudo apt-get -y --force-yes install ntfs-3g
sudo apt-get -y --force-yes install ntfs-config
## 修复依赖
sudo apt-get -f install
set + x
## 中文设置 ###########################################################################
echo ' # 设置中文相关'
set -v
# GST 中文标签
grep -q GST_ID3_TAG_ENCODING / etc / X11 / Xsession . d / 85setenv || echo 'export GST_ID3_TAG_ENCODING = GBK' | sudo tee -a / etc / X11 / Xsession . d / 85setenv
# LC_CTYPE
grep -q LC_CTYPE / etc / environment || echo 'LC_CTYPE = " zh_CN.UTF-8 " ' | sudo tee -a / etc / environment
# 字体区域
sudo fontconfig-voodoo -f zh_CN
# 全局输入法
sudo im-switch -z all_ALL -s scim
# 中文 locales
grep zh_CN . UTF- 8 / var / lib / locales / supported . d / zh || echo 'zh_CN . UTF- 8 UTF- 8 ' | sudo tee -a / var / lib / locales / supported . d / zh
locale -a | grep zh_CN || locale-gen
# 改善 wine 程序速度
sudo sed -i -e ' / GBK /,/ ^} / d' / usr / share / X11 / locale / zh_CN . UTF- 8 / XLC_LOCALE
# mplayer 字幕设置
mkdir -p ~ /. mplayer
[ -e / usr / share / fonts / truetype / arphic / uming . ttf ] && ln -sf / usr / share / fonts / truetype / arphic / uming . ttf ~ /. mplayer / subfont . ttf
# OOo 字体替换
sudo mkdir -p / usr / lib / openoffice / share / fonts / truetype
[ -e / usr / share / fonts / truetype / arphic / uming . ttf ] && sudo ln -sf / usr / share / fonts / truetype / arphic / uming . ttf / usr / lib / openoffice / share / fonts / truetype /
# ntfs-3g
[ -x / usr / bin / ntfs-3g ] && sudo ln -sf / usr / bin / ntfs-3g / sbin / mount . ntfs
gksudo ntfs-config &
set + v
## 其他设置 ###################################################################
##################################################
##
# echo ' # 优化内核参数'
# set -x
# if ( ! grep " elevator=cfq " / boot / grub / menu . lst > / dev / null 2 > & 1 ); then
# echo " Kernel process scheduler changed to CFQ "
# sudo sed -ie ' /# defoptions / s / splash / splash elevator = cfq / ' / boot / grub / menu . lst
# sudo update-grub
# else
# echo " Kernel process scheduler is already CFQ "
# fi
# set + x
##
echo ' # 禁用 ipv6 , 优化网络速度'
set -v
grep -q " net-pf-10 off " / etc / modprobe . d / aliases || echo " alias net-pf-10 off " | sudo tee -a / etc / modprobe . d / aliases
grep -q " ipv6 off " / etc / modprobe . d / aliases || echo " alias ipv6 off " | sudo tee -a / etc / modprobe . d / aliases
set + v
##
echo ' # 优化 Gnome 速度'
set -x
gconftool- 2 -- set -- type boolean / desktop / gnome / interface / enable_animations false
gconftool- 2 -- set -- type boolean / apps / panel / global / enable_animations false
gconftool- 2 -- set -- type string / apps / nautilus / preferences / preview_sound never
set + x
##
echo ' # 优化 Ext3 分区'
for volume in $( mount 2 > / dev / null| grep ext3 | awk '{ print $ 1 }' ); do
# echo " Enabled dir_index ext3 option for $volume "
echo " # 在 $volume 打开 ext3 的 dir_index 选项 "
echo sudo tune2fs -O dir_index " $volume "
sudo tune2fs -O dir_index " $volume "
done
##
echo ' # 优化启动服务'
# for service in hplip ppp festival bluez-utils mdadm apmd brltty lvm evms pppd-dns waitnfs . sh ; do
for service in ppp festival bluez-utils mdadm apmd brltty lvm evms pppd-dns waitnfs . sh ; do
[ -x / etc / init . d /$ service ] || continue
echo " # 禁用 $service 服务 "
sudo / etc / init . d /$ service stop
sudo update-rc . d -f $ service remove
done
##
# echo 'sudo 不要密码'
# set -x
# sudo sed -ie ' / ^%admin / s / ALL $/ NOPASSWD: ALL / ' / etc / sudoers
# sudo sed -ie ' / NOPASSWD / s / NOPASSWD: // ' / etc / sudoers
# set + x
echo ' ###################################################### '
echo ' # 完成'
echo ' # 按回车确定' ; read E