Merge branch 'install' of https://github.com/andrejusk/dotfiles
Clean scripts, remove sudo requirement Add python dependencies Correctly symlink and add poetry Update make clean Add python2 to dependencies Fix pyenv install Use pyenv to install python Update .gitignore Install git and keybase
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1 @@
|
|||||||
install/*.lock
|
*.dotlock
|
||||||
install.lock
|
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -1,7 +1,3 @@
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f install.lock install/*.lock
|
rm -f .dotlock
|
||||||
|
|
||||||
.PHONY: clear
|
|
||||||
clear:
|
|
||||||
rm -f install.lock
|
|
||||||
|
|||||||
22
README.md
22
README.md
@@ -1,15 +1,17 @@
|
|||||||
# dotfiles.andrejus.uk
|
# dotfiles.andrejus.uk
|
||||||
☁
|
|
||||||
|
Collection of tracked dotfiles and supporting install scripts.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
```
|
|
||||||
git clone https://github.com/andrejusk/dotfiles.git ~/workspace/dotfiles
|
|
||||||
sudo sh ~/workspace/dotfiles/setup.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## About
|
source <(wget https://raw.githubusercontent.com/andrejusk/dotfiles/master/bootstrap.sh)
|
||||||
* zsh
|
|
||||||
* oh-my-zsh
|
|
||||||
* spaceman
|
|
||||||
|
|
||||||
* brew
|
## Stack
|
||||||
|
|
||||||
|
Shell: 🐟 fish (+ fisher)
|
||||||
|
|
||||||
|
Devops:
|
||||||
|
* docker (+ docker-compose)
|
||||||
|
|
||||||
|
Languages:
|
||||||
|
* python (+ poetry, pyenv)
|
||||||
|
|||||||
36
bootstrap.sh
Normal file
36
bootstrap.sh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Script to set up and install dotfiles repository.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# `source path/to/bootstrap.sh`
|
||||||
|
# `source <(wget path/to/bootstrap.sh)`
|
||||||
|
#
|
||||||
|
set -euf -o pipefail
|
||||||
|
|
||||||
|
# Set up variables and imports
|
||||||
|
repository="andrejusk/dotfiles"
|
||||||
|
repository_url="https://github.com/$repository.git"
|
||||||
|
workspace_dir="$HOME/workspace"
|
||||||
|
dotfiles_dir="$workspace_dir/dotfiles"
|
||||||
|
lock_extension="dotlock"
|
||||||
|
source "${dotfiles_dir}/utils.sh"
|
||||||
|
|
||||||
|
# Ensure git is installed
|
||||||
|
if ! hash git 2>/dev/null; then
|
||||||
|
sudo apt-get update -yqq
|
||||||
|
sudo apt-get install -yqq git
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure repository is cloned
|
||||||
|
if [[ ! -d $dotfiles_dir ]]; then
|
||||||
|
mkdir -p $workspace_dir
|
||||||
|
git clone $repository_url $dotfiles_dir
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure repository is up to date
|
||||||
|
cd $dotfiles_dir
|
||||||
|
# git pull origin master
|
||||||
|
|
||||||
|
# Install dotfiles
|
||||||
|
source $dotfiles_dir/install.sh
|
||||||
12
fish/config.fish
Normal file
12
fish/config.fish
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Ensure fisher is installed
|
||||||
|
if not functions -q fisher
|
||||||
|
set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
|
||||||
|
curl https://git.io/fisher --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/fisher.fish
|
||||||
|
fish -c fisher
|
||||||
|
end
|
||||||
|
|
||||||
|
# Poetry
|
||||||
|
set -gx PATH $HOME/.poetry/bin $PATH
|
||||||
|
|
||||||
|
# Wipe greeting
|
||||||
|
set fish_greeting
|
||||||
2
fish/fishfile
Normal file
2
fish/fishfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
rafaelrinaldi/pure
|
||||||
|
jorgebucaran/fish-nvm
|
||||||
6
git/.gitconfig
Normal file
6
git/.gitconfig
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[user]
|
||||||
|
name = Andrejus
|
||||||
|
email = hi@andrejus.uk
|
||||||
|
|
||||||
|
[github]
|
||||||
|
user = andrejusk
|
||||||
0
git/.gitignore_global
Normal file
0
git/.gitignore_global
Normal file
73
install.sh
73
install.sh
@@ -1,47 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Runs all install scripts
|
# Invokes all install scripts.
|
||||||
|
#
|
||||||
|
|
||||||
# set -xv
|
# Log execution
|
||||||
set -o pipefail
|
printf "Installing ${C_CYAN}$repository${C_NC}"
|
||||||
|
printf " as ${C_YELLOW}$USER${C_NC}\n\n"
|
||||||
|
|
||||||
dir=`dirname $0`
|
# Prevent running as root
|
||||||
name=`basename $0 ".sh"`
|
if [ "$USER" == "root" ]; then
|
||||||
source $dir/utils.sh
|
printf "Failed: ${C_RED}Running as $USER${C_NC}\n"
|
||||||
printf "${C_CYAN}andrejusk/dotfiles${C_NC}\n\n"
|
printf "Please run as user, not ${C_YELLOW}sudo${C_NC}\n"
|
||||||
|
|
||||||
# Check if running
|
|
||||||
lock_file=$dir/$name.lock
|
|
||||||
if [ -f $lock_file ]; then
|
|
||||||
printf "${C_RED}Script already running${C_NC}\n"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
touch $lock_file # Requires clear
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for root
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
printf "${C_RED}Called without sudo, run:${C_NC}\n"
|
|
||||||
printf "sudo !!\n\n"
|
|
||||||
make clear
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Prevent concurrent scripts
|
||||||
|
lock_file="$dotfiles_dir/.$lock_extension"
|
||||||
|
if [ -f "$lock_file" ]; then
|
||||||
|
printf "Failed: ${C_RED}Script already running${C_NC}\n"
|
||||||
|
printf "Please wait for script to exit or ${C_YELLOW}make clean${C_NC}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
touch $lock_file # Requires clear
|
||||||
|
|
||||||
# Run all install scripts
|
# Run all install scripts
|
||||||
install_dir="$dir/install"
|
for script in "$dotfiles_dir/install/*.sh"; do
|
||||||
for script in $install_dir/*.sh;
|
|
||||||
do
|
printf "$script\n\n"
|
||||||
script_name=`basename $script ".sh"`
|
|
||||||
script_lock="$install_dir/$script_name.lock"
|
# Avoid pattern matching self
|
||||||
if [ -f $script_lock ]; then
|
[ -e "$script" ] || continue
|
||||||
printf "skipping $script_name\n"
|
|
||||||
else
|
# Log execution
|
||||||
printf "running $script_name\n"
|
script_name=$(basename "$script" ".sh")
|
||||||
touch $script_lock
|
printf "Running ${C_YELLOW}$script_name${C_NC}...\n${C_DGRAY}"
|
||||||
bash -o pipefail $script | indent
|
|
||||||
fi
|
# Run and indent output
|
||||||
|
source "$script" | indent
|
||||||
|
printf "${C_NC}\n"
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Exit
|
# Clean up and exit
|
||||||
make clear
|
printf "Done! Cleaning up...\n${C_DGRAY}"
|
||||||
|
make clean
|
||||||
|
printf "${C_NC}\n"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
3
install/00-apt-pkglist
Normal file
3
install/00-apt-pkglist
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
curl
|
||||||
|
net-tools
|
||||||
|
openssh-server
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Always updates apt, upgrades apt, and installes 00-apt-pkglist
|
||||||
|
#
|
||||||
|
|
||||||
apt-get -y update
|
# apt update and upgrade non-interactively
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -y \
|
sudo apt-get update -y
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get \
|
||||||
-o Dpkg::Options::="--force-confdef" \
|
-o Dpkg::Options::="--force-confdef" \
|
||||||
-o Dpkg::Options::="--force-confold" upgrade
|
-o Dpkg::Options::="--force-confold" upgrade -y
|
||||||
apt-get -y autoremove
|
|
||||||
apt-get -y autoclean
|
# Package installs
|
||||||
|
pkglist=$(cat $install_dir/00-apt-pkglist)
|
||||||
|
sudo apt-get install -y $pkglist
|
||||||
|
|||||||
@@ -1,6 +1,44 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. fish shell is installed
|
||||||
|
# 2. fish shell is default login shell
|
||||||
|
# 3. fish dotfiles are symlinked
|
||||||
|
#
|
||||||
|
|
||||||
apt-add-repository -y ppa:fish-shell/release-3
|
# 1. fish shell is installed
|
||||||
apt update
|
if [ ! hash fish ] 2>/dev/null; then
|
||||||
apt-get -y install fish
|
|
||||||
chsh -s `which fish`
|
printf "Installing fish...\n"
|
||||||
|
|
||||||
|
# Add fish repository
|
||||||
|
sudo apt-add-repository -y ppa:fish-shell/release-3
|
||||||
|
sudo apt-get -y update
|
||||||
|
|
||||||
|
# Install fish
|
||||||
|
sudo apt-get -y install fish
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "fish is installed\n"
|
||||||
|
|
||||||
|
# 2. fish shell is default login shell
|
||||||
|
fish_path=$(which fish)
|
||||||
|
if [ $SHELL != fish_path ]; then
|
||||||
|
|
||||||
|
printf "Setting fish as default...\n"
|
||||||
|
|
||||||
|
# Update default login shell
|
||||||
|
chsh -s $fish_path $USER
|
||||||
|
usermod -s $fish_path $USER
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "fish is default login shell\n"
|
||||||
|
|
||||||
|
# 3. fish dotfiles are symlinked
|
||||||
|
target="$HOME/.config/fish"
|
||||||
|
for file in $(ls -d $script_dir/fish/*); do
|
||||||
|
rel_path=$(realpath --relative-to="$target" "$file")
|
||||||
|
printf "Linking $file to $target as $rel_path...\n"
|
||||||
|
ln -sv $rel_path $target
|
||||||
|
done
|
||||||
|
printf "fish dotfiles linked\n"
|
||||||
|
|||||||
14
install/10-git.sh
Normal file
14
install/10-git.sh
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. git dotfiles are symlinked
|
||||||
|
#
|
||||||
|
|
||||||
|
# 1. git dotfiles are symlinked
|
||||||
|
target="$HOME"
|
||||||
|
for file in $(ls -d $script_dir/git/*); do
|
||||||
|
rel_path=$(realpath --relative-to="$target" "$file")
|
||||||
|
printf "Linking $file to $target as $rel_path...\n"
|
||||||
|
ln -sv $rel_path $target
|
||||||
|
done
|
||||||
|
printf "git dotfiles linked\n"
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
apt-get -y install \
|
|
||||||
apt-transport-https \
|
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
gnupg-agent \
|
|
||||||
software-properties-common
|
|
||||||
|
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
||||||
apt-key fingerprint 0EBFCD88
|
|
||||||
|
|
||||||
add-apt-repository -y \
|
|
||||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
|
||||||
$(lsb_release -cs) \
|
|
||||||
stable"
|
|
||||||
apt update
|
|
||||||
apt install -y docker-ce
|
|
||||||
systemctl status docker
|
|
||||||
|
|
||||||
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
|
||||||
chmod +x /usr/local/bin/docker-compose
|
|
||||||
docker-compose --version
|
|
||||||
16
install/11-keybase.sh
Normal file
16
install/11-keybase.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. keybase is installed
|
||||||
|
#
|
||||||
|
|
||||||
|
# 1.keybase is installed
|
||||||
|
if [ ! hash fish ] 2>/dev/null; then
|
||||||
|
|
||||||
|
printf "Installing keybase...\n"
|
||||||
|
|
||||||
|
curl --remote-name https://prerelease.keybase.io/keybase_amd64.deb
|
||||||
|
sudo apt install ./keybase_amd64.deb
|
||||||
|
run_keybase
|
||||||
|
|
||||||
|
fi
|
||||||
58
install/12-docker.sh
Normal file
58
install/12-docker.sh
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. docker is installed
|
||||||
|
# 2. docker-compose if installed
|
||||||
|
# 3. docker group exists
|
||||||
|
# 4. user is in docker group
|
||||||
|
#
|
||||||
|
|
||||||
|
# 1. docker is installed
|
||||||
|
if ! hash docker 2>/dev/null; then
|
||||||
|
|
||||||
|
printf "Installing docker...\n"
|
||||||
|
|
||||||
|
# Requirements
|
||||||
|
sudo apt-get -y install \
|
||||||
|
apt-transport-https \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
gnupg-agent \
|
||||||
|
software-properties-common
|
||||||
|
|
||||||
|
# Add repository
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||||
|
sudo add-apt-repository -y \
|
||||||
|
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||||
|
$(lsb_release -cs) \
|
||||||
|
stable"
|
||||||
|
sudo apt-get -y update
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "docker is installed\n"
|
||||||
|
|
||||||
|
# 2. docker-compose if installed
|
||||||
|
if ! hash docker-compose 2>/dev/null; then
|
||||||
|
|
||||||
|
printf "Installing docker-compose...\n"
|
||||||
|
|
||||||
|
# Docker-compose
|
||||||
|
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
|
||||||
|
sudo chmod +x /usr/local/bin/docker-compose
|
||||||
|
docker-compose --version
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "docker-compose is installed\n"
|
||||||
|
|
||||||
|
# 3. docker group exists
|
||||||
|
group='docker'
|
||||||
|
if ! grep -q $group /etc/group; then
|
||||||
|
sudo groupadd docker
|
||||||
|
fi
|
||||||
|
printf "group '$group' is created\n"
|
||||||
|
|
||||||
|
# 4. user is in docker group
|
||||||
|
if ! groups $USER | grep -q "\b$group\b"; then
|
||||||
|
sudo usermod -aG docker $USER
|
||||||
|
fi
|
||||||
|
printf "user '$USER' is in '$group' group\n"
|
||||||
23
install/20-pyenv.sh
Normal file
23
install/20-pyenv.sh
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. pyenv is installed
|
||||||
|
#
|
||||||
|
|
||||||
|
# 1. pyenv is installed
|
||||||
|
if ! hash pyenv 2>/dev/null; then
|
||||||
|
|
||||||
|
printf "Installing pyenv...\n"
|
||||||
|
|
||||||
|
# Install pyenv prerequisites
|
||||||
|
# see https://github.com/pyenv/pyenv/wiki/common-build-problems
|
||||||
|
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
|
||||||
|
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
|
||||||
|
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
|
||||||
|
|
||||||
|
# Install pyenv
|
||||||
|
# see https://github.com/pyenv/pyenv-installer
|
||||||
|
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "pyenv is installed\n"
|
||||||
16
install/21-python.sh
Normal file
16
install/21-python.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. python is installed
|
||||||
|
#
|
||||||
|
|
||||||
|
# 1. python is installed
|
||||||
|
if ! hash python 2>/dev/null; then
|
||||||
|
|
||||||
|
printf "Installing python...\n"
|
||||||
|
|
||||||
|
pyenv install -s 3.7.0
|
||||||
|
pyenv global 3.7.0
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "python is installed\n"
|
||||||
16
install/22-poetry.sh
Normal file
16
install/22-poetry.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# After running this script:
|
||||||
|
# 1. poetry is installed
|
||||||
|
#
|
||||||
|
|
||||||
|
# 1. poetry is installed
|
||||||
|
if ! hash poetry 2>/dev/null; then
|
||||||
|
|
||||||
|
printf "Installing poetry...\n"
|
||||||
|
|
||||||
|
# Install poetry
|
||||||
|
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
|
||||||
|
|
||||||
|
fi
|
||||||
|
printf "poetry is installed\n"
|
||||||
5
install/99-apt-clean.sh
Normal file
5
install/99-apt-clean.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
sudo apt-get -y autoremove
|
||||||
|
sudo apt-get -y autoclean
|
||||||
Reference in New Issue
Block a user