Commit e18177cb30a08495f08990e0fe47ea13e443b0f5
1 parent
b8914f261a
Exists in
master
and in
2 other branches
ADD FILE: sys_base_install.sh
Showing 1 changed file with 85 additions and 0 deletions Inline Diff
tools/sys_base_install.sh
| File was created | 1 | #!/usr/bin/env bash | |
| 2 | |||
| 3 | # ** Helper Functions ** | ||
| 4 | # ---------------------- | ||
| 5 | |||
| 6 | GJ_DEVENV="local_aptproxy" | ||
| 7 | GJ_SHELL="bash" | ||
| 8 | |||
| 9 | function set_apt_proxy { | ||
| 10 | if [ "$GJ_DEVENV" == "local_aptproxy" ]; then | ||
| 11 | echo "Setting apt-proxy: srvths" | ||
| 12 | printf 'Acquire::http { Proxy "http://192.168.188.110:3142"; };\nAcquire::https { Proxy "https://"; };\n' > /etc/apt/apt.conf.d/02proxy | ||
| 13 | elif [ "$GJ_DEVENV" == "hetzner_server" ]; then | ||
| 14 | echo "Setting apt-mirror: hetzner mirror" | ||
| 15 | echo 'deb ftp://mirror.hetzner.de/debian/packages wheezy main contrib non-free' > /etc/apt/sources.list.d/hetzner.list | ||
| 16 | echo 'deb ftp://mirror.hetzner.de/debian/security wheezy/updates main contrib non-free' >> /etc/apt/sources.list.d/hetzner.list | ||
| 17 | fi | ||
| 18 | } | ||
| 19 | |||
| 20 | function get_shell_config { | ||
| 21 | apt-get -yq install curl git nano zsh | ||
| 22 | mkdir "~/.config" | ||
| 23 | echo "cloning zsh config.." | ||
| 24 | hash git >/dev/null 2>&1 && env git clone --depth=1 http://git.str8.biz/mj/zsh-config.git $ZCNF || | ||
| 25 | } | ||
| 26 | |||
| 27 | set_apt_proxy | ||
| 28 | |||
| 29 | set -e | ||
| 30 | |||
| 31 | if [ ! -n "$ZCNF" ]; then | ||
| 32 | ZCNF=~/.config/zsh-config | ||
| 33 | fi | ||
| 34 | |||
| 35 | if [ ! -n "$ZSH" ]; then | ||
| 36 | ZSH=$ZCNF/tools/oh-my-zsh | ||
| 37 | fi | ||
| 38 | |||
| 39 | export DEBIAN_FRONTEND=noninteractive | ||
| 40 | |||
| 41 | apt-get update | ||
| 42 | |||
| 43 | if [ "$GJ_SHELL" != "zsh" ]; then | ||
| 44 | get_shell_config | ||
| 45 | src | ||
| 46 | fi | ||
| 47 | |||
| 48 | apt-get -yq upgrade && apt-get -yq dist-upgrade | ||
| 49 | apt-get -yq autoremove && apt-get -yq clean | ||
| 50 | |||
| 51 | |||
| 52 | echo "\033[0;34mLooking for an existing zsh config...\033[0m" | ||
| 53 | if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then | ||
| 54 | echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-zsh-cnf\033[0m"; | ||
| 55 | mv ~/.zshrc ~/.zshrc.pre-zsh-cnf; | ||
| 56 | fi | ||
| 57 | |||
| 58 | echo "\033[0;34mUsing the Zsh Config template file and adding it to ~/.zshrc\033[0m" | ||
| 59 | ln -s $ZCNF/templates/zshrc ~/.zshrc | ||
| 60 | ln -s $ZCNF/templates/bash_aliases ~/.bash_aliases | ||
| 61 | sed -i -e "/^export ZSH=/ c\\ | ||
| 62 | export ZSH=$ZSH | ||
| 63 | " ~/.zshrc | ||
| 64 | |||
| 65 | echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" | ||
| 66 | sed -i -e "/export PATH=/ c\\ | ||
| 67 | export PATH=\"$PATH\" | ||
| 68 | " ~/.zshrc | ||
| 69 | |||
| 70 | if [ "$SHELL" != "$(which zsh)" ]; then | ||
| 71 | echo "\033[0;34mTime to change your default shell to zsh!\033[0m" | ||
| 72 | chsh -s `which zsh` | ||
| 73 | fi | ||
| 74 | |||
| 75 | echo "\033[0;32m"' __ __ '"\033[0m" | ||
| 76 | echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" | ||
| 77 | echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" | ||
| 78 | echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" | ||
| 79 | echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" | ||
| 80 | echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" | ||
| 81 | echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" | ||
| 82 | echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" | ||
| 83 | echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m" | ||
| 84 | env zsh | ||
| 85 | . ~/.zshrc | ||
| 86 |