zoukankan      html  css  js  c++  java
  • [Linux] Auto init environment after reinstall Ubuntu system for me **backup**

    #!/bin/bash
    # for Ubuntu12.10 64bit
    ## 1.change mount, /etc/fstab
    cat << EOF > $HOME/fstab_padding.txt
    # EXT4
    #Entry "Source" for /dev/sda6 :
    UUID="0988bb9d-02ad-4290-9f60-7954605a8115"    /media/scue/Source     ext4    defaults    0    0  
    # NTFS
    #Entry "Study" for /dev/sda5 :
    UUID="20C5750E61E16D51"        /media/scue/Study    ntfs-3g    defaults,locale=zh_CN.UTF-8,gid=1000,uid=1000,umask=002    0    0
    #Entry "Enjoy" for /dev/sda7 :
    UUID="0E5E668D4576BBEE"        /media/scue/Enjoy    ntfs-3g    defaults,locale=zh_CN.UTF-8,gid=1000,uid=1000,umask=002    0    0
    #Entry "Storage" for /dev/sda9 :
    # UUID="4B8660A12AC75B45"     /media/scue/Storage    ntfs-3g     defaults,locale=zh_CN.UTF-8    0    0
    EOF
    fstab_ok=$(cat /etc/fstab | grep Study)
    if [[ $fstab_ok ]];then
        echo " 1. fstab is write ok!"
    else
        sudo cat $HOME/fstab_padding.txt | sudo tee -a /etc/fstab &> /dev/null
    fi
    
    ## 2.mount the devices
    if [[ ! -d /media/scue/Study ]];then
        sudo mkdir -p /media/scue/Study
        sudo mkdir -p /media/scue/Source
        sudo mkdir -p /media/scue/Enjoy
        sudo mount UUID="20C5750E61E16D51"    
        sudo mount UUID="0E5E668D4576BBEE"
        sudo mount UUID="0988bb9d-02ad-4290-9f60-7954605a8115"
    else
        echo " 2. mount devices is ok!"
    fi
    
    ## 3.change the archives diretory
    if [[ ! -e /var/cache/apt/archives/__ln_ok__ ]];then
        sudo rm -rf /var/cache/apt/archives/
        sudo ln -s /media/scue/Enjoy/LinuxAppsBak/UbuntuAppsBak_amd64/ /var/cache/apt/archives
    else
        echo " 3. set archivces is ok!"
    fi
    
    ## 4.update source
    read -p ">> 4. please connect to internel for update source.[Y/n]" update
    if [[ $update != "n" ]];then
        sudo apt-get update
    else
        echo " 4. source update completed!"
    fi
    
    ## 5.install software for yourself
    # for daily usage
    read -p ">> 5.1 install some software for daily?[Y/n]" install
    if [[ $install != "n" ]];then
        sudo apt-get install -y vim-gnome gconf-editor gnome-tweak-tool fcitx fcitx-table-wubi 
        sudo dpkg -i /media/scue/Enjoy/Downloads/UbuntuApps/google-chrome-stable_current_i386\(20.0.1132.47-r144678\).deb
        sudo apt-get install -f -y
        echo " 5.1 install daily softwares ok!"
    else
        echo " 5.1 install daily softwares had been installed!"
    fi
    
    # for compile cm environment
    read -p ">> 5.2 install some softwares for compile CM?[Y/n]" install
    if [[ $install != "n" ]];then
        sudo apt-get install -y git-core gnupg flex bison python rar original-awk gawk p7zip-full gperf libsdl1.2-dev libesd0-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool libc6-dev x11proto-core-dev libx11-dev libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils g++-multilib lib32z1-dev ia32-libs lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib g++-multilib
        echo " 5.2 compile CM environment softwares ok!"
    else
        echo " 5.2 compile CM environment softwares had been installed!"
    fi
    
    # for VirtualBox 
    read -p ">> 5.3 install vbox & config it?[Y/n]" install
    if [[ $install != "n" ]];then
        sudo dpkg -i /media/scue/Enjoy/Downloads/UbuntuApps/virtualbox-4.2_4.2.6-82870~Ubuntu~quantal_amd64.deb
        sudo apt-get install -f -y
        sudo apt-get install dkms
        sudo apt-get install linux-headers-3.5.0-17-generic
        sudo gpasswd vboxusers -a $USER
        sudo /etc/init.d/vboxdrv setup
        echo " 5.3 vbox config is ok!"
    else
        echo " 5.3 vbox had been configed!"
    fi
    
    # for java environment
    jdk_dir=/media/scue/Enjoy/Downloads/UbuntuApps/jdk1.6.0_34/
    if [[ ! -d /usr/lib/jvm/jdk1.6.0 ]]; then
        sudo mkdir -p /usr/lib/jvm
        sudo cp -avf $jdk_dir /usr/lib/jvm/jdk1.6.0
    #cat << EOF >> $HOME/.profile
    #export JAVA_HOME=/usr/lib/jvm/jdk1.6.0
    #export PATH=\$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH 
    #export CLASSPATH=\$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    #EOF
        echo " 5.4 java run environment config is ok!"
    else
        echo " 5.4 java run environment had been cofiged!"
    fi
    
    ## 6. setting profile for scue
    # 6.1 icons on right
    gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
    echo " 6.1 icons config is ok!"
    
    # 6.2 vim config backup
    vim_bak_dir=/media/scue/Source/Ubuntu_backup
    if [[ ! -d $HOME/.vim ]];then
        cp -avf $vim_bak_dir/.vim/ $HOME/.vim
        cp -avf $vim_bak_dir/.vimrc $HOME/.vimrc
        cp -avf $vim_bak_dir/.gvimrc $HOME/.gvimrc
        echo " 6.2 vim config is ok!"
    else
        echo " 6.2 vim config had been configed!"
    fi
    
    # 6.3 .bashrc config
    bashrc_ok=$(cat $HOME/.bashrc | grep Android)
    if [[ $bashrc_ok ]];then
        echo " 6.3 .bashrc had been configed!"
    else
        cat $HOME/bashrc_padding.txt | tee -a $HOME/.bashrc &> /dev/null
        echo " 6.3 .bashrc config is ok!"
    fi
    
    # 7. remove what I don't need
    sudo apt-get remove thunderbird ubuntuone* -y --purge &> /dev/null
    ------------
    微博:http://weibo.com/scue
    Github:http://github.com/scue
  • 相关阅读:
    微信开发-如何自定义页面分享元素
    nginx实现日志按天切割
    JS兼容IE浏览器的方法
    mysql 索引过长1071-max key length is 767 byte
    playframework1.x的eclipse插件开源-playtools
    开放平台-web实现人人网第三方登录
    开放平台-web实现QQ第三方登录
    bash shell执行方式
    pushd和popd
    What do cryptic Github comments mean?
  • 原文地址:https://www.cnblogs.com/scue/p/2860496.html
Copyright © 2011-2022 走看看