ubuntu下常用工具安装

ubuntu下常用工具安装

Tags: Ubuntu

摘要

ubuntu下常用工具安装

安装常用命令

maven
git
vim
htop
lrzsz
jnettop
sysv-rc-conf

wget -O init.sh https://coding.net/u/javacore/p/dev-env-shell/git/raw/master/init.sh && bash init.sh

maven是下载apache-maven-3.3.9-bin.tar.gz进行安装的
因为apt-get install maven会更改jdk为jdk7.

解决vim中文不乱码

添加系统语言中文,否则安装一些中文字体时无效.

完整脚本

#!/bin/bash

# install  git maven sysv-rc-conf
apt-get update

if [ "/usr/lib/jvm/jdk1.8.0_112" != "$JAVA_HOME" ] || [ ! -f "/usr/lib/jvm/jdk1.8.0_112/bin/java" ];then
wget -O install-jdk8.sh https://coding.net/u/javacore/p/dev-env-shell/git/raw/master/ubuntu-1404-64-install-jdk8.sh && bash install-jdk8.sh
fi

if [ ! -d "/tmp/" ]; then
mkdir  "/tmp"
fi

MAVEN_FILE="/tmp/apache-maven-3.3.9-bin.tar.gz"
MAVEN_NAME="apache-maven-3.3.9"
MAVEN_dir=/usr/lib/maven
MAVEN_HOME=$MAVEN_dir/$MAVEN_NAME

if [ ! -f $MAVEN_FILE ];then
wget -P "/tmp" "http://files.javablog.net/linux-soft/apache-maven-3.3.9-bin.tar.gz"
else
echo "$MAVEN_FILE is exist";
fi

rm -rf $MAVEN_dir
mkdir -p $MAVEN_dir
tar zxvf $MAVEN_FILE -C $MAVEN_dir

##写入MAVEN_HOME,追加PATH
[ -z "`grep ^'export MAVEN_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export MAVEN_HOME=$MAVEN_HOME" >> /etc/profile || sed -i "s@^export PATH=@export MAVEN_HOME=$MAVEN_HOME\nexport PATH=@" /etc/profile; } || sed -i "s@^export MAVEN_HOME=.*@export MAVEN_HOME=$MAVEN_HOME@" /etc/profile
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$MAVEN_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$MAVEN_HOME/bin:\1@" /etc/profile
[ -z "`grep ^'export PATH=' /etc/profile | grep '$MAVEN_HOME/bin'`" ] && echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> /etc/profile


echo "/usr/lib/maven/apache-maven-3.3.9 install over"


apt-get  install -y git
apt-get  install -y vim
apt-get  install -y htop
apt-get  install -y lrzsz
apt-get  install -y jnettop
apt-get  install -y sysv-rc-conf


#优化vim  /etc/vim/vimrc ,不存在就追加,否则就替换
[ -z "`grep ^'set fileencodings' /etc/vim/vimrc`" ] && echo  "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc || sed -i "s@^set fileencodings=.*@set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936@" /etc/vim/vimrc 
[ -z "`grep ^'set termencoding' /etc/vim/vimrc`" ] && echo  "set termencoding=utf-8" >> /etc/vim/vimrc || sed -i "s@^set termencoding=.*@set termencoding=utf-8@" /etc/vim/vimrc 
[ -z "`grep ^'set encoding' /etc/vim/vimrc`" ] && echo  "set encoding=utf-8" >> /etc/vim/vimrc || sed -i "s@^set encoding=.*@set encoding=utf-8@" /etc/vim/vimrc 
[ -z "`grep ^'set number' /etc/vim/vimrc`" ] && echo  "set number" >> /etc/vim/vimrc 


#set cn
apt-get install -y language-pack-zh-hant language-pack-zh-hans
echo PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\" > /etc/environment 
echo LANG=\"zh_CN.UTF-8\" >> /etc/environment 
echo LANGUAGE=\"zh_CN:zh:en_US:en\" >> /etc/environment 

dpkg-reconfigure locales

echo  "install  git,maven,vim,htop,lrzsz,jnettop,sysv-rc-conf over ";
echo  "at last, you should reboot your vps !"
echo  "then set UTF-8 in xshell !"  

#立即生效
 . /etc/profile