Skip to content

Commit

Permalink
Update installation scripts
Browse files Browse the repository at this point in the history
- Add vim 8 repository
- Fix multiline command not working
- docker: postinstall.sh -> install.sh
- Some small fixes
  • Loading branch information
gillchristian committed Nov 26, 2018
1 parent 835a311 commit 1558ee6
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 86 deletions.
92 changes: 52 additions & 40 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash

DOTFILES_DIR="$HOME/dev/dotfiles"

Expand All @@ -11,47 +11,18 @@ function install_PACKAGES {
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886 0DF731E45CE24F27EEEB1450EFDC8610341D9410
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list

# vim 8 repository
sudo add-apt-repository -y ppa:jonathonf/vim

sudo apt-get update
echo ""

echo "Installing packages"
sudo apt-get install -y \
# general
zip \
ubuntu-restricted-extras \
unzip \
rar \
git \
vim \
vim-gnome \
zsh \
git-core \
indicator-multiload \
bison \
curl \
make \
binutils \
gcc \
build-essential \
terminator \
xclip \
silversearcher-ag \
spotify-client \
asciinema \
jq \
git-extras \
tmux \
# vim
cmake \
python3-dev \
python-dev \
exuberant-ctags \
mercurial \
libmagic-dev \
# docker
apt-transport-https \
ca-certificates \
software-properties-common
sudo apt-get install -y zip ubuntu-restricted-extras unzip rar git vim vim-gnome zsh git-core indicator-multiload
sudo apt-get install -y bison make binutils gcc build-essential terminator xclip silversearcher-ag asciinema mercurial
sudo apt-get install -y exuberant-ctags libmagic-dev apt-transport-https ca-certificates software-properties-common
sudo apt-get install -y curl jq git-extras tmux cmake python3-dev python-dev
sudo apt-get install -y --allow-unauthenticated spotify-client
echo ""
}

Expand Down Expand Up @@ -89,14 +60,18 @@ function install_GOLANG {
mkdir -p $GOPATH/src/github.com/$gitUsername
fi

mkdir -p ~/dev/go
GOPATH="$HOME/dev/go"
export GO_BIN="$GOPATH/bin:/usr/local/go/bin"

goinstall "Find Unleashed" github.com/kbrgl/fu
goinstall the_platinum_searcher github.com/monochromegane/the_platinum_searcher/...
goinstall hub github.com/github/hub
goinstall lazygit github.com/jesseduffield/lazygit
goinstall gocloc github.com/hhatto/gocloc/cmd/gocloc
goinstall gocode github.com/mdempsky/gocode

# only install td if fetching todos-data is succesful
# only install td if fetching todos-data is succesful
# since it's a private repo, so only would work for me
git clone [email protected]:gillchristian/todos-data.git ~/.todos
if [ $? -eq 0 ]; then
Expand Down Expand Up @@ -149,6 +124,41 @@ function install_ZSH {
echo ""
}

function install_DOCKER_COMPOSE {
# TODO: prompt version
echo "Installing docker-compose"
sudo touch /usr/local/bin/docker-compose
touch /tmp/docker-compose-binary
curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" > /tmp/docker-compose-binary
sudo mv /tmp/docker-compose-binary /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo ""
}

function install_DOCKER {
echo "Installing Docker"
sudo apt-get remove docker docker-engine docker.io
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "Verifying fingerprint"
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
echo "Verifying Docker installation"
sudo docker run hello-world
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl enable docker

install_DOCKER_COMPOSE

echo "After the installation restart the computer and run \`\$ docker run hello-world\`"
echo ""
}


function install_CONFIG {
install_ZSH
Expand All @@ -162,10 +172,12 @@ function install_CONFIG {
install_VIM

install_GOLANG

install_RUST

install_HASKELL

install_DOCKER
}

function main {
Expand Down
60 changes: 16 additions & 44 deletions postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ source "$DOTFILES_DIR/helpers.sh"

function install_NODE_ENV {
echo "Installing node, nvm & yarn"
nvm install 8
nvm alias default 8
nvm install 8.9.4
nvm alias default 8.9.4
curl -o- -L https://yarnpkg.com/install.sh | bash
# yarn adds itself to the $PATH when being installed
# but yarn path is already exported in ~/.zsh/exports.zsh
Expand All @@ -17,8 +17,8 @@ function install_NODE_ENV {
}

function install_VIM_PLUGINS {
# only run if npm is installed
if hash npm 2>/dev/null; then
# only run if yarn & npm are installed
if hash npm 2>/dev/null && hash yarn 2>/dev/null; then
echo "Installing vim plugins"
vim +PlugInstall +qall
# fzf adds a a call to source fzf to the ~/.zshrc, since it's already in
Expand All @@ -31,12 +31,12 @@ function install_VIM_PLUGINS {
cd ~/.vim/bundle/YouCompleteMe
./install.py --gocode-completer --tern-completer --clang-completer --rust-completer
cd ~/.vim/bundle/tern_for_vim
npm install
npm install -g typescript livedown
yarn
yarn global add typescript livedown
echo ""

echo "Installing vim-elm dependencies"
npm install -g elm elm-test elm-oracle elm-format
yarn global add elm elm-test elm-oracle elm-format
echo ""

echo "Installing nerd-fonts"
Expand All @@ -48,56 +48,28 @@ function install_VIM_PLUGINS {

# TODO: move this from here, it's not vim related
echo "Installing other programs from npm"
npm install -g tldr npm-ls-scripts
yarn global add tldr npm-ls-scripts
echo ""

echo "Installing vim-go dependencies"
vim +GoInstallBinaries +qall
echo ""
else
echo "In order to install vim packages you first need node & npm installed"
fi
}

function install_DOCKER_COMPOSE {
echo "Installing docker-compose"
sudo touch /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
touch /temp/docker-compose-binary
curl -L "https://github.com/docker/compose/releases/download/1.16.1/docker-compose-$(uname -s)-$(uname -m)" > /temp/docker-compose-binary
sudo mv /temp/docker-compose-binary /usr/local/bin/docker-compose
echo ""
}

function install_DOCKER {
echo "Installing Docker"
sudo apt-get remove docker docker-engine docker.io
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "Verifying fingerprint"
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
echo "Verifying Docker installation"
sudo docker run hello-world
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl enable docker

install_DOCKER_COMPOSE

echo "After the installation restart the computer and run \`\$ docker run hello-world\`"
echo ""
}

function main {
install_NODE_ENV
install_VIM_PLUGINS
install_DOCKER

install_VIM_PLUGINS

# after calling sed to remove something from the
# file that is symlinked the symlink gets broken
echo "Relinking ~/.zsrc"
link "$DOTFILES_DIR/zsh" ~/.zsh
echo "All done!"
echo ""
}

main
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# my dotfiles

```bash
$ sudo apt-get git
$ sudo apt-get install git
$ git clone https://github.com/gillchristian/dotfiles.git ~/dev/dotfiles
$ cd ~/dev/dotfiles
$ ./install.sh
Expand All @@ -19,7 +19,8 @@ $ ./postinstall.sh
- Test (_maybe inside a Docker container_).
- Report of what went well and what not.
- Improve output & progress.
- Unify `install.sh` and `postinstall.sh` in one script.
- Unify `install.sh` and `postinstall.sh` in one script (not not possible
because `nvm` is installing by zsh plugin when running zsh for the first time).

## Inspiration

Expand Down

0 comments on commit 1558ee6

Please sign in to comment.