├── .gitignore ├── LICENSE ├── README.md ├── config ├── ubuntu_16.04.ini ├── ubuntu_18.04.ini └── ubuntu_22.04.ini └── oh-my-ubuntu.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .DS_Store 3 | *.deb 4 | omu.log 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 tracyone 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ``` 3 | 4 | _ _ _ 5 | ___ | |__ _ __ ___ _ _ _ _| |__ _ _ _ __ | |_ _ _ 6 | / _ \| '_ \ _____| '_ ` _ \| | | |_____| | | | '_ \| | | | '_ \| __| | | | 7 | | (_) | | | |_____| | | | | | |_| |_____| |_| | |_) | |_| | | | | |_| |_| | 8 | \___/|_| |_| |_| |_| |_|\__, | \__,_|_.__/ \__,_|_| |_|\__|\__,_| 9 | |___/ 10 | ``` 11 | 12 | 13 | # This is The Ubuntu Way 14 | 15 | A software-install shell script for **Ubuntu** that is: 16 | 17 | **Customizable** 18 | 19 | and 20 | 21 | **Easy to use**. 22 | 23 | 24 | Make sure your ubuntu connect to the internet then run: 25 | 26 | ```bash 27 | ./oh-my-ubuntu.sh -f ./config/ubuntu_16.04.ini 28 | ``` 29 | 30 | It will ask you whether prompt or not, if you choose `y`, then all the software will install **automatically**. 31 | 32 | If you choose `n`, then you can confirm every item before it start install. 33 | 34 | It will install all my favorite softwares specified by `.config/ubuntu_16.04.ini` 35 | 36 | You can modify `./config/ubuntu_16.04.ini` according to your actual environment. see [INI file format](#ini-file-format). 37 | 38 | # Feature 39 | 40 | 1. You can install software by apt, download deb packags from internet and build from source.**oh-my-ubuntu** will deal with every error situation property(ie. dependent packags error) 41 | 42 | 2. You can maintain source code easliy through **oh-my-ubuntu**,before install software from source code,**oh-my-ubuntu** will detect whether the directory of specified source is exist in `${SRC_DIR}`,if yes,**oh-my-ubuntu** will try to update it then install. 43 | 44 | 3. You only need to input passwd **one time** and it will never invaild until the end of **oh-my-ubuntu** process. 45 | 46 | # Usage 47 | 48 | ```bash 49 | ./oh-my-ubuntu.sh [-f ] [-a all|ppa|apt|download|build] [-h]" 50 | ``` 51 | 52 | `-f`: specified the path of ini file 53 | 54 | `-h`: Show the usage of oh-my-ubuntu 55 | 56 | `-a`: You can execute one of following function alone. 57 | 58 | 59 | 1. ppa: add ppa then update apt source 60 | 2. apt: Install packags through `apt-ght install` 61 | 3. download: Download deb file from internet then install. 62 | 3. build: build and install software from source code (Currently only support get source code from git server like github or gitlab) 63 | 64 | You can call `./oh-my-ubuntu.sh` without any argument: 65 | 66 | Default argument of `-f` option is `config/ubuntu_16.04.ini`。 67 | 68 | Default argument of `-a` option is `all`. 69 | 70 | All the source code will install to the path specified by variable `SRC_DIR` (Default is `${HOME}/Work/Source`). 71 | 72 | If the source code is aleady exist, then oh-my-ubuntu will try to update it then install. 73 | 74 | ## INI file format 75 | 76 | I use **git** to read or write standard ini file. 77 | 78 | **For example** 79 | 80 | - read :git config section.key 81 | - write :git config section.key value 82 | 83 | --- 84 | 85 | In section `repo`,add your favorite ppa: 86 | 87 | ```ini 88 | ppa = ppa:neovim-ppa/unstable 89 | ``` 90 | 91 | In section `apt`,add your favorite packags separated by space 92 | 93 | ```ini 94 | packages = virtualbox virtualbox-guest-additions-iso vde2 95 | ``` 96 | 97 | In section `download`,add the deb file download url: 98 | 99 | ```ini 100 | url = http://download.teamviewer.com/download/teamviewer_i386.deb 101 | ``` 102 | 103 | 104 | In section `build`,There are three string separated by comma that assigned to key `gitsrc`. 105 | 106 | - The url of software's in git server, 107 | - Dependence packags that can be installed by `apt-get install`. **[optional]** 108 | - Install command 109 | 110 | ```ini 111 | gitsrc=https://github.com/ggreer/the_silver_searcher.git , automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev , ./build.sh && sudo make install 112 | ``` 113 | -------------------------------------------------------------------------------- /config/ubuntu_16.04.ini: -------------------------------------------------------------------------------- 1 | [info] 2 | arch = x64 3 | [repo] 4 | ppa = ppa:git-core/ppa 5 | ppa = ppa:caffeine-developers/ppa 6 | ppa = ppa:rabbitvcs/ppa 7 | ppa = ppa:chris-lea/node.js 8 | ppa = ppa:george-edison55/nitroshare 9 | ppa = ppa:maarten-baert/simplescreenrecorder 10 | ppa = ppa:dreibh/ppa; wireshark 11 | ppa = ppa:plushuang-tw/uget-stable 12 | ppa = ppa:noobslab/macbuntu 13 | ppa = ppa:wiznote-team 14 | ppa = ppa:neovim-ppa/unstable 15 | ppa = ppa:ubuntu-elisp/ppa 16 | ppa = ppa:oranchelo/oranchelo-icon-theme 17 | ppa= ppa:atareao/telegram 18 | 19 | 20 | [apt] 21 | 22 | packages = git gitk git-gui git-svn tig python-nautilus python-configobj python-gtk2 python-glade2 python-svn python-dbus python-dulwich subversion meld rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit rabbitvcs-nautilus 23 | 24 | packages = openjdk-8-jdk 25 | 26 | packages = openssh-server automake autoconf curl wget samba 27 | 28 | packages = codeblocks g++ wx-common libwxgtk3.0-0 build-essential wxformbuilder codeblocks-dbg codeblocks-contrib wx3.0-headers wx3.0-i18n 29 | 30 | packages = eclipse eclipse-cdt 31 | 32 | packages = qt5-default qtcreator 33 | 34 | packages = gimp inkscape dia 35 | 36 | packages = caffeine openshot keepass2 simplescreenrecorder wireshark aria2 unity-tweak-tool xdotool 37 | 38 | packages = virtualbox virtualbox-guest-additions-iso vde2 39 | 40 | packages = libpurple0 pidgin chromium-browser telegram 41 | 42 | packages = goldendict goldendict-wordnet wiznote asciinema ranger 43 | 44 | packages = nautilus-actions 45 | 46 | packages = unrar p7zip-full zhcon xbacklight shutter wmctrl curl 47 | 48 | packages = gparted vlc skype dconf-editor dconf-cli 49 | 50 | packages = exfat-utils lm-sensors hddtemp 51 | 52 | packages = sl cmatrix oneko libaa-bin toilet cowsay xcowsay figlet screenfetch 53 | 54 | packages = nodejs-legacy python-software-properties 55 | 56 | ;for embedded development 57 | packages = putty openbsd-inetd tftp-hpa tftpd-hpa nfs-kernel-server minicom bison flex mtd-utils cmake 58 | 59 | packages = emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot neovim software-properties-common exuberant-ctags cscope 60 | 61 | packages = python-dev python-pip python3-dev python3-pip 62 | 63 | ;icon themes 64 | packages = macbuntu-os-icons-lts-v7 macbuntu-os-ithemes-lts-v7 oranchelo-icon-theme 65 | 66 | packages = gpac ffmpeg byzanz sox 67 | 68 | [download] 69 | 70 | url = http://pinyin.sogou.com/linux/download.php?f=linux&bit=64 71 | 72 | url = http://download.teamviewer.com/download/teamviewer_i386.deb 73 | 74 | url = http://kdl.cc.ksosoft.com/wps-community/download/6757/wps-office_10.1.0.6757_amd64.deb 75 | 76 | url = http://codown.youdao.com/cidian/linux/youdao-dict_1.1.0-0-deepin_amd64.deb 77 | 78 | url = http://s1.music.126.net/download/pc/netease-cloud-music_1.0.0_amd64_ubuntu16.04.deb 79 | 80 | url = https://bitbucket.org/rhiokim/haroopad-download/downloads/haroopad-v0.13.1-x64.deb 81 | 82 | [build] 83 | 84 | gitsrc=https://github.com/ggreer/the_silver_searcher.git , automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev , ./build.sh && sudo make install 85 | 86 | gitsrc=https://github.com/tracyone/dotfiles , , ./install.sh 87 | 88 | gitsrc=https://github.com/tracyone/program_font , , ./install.sh 89 | 90 | gitsrc=https://github.com/oblique/create_ap ,, sudo make install 91 | 92 | gitsrc=sudo pip3 install git+https://github.com/xybu/onedrived-dev.git 93 | 94 | gitsrc=https://github.com/horst3180/arc-theme, autoconf automake pkg-config libgtk-3-dev,./autogen.sh --prefix=/usr && sudo make install 95 | 96 | gitsrc=https://github.com/snwh/paper-gtk-theme,,./install-gtk-theme.sh 97 | 98 | gitsrc=https://github.com/lolilolicon/xrectsel, , ./bootstrap&&./configure --prefix /usr && make && sudo make install 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /config/ubuntu_18.04.ini: -------------------------------------------------------------------------------- 1 | [info] 2 | arch = x64 3 | [repo] 4 | ppa = ppa:git-core/ppa 5 | ppa = ppa:rabbitvcs/ppa 6 | ppa = ppa:chris-lea/node.js 7 | ppa = ppa:george-edison55/nitroshare 8 | ppa = ppa:maarten-baert/simplescreenrecorder 9 | ppa = ppa:dreibh/ppa; wireshark 10 | ppa = ppa:plushuang-tw/uget-stable 11 | ppa = ppa:wiznote-team 12 | ppa = ppa:neovim-ppa/unstable 13 | ppa = ppa:ubuntu-elisp/ppa 14 | ppa = ppa:oranchelo/oranchelo-icon-theme 15 | ppa= ppa:atareao/telegram 16 | 17 | 18 | [apt] 19 | 20 | packages = git gitk git-gui git-svn tig python-nautilus python-configobj python-gtk2 python-glade2 python-svn python-dbus python-dulwich subversion meld rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit rabbitvcs-nautilus 21 | 22 | packages = openjdk-8-jdk 23 | 24 | packages = openssh-server automake autoconf curl wget samba 25 | 26 | packages = codeblocks g++ wx-common libwxgtk3.0-0 build-essential wxformbuilder codeblocks-dbg codeblocks-contrib wx3.0-headers wx3.0-i18n 27 | 28 | packages = eclipse eclipse-cdt 29 | 30 | packages = qt5-default qtcreator 31 | 32 | packages = gimp inkscape dia 33 | 34 | packages = openshot keepass2 simplescreenrecorder wireshark aria2 gnome-tweaks xdotool 35 | 36 | packages = virtualbox virtualbox-guest-additions-iso vde2 37 | 38 | packages = libpurple0 pidgin chromium-browser telegram 39 | 40 | packages = goldendict goldendict-wordnet wiznote asciinema ranger 41 | 42 | packages = nautilus-actions 43 | 44 | packages = unrar p7zip-full zhcon xbacklight shutter wmctrl curl 45 | 46 | packages = gparted vlc skype dconf-editor dconf-cli 47 | 48 | packages = exfat-utils lm-sensors hddtemp 49 | 50 | packages = sl cmatrix oneko libaa-bin toilet cowsay xcowsay figlet screenfetch 51 | 52 | packages = nodejs-legacy python-software-properties 53 | 54 | ;for embedded development 55 | packages = putty openbsd-inetd tftp-hpa tftpd-hpa nfs-kernel-server minicom bison flex mtd-utils cmake 56 | 57 | packages = emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot neovim software-properties-common exuberant-ctags cscope 58 | 59 | packages = python-dev python-pip python3-dev python3-pip 60 | 61 | ;icon themes 62 | packages = macbuntu-os-icons-v1804 macbuntu-os-ithemes-v1804 macbuntu-os-plank-theme-v1804 63 | 64 | packages = gpac ffmpeg byzanz sox 65 | 66 | [download] 67 | 68 | url = http://pinyin.sogou.com/linux/download.php?f=linux&bit=64 69 | 70 | url = http://download.teamviewer.com/download/teamviewer_i386.deb 71 | 72 | url = http://kdl.cc.ksosoft.com/wps-community/download/6757/wps-office_10.1.0.6757_amd64.deb 73 | 74 | url = http://codown.youdao.com/cidian/linux/youdao-dict_1.1.0-0-deepin_amd64.deb 75 | 76 | url = http://s1.music.126.net/download/pc/netease-cloud-music_1.0.0_amd64_ubuntu16.04.deb 77 | 78 | url = https://bitbucket.org/rhiokim/haroopad-download/downloads/haroopad-v0.13.1-x64.deb 79 | 80 | [build] 81 | 82 | gitsrc=https://github.com/ggreer/the_silver_searcher.git , automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev , ./build.sh && sudo make install 83 | 84 | gitsrc=https://github.com/tracyone/dotfiles , , ./install.sh 85 | 86 | gitsrc=https://github.com/tracyone/program_font , , ./install.sh 87 | 88 | gitsrc=https://github.com/oblique/create_ap ,, sudo make install 89 | 90 | gitsrc=sudo pip3 install git+https://github.com/xybu/onedrived-dev.git 91 | 92 | gitsrc=https://github.com/horst3180/arc-theme, autoconf automake pkg-config libgtk-3-dev,./autogen.sh --prefix=/usr && sudo make install 93 | 94 | gitsrc=https://github.com/snwh/paper-gtk-theme,,./install-gtk-theme.sh 95 | 96 | gitsrc=https://github.com/lolilolicon/xrectsel, , ./bootstrap&&./configure --prefix /usr && make && sudo make install 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /config/ubuntu_22.04.ini: -------------------------------------------------------------------------------- 1 | [info] 2 | arch = x64 3 | [repo] 4 | ppa = ppa:neovim-ppa/unstable 5 | 6 | 7 | [apt] 8 | 9 | packages = gitk git-gui git-svn tig subversion meld 10 | 11 | packages = gimp inkscape dia 12 | 13 | packages = keepass2 simplescreenrecorder wireshark aria2 gnome-tweaks xdotool 14 | 15 | packages = virtualbox virtualbox-guest-additions-iso vde2 16 | 17 | packages = libpurple0 pidgin 18 | 19 | packages = goldendict goldendict-wordnet asciinema ranger 20 | 21 | packages = unrar p7zip-full zhcon xbacklight shutter wmctrl curl 22 | 23 | packages = gparted vlc skype dconf-editor dconf-cli 24 | 25 | packages = lm-sensors hddtemp 26 | 27 | packages = sl cmatrix oneko libaa-bin toilet cowsay xcowsay figlet screenfetch 28 | 29 | ;for embedded development 30 | packages = putty openbsd-inetd tftp-hpa tftpd-hpa nfs-kernel-server minicom bison flex mtd-utils cmake 31 | 32 | packages = neovim exuberant-ctags cscope 33 | 34 | ;for ubuntu 22.04 only 35 | packages = gnome-shell-extension-ubuntu-dock qml-module-qtquick2 libqt5quickwidgets5 libgsettings-qt1 libgsetting-qt1 libqt5quick5 libqt5qml5 36 | 37 | ;icon themes 38 | packages = macbuntu-os-icons-v1804 macbuntu-os-ithemes-v1804 macbuntu-os-plank-theme-v1804 39 | 40 | packages = gpac ffmpeg byzanz sox 41 | 42 | [download] 43 | 44 | url = https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/11719/wps-office_11.1.0.11719_amd64.deb?t=1718205236&k=f57c8fcbd03affec75a0e1580d61dd93 45 | 46 | url = https://codown.youdao.com/cidian/linux/youdao-dict_6.0.0-ubuntu-amd64.deb 47 | 48 | url = https://dldir1.qq.com/music/clntupate/linux/deb/qqmusic_1.1.5_amd64_.deb 49 | 50 | url = https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /oh-my-ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # author:tracyone,tracyone@live.cn 3 | # ./oh-my-ubuntu.sh [-f ] [-a all|ppa|apt|download|build] [-h] 4 | # Core theory:git can read or write standard ini file easily. 5 | # For example: 6 | # read :git config section.key 7 | # write :git config section.key value 8 | 9 | 10 | # variable default setting {{{ 11 | LOG_FILE="omu.log" 12 | PROMPT=1 # prompt before every install 13 | ROOT_DIR=$(pwd) #do not change 14 | ACTION="all" 15 | SRC_DIR=${HOME}/Work/Source 16 | GIT_CONFIG="./config/ubuntu_18.04.ini" 17 | # }}} 18 | 19 | # function definition {{{ 20 | 21 | # $1:software list to install.. 22 | function AptSingleInstall() 23 | { 24 | local oldifs=${IFS} 25 | IFS=" " 26 | for i in $1 27 | do 28 | sudo apt-get install $i --allow-unauthenticated -y || echo -e "apt-get install failed : $i\n" >> ${LOG_FILE} 29 | done 30 | IFS=${oldifs} 31 | } 32 | 33 | function AptInstall() 34 | { 35 | local oldifs=${IFS} 36 | IFS=" " 37 | ans="" 38 | if [[ $1 =~ ^[\ ]*$ ]]; then 39 | return 3 40 | fi 41 | if [[ PROMPT -eq 1 ]]; then 42 | read -n1 -p "Install $1 ?(y/n)" ans 43 | fi 44 | if [[ $ans =~ [Yy] || PROMPT -eq 0 ]]; then 45 | sudo apt-get install $1 --allow-unauthenticated -y || AptSingleInstall "$1" 46 | sleep 1 47 | else 48 | echo -e "\n\nAbort install\n" 49 | fi 50 | IFS=${oldifs} 51 | } 52 | 53 | # $1:section.key 54 | function AptAddRepo() 55 | { 56 | ans="" 57 | if [[ PROMPT -eq 1 ]]; then 58 | read -n1 -p "Adding ppa $i? (y/n) " ans 59 | fi 60 | if [[ $ans =~ [Yy] || PROMPT -eq 0 ]]; then 61 | sudo add-apt-repository -y $1 || echo -e "apt-add-repository failed : $1\n" >> ${LOG_FILE} 62 | sleep 1 63 | else 64 | echo -e "\n\nAbort install\n" 65 | fi 66 | } 67 | 68 | function DebInstall() 69 | { 70 | local filename="tmp$(date +%Y%m%d%H%M%S).deb" 71 | ans="" 72 | if [[ PROMPT -eq 1 ]]; then 73 | read -n1 -p "Wget $i? (y/n) " ans 74 | fi 75 | if [[ $ans =~ [Yy] || PROMPT -eq 0 ]]; then 76 | wget -c $1 -O ${filename} || echo -e "Wget $1 failed\n" >> ${LOG_FILE} 77 | sudo dpkg -i ${filename} || ( sudo apt-get -f install --fix-missing -y; sudo dpkg -i ${filename} \ 78 | || echo -e "dpkg install ${filename} form $1 failed\n" >> ${LOG_FILE} ) 79 | else 80 | echo -e "\n\nAbort install\n" 81 | fi 82 | } 83 | 84 | function BuildSrc() 85 | { 86 | IFS="," 87 | local -i count=0 88 | local proj_str="" 89 | if [[ PROMPT -eq 1 ]]; then 90 | read -n1 -p "Build source $i? (y/n) " ans 91 | fi 92 | if [[ $ans =~ [Yy] || PROMPT -eq 0 ]]; then 93 | for i in $1; do 94 | case ${count} in 95 | 0 ) 96 | IFS=${OLD_IFS} 97 | proj_dir=${SRC_DIR}/$(basename $i .git) 98 | if [[ ! -d ${proj_dir} ]]; then 99 | git clone $i ${proj_dir}/ || echo -e "git clone $i failed\n" >> ${LOG_FILE} 100 | else 101 | echo -e "\n\nUpdating $(basename $i .git)'s source code ...\n" 102 | cd ${proj_dir} 103 | git checkout -- . 104 | git pull || echo -e "Update source $(basename $i .git) failed\n" >> ${LOG_FILE} 105 | fi 106 | IFS="," 107 | ;; 108 | 1 ) 109 | AptInstall $i 110 | ;; 111 | 2 ) 112 | child_shell_execute "cd ${proj_dir} && $i" 113 | ;; 114 | *) 115 | echo -e "Wrong ini format in build section\n" >> ${LOG_FILE} 116 | ;; 117 | esac 118 | let "count+=1" 119 | done 120 | else 121 | echo -e "\n\nAbort install\n" 122 | fi 123 | cd ${ROOT_DIR} 124 | IFS=$'\x0A' 125 | } 126 | 127 | function PrintInfo() 128 | { 129 | cat << "EOF" 130 | ============================================================== 131 | ___ __ __ _ _ 132 | / _ \| \/ | | | | 133 | | | | | |\/| | | | | 134 | | |_| | | | | |_| | 135 | \___/|_| |_|\___/ 136 | 137 | Author :tracyone at live dot cn 138 | Project :https://github.com/tracyone/oh-my-ubuntu.git 139 | ============================================================== 140 | EOF 141 | } 142 | 143 | function OmuShowHelp() 144 | { 145 | PrintInfo 146 | echo -e "\n$1" 147 | echo -e "\nUsage:`basename $0` [-f ] [-a all|ppa|apt|download|build] [-h]\n" 148 | } 149 | 150 | function ProcessOptionA() 151 | { 152 | ACTION=$1 153 | case $1 in 154 | all ) 155 | ;; 156 | ppa ) 157 | ;; 158 | apt ) 159 | ;; 160 | download ) 161 | ;; 162 | build ) 163 | ;; 164 | * ) 165 | OmuShowHelp "Unsupport action $1" 166 | exit 3; 167 | ;; 168 | esac 169 | } 170 | 171 | function configure() 172 | { 173 | local package_lack="" 174 | for i in $1 175 | do 176 | which $i > /dev/null 2>&1 177 | if [[ $? -ne 0 ]]; then 178 | echo -e "\nChecking for $i ..... no\n" 179 | package_lack="$i ${package_lack}" 180 | else 181 | echo -e "\nChecking for $i ..... yes\n" 182 | fi 183 | done 184 | if [[ ${package_lack} != "" ]]; then 185 | echo -e "Before install ${package_lack},we update apt Source first ..... \n" 186 | sudo apt-get update 187 | echo -e "apt-get install ${package_lack} ..... \n" 188 | sudo apt-get install -y ${package_lack} || return 3 189 | fi 190 | return 0 191 | } 192 | 193 | function child_shell_execute() 194 | { 195 | local tmp="echo ${mypasswd} |sudo -S " 196 | bash -c "$(echo $1 | sed "s/\/${tmp}/g")" 197 | } 198 | 199 | # }}} 200 | 201 | # Script start {{{ 202 | 203 | # arg parse and env check {{{ 204 | while getopts "f:a:h" arg #选项后面的冒号表示该选项需要参数 205 | do 206 | case $arg in 207 | f ) 208 | GIT_CONFIG=${OPTARG} 209 | ;; 210 | a ) 211 | ProcessOptionA ${OPTARG} 212 | ;; 213 | h ) 214 | OmuShowHelp 215 | exit 0 216 | ;; 217 | * ) 218 | OmuShowHelp 219 | exit 1 220 | ;; 221 | esac 222 | done 223 | 224 | stty -echo 225 | shopt -s expand_aliases #enable alias in bash shell 226 | read -p "Please input $(whoami)'s passwd: " mypasswd 227 | alias sudo="echo "${mypasswd}" | sudo -S" 228 | stty echo 229 | 230 | shift $(($OPTIND-1)) 231 | if [[ ! -z $1 ]]; then 232 | OmuShowHelp "Unknown option:$1" 233 | exit 3 234 | fi 235 | 236 | if [[ ! -f ${GIT_CONFIG} ]]; then 237 | OmuShowHelp "Config file ${OPTARG} is not exist\n" 238 | exit 3 239 | fi 240 | 241 | echo -e "\nUse Config file: ${GIT_CONFIG}\n" 242 | echo -e "Action is : ${ACTION}\n" 243 | 244 | export GIT_CONFIG 245 | 246 | configure "git wget rm mkdir" || exit 3 247 | 248 | # }}} 249 | 250 | 251 | rm -f ${LOG_FILE} 252 | mkdir -p ${SRC_DIR} || exit 3 253 | 254 | # set the separator to \n 255 | OLD_IFS="$IFS" 256 | IFS=$'\x0A' 257 | 258 | 259 | read -n1 -p "Install all software Without prompting?(y/n)" ans 260 | if [[ ${ans} =~ [yY] ]]; then 261 | PROMPT=0 262 | else 263 | PROMPT=1 264 | fi 265 | 266 | if [[ ${ACTION} == "all" || ${ACTION} == "ppa" ]]; then 267 | ppa_list=$(git config --get-all repo.ppa) 268 | echo -e "\n\nadding ppa ...\n" 269 | for i in ${ppa_list}; do 270 | if [[ $i != "" ]]; then 271 | AptAddRepo $i 272 | fi 273 | done 274 | fi 275 | 276 | if [[ PROMPT -eq 1 ]]; then 277 | echo -e "\n\n" 278 | read -n1 -p "Update Source (y/n) " ans 279 | fi 280 | 281 | ARCH=$(git config --get-all info.arch) 282 | 283 | if [[ $ans =~ [Yy] || PROMPT -eq 0 ]]; then 284 | if [[ ${ARCH} == "x64" ]]; then 285 | echo -e "\n\nAdding i386 packages support ...\n" 286 | sudo dpkg --add-architecture i386 287 | fi 288 | echo -e "\n\nUpdate source ...\n" 289 | sudo apt-get update 290 | echo -e "\n\nUpgrade ...\n" 291 | sudo apt-get upgrade -y 292 | fi 293 | 294 | if [[ ${ACTION} == "all" || ${ACTION} == "apt" ]]; then 295 | echo -e "\n\nApt install ...\n" 296 | apt_list=$(git config --get-all apt.packages) 297 | for i in ${apt_list}; do 298 | if [[ $i != "" ]]; then 299 | AptInstall $i 300 | fi 301 | done 302 | fi 303 | 304 | if [[ ${ACTION} == "all" || ${ACTION} == "download" ]]; then 305 | echo -e "\n\nDeb install ...\n" 306 | deb_list=$(git config --get-all download.url) 307 | for i in ${deb_list}; do 308 | if [[ $i != "" ]]; then 309 | DebInstall $i 310 | fi 311 | done 312 | fi 313 | 314 | if [[ ${ACTION} == "all" || ${ACTION} == "build" ]]; then 315 | src_list=$(git config --get-all build.gitsrc) 316 | echo -e "\n\nInstall software from source ...\n" 317 | for i in ${src_list}; do 318 | if [[ $i != "" ]]; then 319 | BuildSrc $i 320 | fi 321 | done 322 | fi 323 | 324 | echo -e "\nAll done!!Clean ...\n" 325 | sudo apt-get autoremove -y 326 | sudo apt-get autoclean 327 | sudo apt-get clean 328 | PrintInfo 329 | 330 | # }}} 331 | 332 | # vim: set ft=sh fdm=marker foldlevel=0 foldmarker&: 333 | --------------------------------------------------------------------------------