wip: further cleanup

This commit is contained in:
Andrejus
2021-04-16 00:26:07 +01:00
parent 18689abd73
commit e5223a45db
48 changed files with 405 additions and 361 deletions

10
.gitignore vendored
View File

@@ -3,13 +3,13 @@
**/logs **/logs
**/*.deb **/*.deb
# custom functions # ssh env
!files/.config/fish/functions/nvm.fish **/id_rsa*
**/known_hosts*
# setup files # setup files
**/plugged **/plugged
**/autoload **/autoload
**/functions
**/completions **/completions
**/conf.d **/conf.d
**/fish_variables **/fish_variables
@@ -20,7 +20,3 @@
**/TabNine **/TabNine
**/firebase **/firebase
**/pypoetry **/pypoetry
# ssh env
**/id_rsa*
**/known_hosts*

View File

@@ -1,12 +1,12 @@
# #
# ubuntu-base: Base Ubuntu image with sudo user # debian-buster: Base Debian image with sudo user
# #
FROM ubuntu:focal AS ubuntu-base FROM debian:buster AS debian-base
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -qy update RUN apt-get -qq update
RUN apt-get -qy install --no-install-recommends \ RUN apt-get -qq install --no-install-recommends \
apt-utils software-properties-common sudo apt-utils software-properties-common sudo
# Create user with sudo priviledge # Create user with sudo priviledge
@@ -19,7 +19,7 @@ RUN echo "test-user ALL=(ALL) NOPASSWD: ALL" \
# #
# source: Source steps # source: Source steps
# #
FROM ubuntu-base AS source FROM debian-base AS source
ARG DOTFILES_DIR="/home/test-user/.dotfiles" ARG DOTFILES_DIR="/home/test-user/.dotfiles"
ADD --chown="test-user" . "$DOTFILES_DIR" ADD --chown="test-user" . "$DOTFILES_DIR"
@@ -33,7 +33,7 @@ FROM source AS install
USER test-user USER test-user
ENV USER=test-user ENV USER=test-user
ENV UUID="docker" ARG UUID="docker"
RUN ./scripts/install.sh RUN ./scripts/install.sh

View File

@@ -1,21 +0,0 @@
{
"apt_dependencies": [
"bat",
"curl",
"cowsay",
"fd-find",
"figlet",
"fortune-mod",
"git",
"gnupg2",
"jq",
"make",
"neovim",
"net-tools",
"openssh-client",
"openssh-server",
"screenfetch",
"stow",
"tmux"
]
}

View File

@@ -1,3 +1,3 @@
# Load nvm bash dependency
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -f ~/.fzf.bash ] && source ~/.fzf.bash

View File

@@ -0,0 +1,57 @@
# env:
# TERM: xterm-256color
window:
dynamic_title: true
dynamic_padding: true
decorations: None
startup_mode: Windowed
padding:
x: 7
y: 7
scrolling:
history: 10000
multiplier: 3
font:
size: 9.0
normal:
family: FiraCode Nerd Font Mono
style: Regular
bold:
family: FiraCode Nerd Font Mono
style: Bold
italic:
family: FiraSansCondensed NF
style: Italic
bold_italic:
family: FiraSansCondensed NF
style: Bold Italic
draw_bold_text_with_bright_colors: false
background_opacity: 0.95
cursor:
style: Beam
unfocused_hollow: true
live_config_reload: true
shell:
program: /usr/bin/fish
args:
- --interactive
- --login
key_bindings:
- { key: V, mods: Control|Shift, action: Paste }
- { key: C, mods: Control|Shift, action: Copy }
- { key: Insert, mods: Shift, action: PasteSelection }
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Plus, mods: Control, action: IncreaseFontSize }
- { key: Minus, mods: Control, action: DecreaseFontSize }

View File

@@ -1,5 +1,6 @@
# Only execute in interactive shell # Only execute in interactive shell
if status --is-interactive if status is-interactive
# Fish specific # Fish specific
set fish_greeting set fish_greeting
set --global hydro_symbol_prompt "\$" set --global hydro_symbol_prompt "\$"
@@ -12,4 +13,5 @@ if status --is-interactive
if begin; test -e $HOME/.profile; and type -q replay; end if begin; test -e $HOME/.profile; and type -q replay; end
replay "source $HOME/.profile" replay "source $HOME/.profile"
end end
end end

View File

@@ -0,0 +1,6 @@
# Ignore all
**/*
!.gitignore
# Keep custom functions
!nvm.fish

View File

@@ -6,30 +6,23 @@
# << >> || \\,-.// # << >> || \\,-.//
# (__) (__)(_") (_/(__) # (__) (__)(_") (_/(__)
# #
# set PATH so it includes user's private bin # set PATH so it includes user's private bin
export PATH="$HOME/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH"
mkdir -p ~/.local/bin
# xdg data & config # xdg data & config
if [ -z "$XDG_DATA_HOME" ]; then export XDG_DATA_HOME=${XDG_DATA_HOME:-"$HOME/.local/share"}
export XDG_DATA_HOME="$HOME/.local/share"
fi
mkdir -p "$XDG_DATA_HOME" mkdir -p "$XDG_DATA_HOME"
if [ -z "$XDG_CONFIG_HOME" ]; then export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"}
export XDG_CONFIG_HOME="$HOME/.config"
fi
mkdir -p "$XDG_CONFIG_HOME" mkdir -p "$XDG_CONFIG_HOME"
# workspace # workspace
if [ -z "$WORKSPACE" ]; then export WORKSPACE=${WORKSPACE:-"$HOME/workspace"}
export WORKSPACE="$HOME/workspace"
fi
mkdir -p "$WORKSPACE" mkdir -p "$WORKSPACE"
# dotfiles # dotfiles
if [ -z "$DOTFILES" ]; then export DOTFILES=${DOTFILES:-"$HOME/.dotfiles"}
export DOTFILES="$HOME/.dotfiles"
fi
# pyenv # pyenv
export PYENV_ROOT="$HOME/.pyenv" export PYENV_ROOT="$HOME/.pyenv"
@@ -43,14 +36,12 @@ export POETRY_ROOT="$HOME/.poetry"
export PATH="$POETRY_ROOT/bin:$PATH" export PATH="$POETRY_ROOT/bin:$PATH"
# nvm # nvm
if [ -z "$NVM_DIR" ]; then export NVM_DIR=${NVM_DIR:-"$HOME/.nvm"}
export NVM_DIR="$HOME/.nvm"
fi
mkdir -p "$NVM_DIR" mkdir -p "$NVM_DIR"
export PATH="$NVM_DIR/bin:$PATH" export PATH="$NVM_DIR/bin:$PATH"
# yarn # yarn
export YARN_DIR="$HOME/.yarn" export YARN_DIR=${YARN_DIR:-"$HOME/.yarn"}
mkdir -p "$YARN_DIR" mkdir -p "$YARN_DIR"
export PATH="$YARN_DIR/bin:$PATH" export PATH="$YARN_DIR/bin:$PATH"
@@ -63,9 +54,17 @@ export FZF_DEFAULT_OPTS="--reverse"
export FZF_DEFAULT_COMMAND='fdfind --type f --hidden --follow --exclude .git' export FZF_DEFAULT_COMMAND='fdfind --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_COMPLETION_TRIGGER='**' export FZF_COMPLETION_TRIGGER='**'
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
# z (jump around)
export Z_DATA_DIR=${Z_DATA:-"$XDG_DATA_HOME/z"}
export Z_DATA=${Z_DATA:-"$Z_DATA_DIR/data"}
export Z_OWNER=${Z_OWNER:-$USER}
# nix # nix
if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh; fi if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then
. $HOME/.nix-profile/etc/profile.d/nix.sh
fi
# _ _ _ ____ # _ _ _ ____
# U /"\ u |"| ___ U /"\ u / __"| u # U /"\ u |"| ___ U /"\ u / __"| u
@@ -75,10 +74,4 @@ if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile
# \\ >> // \\.-,_|___|_,-.\\ >> )( (__) # \\ >> // \\.-,_|___|_,-.\\ >> )( (__)
# (__) (__)(_")("_)\_)-' '-(_/(__) (__)(__) # (__) (__)(_")("_)\_)-' '-(_/(__) (__)(__)
# #
alias vim='nvim'
alias vi='vim'
alias bat='batcat'
alias cat='bat'
alias j="z" alias j="z"

View File

@@ -1,78 +1,67 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function apt_update { # Utility functions for common tasks
sudo apt-get update
}
# @arg $1 debian package to install if not present # @arg $1 URL to download
function apt_install { # @arg $2 Path to file
if ! dpkg -s $1; then function download_file {
sudo apt-get install -y $1 curl \
fi --silent \
} --show-error \
--location \
# ---------------------------------------------------------------------------- # --output $2 \
# Helper functions $1
# ---------------------------------------------------------------------------- #
clean() {
sudo apt-get clean
}
update() {
apt_update
}
# @arg $1 packages to install
install() {
apt_install $1
refresh
}
# @arg $1 package list file to install
install_file() {
sudo apt-get install -qqyf $(cat $1)
refresh
}
# @arg $1 repository to add
add_ppa() {
sudo add-apt-repository -y ppa:$1
}
# @arg $1 url to add
# @arg $2 keyring to add to
add_key() {
curl -fsSL $1 \
| sudo gpg --no-default-keyring --keyring $2 --import -
} }
# @arg $1 URL to run # @arg $1 URL to run
# @arg $2 binary to use # @arg $2 binary to use
run() { function download_run {
curl -fsSL $1 | $2 file=$(mktemp)
} download_file $1 $file
cat $file | $2
# Symlink contents of source folder to target
#
# @arg $1 source folder
# @arg $2 target folder
link_folder() {
mkdir -p $2
cp -srf $1/. $2
} }
# @arg $1 binary to test # @arg $1 binary to test
not_installed() { function bin_in_path {
! [ -x "$(command -v $1)" ] command -v $1
} }
# Refreshes PATH # @arg $1 apt package to test
refresh() { function apt_installed {
hash -r dpkg --status $1
} }
# Add to PATH and refresh function clean {
# @arg $1 path to add to PATH sudo apt-get clean -qq
add_path() { }
export PATH="$1:$PATH"
refresh function update {
sudo apt-get update -qq
}
# @arg $1 apt package to install if not present
function install {
if ! apt_installed $1; then
sudo apt-get install -qq $1
fi
}
# Add apt repository
# @arg $1 JSON object containing the following keys
# * repository - apt repository
# * signingKey - gpg signing key url
# * components - apt components
function add_repository {
repository=$(jq -r ".repository" <<<"$1")
if ! grep -q "^deb .*${repository}" /etc/apt/sources.list; then
signingKey=$(jq -r ".signingKey" <<<"$1")
components=$(jq -r ".components" <<<"$1")
curl -fsSL $signingKey | sudo apt-key add -
source="deb [arch=$(dpkg --print-architecture)] ${repository} ${components}"
sudo add-apt-repository --yes "$source"
fi
}
# @arg $1 package list file to install
function install_file {
sudo apt-get install -qqf $(cat $1)
} }

View File

@@ -1,7 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail set -eo pipefail
NAME=`basename "$0"` #
# Script that stows all tracked dotfiles into the user's home directory.
#
REL_DIR=`dirname "$0"` REL_DIR=`dirname "$0"`
ABS_DIR=`readlink -f $REL_DIR/../` # Scripts are nested inside of /scripts ABS_DIR=`readlink -f $REL_DIR/../` # Scripts are nested inside of /scripts

View File

@@ -0,0 +1,2 @@
bat
ripgrep

10
scripts/install.d/02-fish.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
fish --version
fisher_location="$XDG_CONFIG_HOME/fish/functions/fisher.fish"
if ! [ -f $fisher_location ]; then
fish -c "curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher"
fi
fish -c "fisher update"
fish -c "fisher --version"

View File

@@ -1,15 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if not_installed "pyenv"; then if ! bin_in_path "pyenv"; then
# see https://github.com/pyenv/pyenv/wiki/common-build-problems # see https://github.com/pyenv/pyenv/wiki/common-build-problems
pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist" pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist"
install_file "$pyenv_list_file" install_file "$pyenv_list_file"
# see https://github.com/pyenv/pyenv-installer # see https://github.com/pyenv/pyenv-installer
run "https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \ download_run "https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \
bash bash
fi fi
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)" eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)" eval "$(pyenv virtualenv-init -)"

View File

@@ -1,13 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
if not_installed "pip3"; then if ! bin_in_path "pip3"; then
pyenv install 3.9.0 pyenv install 3.9.0
pyenv global 3.9.0 pyenv global 3.9.0
refresh
fi fi
pip install --upgrade pip pip install --upgrade pip
pip3 install --upgrade pip pip3 install --upgrade pip
python3 --version python3 --version
pip3 --version pip3 --version
for dep in `jq -r ".pip_dependencies[]" $CONFIG`; do
pip3 install --upgrade $dep
done

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
poetry --version

14
scripts/install.d/13-nvm.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
nvm_version="v0.38.0"
if ! bin_in_path "nvm"; then
download_run "https://raw.githubusercontent.com/nvm-sh/nvm/${nvm_version}/install.sh" \
"bash"
fi
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm --version
nvm install node
nvm use node
node --version

7
scripts/install.d/14-yarn.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
yarn --version
for dep in `jq -r ".node_dependencies[]" $CONFIG`; do
yarn global add $dep
yarn global upgrade $dep
done

2
scripts/install.d/15-java.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
java --version

24
scripts/install.d/16-vim.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Install neovim from unstable debian repo
echo "deb http://deb.debian.org/debian unstable main" \
| sudo tee /etc/apt/sources.list.d/unstable.list
echo "Package: neovim
Pin: release a=unstable
Pin-Priority: 900" \
| sudo tee /etc/apt/preferences.d/neovim
update
install neovim
mkdir -p "$XDG_DATA_HOME/nvim/backup"
plug_dir="$XDG_DATA_HOME/nvim/site/autoload"
mkdir -p "$plug_dir"
plug_target="$plug_dir/plug.vim"
if [ ! -f $plug_target ]; then
download_file \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim \
"$plug_target"
fi
nvim --headless +UpdateRemotePlugins +PlugClean! +PlugInstall +PlugUpgrade +PlugUpdate +qall
nvim --version

11
scripts/install.d/30-docker.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
docker --version
readonly docker_group="docker"
if ! grep -q "$docker_group" /etc/group; then
sudo groupadd "$docker_group"
fi
if ! groups "$USER" | grep -q "\b$docker_group\b"; then
sudo usermod -aG docker "$USER"
fi

2
scripts/install.d/31-gcloud.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
gcloud --version

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
firebase --version

2
scripts/install.d/33-aws.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
aws --version

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
terraform --version

View File

@@ -1,18 +1,26 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail set -eo pipefail
TIME=${TIME:-`date`} #
UUID=${UUID:-`uuidgen`} # Script that installs system dependencies specified in a config,
HOST=${HOST:-`hostname`} # and runs all post-install scripts contained in a subdirectory.
#
NAME=`basename "$0"` TIME=${TIME:-$(date)}
REL_DIR=`dirname "$0"` UUID=${UUID:-$(uuidgen)}
ABS_DIR=`readlink -f $REL_DIR/../` # Scripts are nested inside of /scripts HOST=${HOST:-$(hostname)}
LOG_DIR="$ABS_DIR/logs" NAME=$(basename "$0")
mkdir -p $LOG_DIR REL_DIR=$(dirname "$0")
LOG_TARGET=${LOG_TARGET:-$LOG_DIR/$UUID.log} ABS_DIR=$(readlink -f $REL_DIR/../) # Scripts are nested inside of /scripts
UTILS="${REL_DIR}/_utils.sh"
CONFIG="${REL_DIR}/install_config.json"
INSTALL_DIR="${REL_DIR}/install.d"
LOG_DIR="${ABS_DIR}/logs"
mkdir -p "$LOG_DIR"
LOG_TARGET=${LOG_TARGET:-"${LOG_DIR}/${UUID}.log"}
main() { main() {
echo "Running $NAME at $TIME" echo "Running $NAME at $TIME"
@@ -24,31 +32,38 @@ main() {
exit 1 exit 1
fi fi
echo "Loading utils" # Load installer dependencies
source $REL_DIR/_utils.sh source "$UTILS"
update
apt_update install jq
for dep in $(jq -r ".apt_core_dependencies[]" "$CONFIG"); do
echo "Installing jq..." install "$dep"
apt_install jq
echo "Installing apt dependencies..."
for dep in `jq -r ".apt_dependencies[]" $ABS_DIR/config.json`; do
apt_install $dep
done done
figlet -c "bootstrapping..." # Add apt repositories
$ABS_DIR/scripts/bootstrap.sh for i in $(jq ".apt_repositories | keys | .[]" "$CONFIG"); do
source $HOME/.profile value=$(jq -r ".apt_repositories[$i]" "$CONFIG")
add_repository "$value"
done
update
figlet -c "installing..." # Install apt dependencies
export INSTALL_DIR="$REL_DIR/install" for dep in $(jq -r ".apt_dependencies[]" "$CONFIG"); do
install "$dep"
done
# Install dotfiles on system and load them
figlet -c "Bootstrapping..."
$ABS_DIR/scripts/bootstrap.sh
source "$HOME/.profile"
# Run custom installer scripts
figlet -c "Installing..."
for script in $INSTALL_DIR/*.sh; do for script in $INSTALL_DIR/*.sh; do
figlet -c `basename $script` figlet -c "$(basename $script)"
source $script source $script
done done
} }
echo "main: Logging to $LOG_TARGET" echo "main: Logging to $LOG_TARGET"
main 2>&1 |tee $LOG_TARGET main 2>&1 | tee "$LOG_TARGET"

View File

@@ -1,4 +0,0 @@
apt-transport-https
software-properties-common
ripgrep
universal-ctags

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
if not_installed "fish"; then
add_ppa "fish-shell/release-3"
update
install fish
fi
fish --version
fisher_location="$HOME/.config/fish/functions/fisher.fish"
if ! [ -f "$fisher_location" ]; then
curl https://git.io/fisher --create-dirs -sLo "$fisher_location"
fish -c "fisher install jorgebucaran/fisher"
fi
fish -c "fisher --version"

View File

@@ -1,10 +0,0 @@
#!/usr/bin/env bash
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
add_path "$HOME/.local/bin"
if not_installed "poetry"; then
pip3 install --user poetry
fi
pip3 install --upgrade poetry
poetry --version

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env bash
run "https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh" \
"bash"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm --version
nvm install node
nvm use node
node --version

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
if not_installed "yarn"; then
add_key https://dl.yarnpkg.com/debian/pubkey.gpg
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
update
sudo apt install --no-install-recommends yarn
fi
yarn --version

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env bash
if not_installed "java"; then
install default-jre
fi
java --version

View File

@@ -1,18 +0,0 @@
#!/usr/bin/env bash
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
mkdir -p "$XDG_DATA_HOME/nvim/backup"
plug_target="$XDG_DATA_HOME/nvim/site/autoload/plug.vim"
if [ ! -f $plug_target ]; then
echo "Downloading vim-plug to $plug_target";
curl -fLo "$plug_target" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
echo "Installing neovim support";
pip3 install --user neovim pynvim 'python-language-server[all]'
nvm use default
npm install -g neovim
echo "Running PlugInstall";
nvim --headless +UpdateRemotePlugins +PlugClean! +PlugInstall +PlugUpgrade +PlugUpdate +qall
nvim --version

View File

@@ -1,43 +0,0 @@
#!/usr/bin/env bash
DOCKER_FOLDER="$HOME/.docker"
if not_installed "docker"; then
mkdir -p "$DOCKER_FOLDER"
# Requirements
install apt-transport-https ca-certificates curl gnupg-agent \
software-properties-common
# Add repository
distro=$(lsb_release -si | tr "[:upper:]" "[:lower:]") # cast to lowercase
add_key "https://download.docker.com/linux/$distro/gpg" \
"gnupg-ring:/etc/apt/trusted.gpg.d/docker-apt-key.gpg"
sudo add-apt-repository -y \
"deb [arch=amd64] https://download.docker.com/linux/$distro \
$(lsb_release -cs) \
stable"
update
# Install
install docker-ce
# Chown
sudo chown "$USER":"$USER" "$DOCKER_FOLDER" -R
sudo chmod g+rwx "$DOCKER_FOLDER" -R
fi
docker --version
if not_installed "docker-compose"; then
pip3 install --user docker-compose
fi
pip3 install --upgrade docker-compose
docker-compose --version
readonly docker_group="docker"
if ! grep -q "$docker_group" /etc/group; then
sudo groupadd "$docker_group"
fi
if ! groups "$USER" | grep -q "\b$docker_group\b"; then
sudo usermod -aG docker "$USER"
fi

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
if not_installed "gcloud"; then
echo "Installing gcloud..."
# Add the Cloud SDK distribution URI as a package source
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" \
| sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
update
install google-cloud-sdk
refresh
fi
gcloud --version

View File

@@ -1,8 +0,0 @@
#!/usr/bin/env bash
if not_installed "firebase"; then
run "https://firebase.tools" "bash"
fi
echo "firebase is installed, upgrading..."
curl -sL firebase.tools | upgrade=true bash
firebase --version

View File

@@ -1,14 +0,0 @@
#!/usr/bin/env bash
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
temp_dir=$(mktemp -d)
unzip awscliv2.zip -d "$temp_dir"
rm awscliv2.zip
if not_installed "aws"; then
echo "Installing awscli..."
sudo $temp_dir/aws/install
fi
echo "awscli is installed, upgrading..."
sudo $temp_dir/aws/install --update
aws --version

View File

@@ -1,29 +0,0 @@
#!/usr/bin/env bash
tf_version="0.14.6"
if not_installed "terraform"; then
echo "Installing terraform..."
tf_archive="terraform_${tf_version}_linux_amd64.zip"
wget "https://releases.hashicorp.com/terraform/${tf_version}/${tf_archive}"
unzip "$tf_archive" -d "$dotfiles_dir/tmp"
rm "$tf_archive"
mkdir -p ~/.local/bin
mv "$dotfiles_dir/tmp/terraform" ~/.local/bin
rm "$dotfiles_dir/tmp/terraform"
fi
echo "terraform is installed"
terraform --version
tf_lsp_version="0.13.0"
if not_installed "terraform-ls"; then
echo "Installing terraform-ls..."
tf_lsp_archive="terraform-ls_${tf_lsp_version}_linux_amd64.zip"
wget "https://releases.hashicorp.com/terraform-ls/${tf_lsp_version}/${tf_lsp_archive}"
unzip "${tf_lsp_archive}" -d "$dotfiles_dir/tmp"
rm "${tf_lsp_archive}"
mkdir -p ~/.local/bin
mv "$dotfiles_dir/tmp/terraform-ls" ~/.local/bin
rm "$dotfiles_dir/tmp/terraform-ls"
fi
echo "terraform-lsp is installed"

View File

@@ -0,0 +1,80 @@
{
"apt_repositories": [
{
"signingKey": "https://apt.releases.hashicorp.com/gpg",
"repository": "https://apt.releases.hashicorp.com",
"components": "buster main"
},
{
"signingKey": "https://dl.yarnpkg.com/debian/pubkey.gpg",
"repository": "https://dl.yarnpkg.com/debian",
"components": "stable main"
},
{
"signingKey": "https://packages.cloud.google.com/apt/doc/apt-key.gpg",
"repository": "https://packages.cloud.google.com/apt",
"components": "cloud-sdk main"
},
{
"signingKey": "https://packages.cloud.google.com/apt/doc/apt-key.gpg",
"repository": "https://apt.kubernetes.io/",
"components": "kubernetes-xenial main"
},
{
"signingKey": "https://download.docker.com/linux/debian/gpg",
"repository": "https://download.docker.com/linux/debian",
"components": "buster stable"
},
{
"signingKey": "https://download.opensuse.org/repositories/shells:fish/Debian_10/Release.key",
"repository": "https://download.opensuse.org/repositories/shells:/fish/Debian_10/",
"components": "/"
}
],
"apt_core_dependencies": [
"curl",
"gnupg",
"gnupg2"
],
"apt_dependencies": [
"apt-transport-https",
"ca-certificates",
"containerd.io",
"cowsay",
"default-jre",
"devscripts",
"docker-ce",
"docker-ce-cli",
"fd-find",
"figlet",
"fish",
"fortune-mod",
"google-cloud-sdk",
"git",
"kubectl",
"lsb-release",
"make",
"net-tools",
"openssh-client",
"openssh-server",
"screenfetch",
"stow",
"terraform",
"terraform-ls",
"tmux",
"unzip",
"yarn"
],
"node_dependencies": [
"firebase-tools",
"neovim"
],
"pip_dependencies": [
"awscli",
"docker-compose",
"neovim",
"poetry",
"python-language-server[all]",
"pyvim"
]
}

View File

@@ -1,4 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail set -eo pipefail
#
# Script that publishes the set up script for new installations.
#
echo "Publishing..." echo "Publishing..."

13
scripts/run.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
tag=$(uuidgen)
docker build . \
--build-arg UUID=$tag \
--tag dotfiles:$tag \
--target install
docker run \
-v "$(pwd)"/logs:/home/test-user/.dotfiles/logs \
dotfiles:$tag
/bin/bash

View File

@@ -1,29 +1,34 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail set -eo pipefail
# GitHub repository details #
AUTHOR=${AUTHOR:-andrejusk} # Script that checks out a compatible dotfiles repository
REPOSITORY=${REPOSITORY:-dotfiles} # and runs the installer to set up a new installation.
BRANCH=${BRANCH:-master} #
echo "Using repository $AUTHOR/$REPOSITORY at $BRANCH"
# Target folder to checkout to author=${GITHUB_AUTHOR:-andrejusk}
DOTFILES_DIR=${DOTFILES_DIR:-$HOME/.dotfiles} repository=${GITHUB_REPOSITORY:-dotfiles}
mkdir -p $DOTFILES_DIR branch=${GITHUB_BRANCH:-master}
if [ -z `ls -A $DOTFILES_DIR` ]; then echo "Using repository $author/$repository at $branch"
echo "Setting up $DOTFILES_DIR"
setup_dir=${DOTFILES_DIR:-$HOME/.dotfiles}
# Prevent overwriting existing installation
mkdir -p $setup_dir
if [ -z `ls -A $setup_dir` ]; then
echo "Setting up $setup_dir"
else else
echo "Failed: Setup directory not empty $DOTFILES_DIR" echo "Failed: Setup directory not empty $setup_dir"
exit 1 exit 1
fi fi
# Download and untar repo # Download and untar repo
tmp_dir=`mktemp -d` tmp_dir=`mktemp -d`
tmp_dest="$tmp_dir/dotfiles.tar.gz" tmp_dest="$tmp_dir/dotfiles.tar.gz"
wget "https://github.com/$AUTHOR/$REPOSITORY/archive/$BRANCH.tar.gz" -qO $tmp_dest wget "https://github.com/$author/$repository/archive/$branch.tar.gz" -qO $tmp_dest
tar -C $tmp_dir -zxf $tmp_dest tar -C $tmp_dir -zxf $tmp_dest
mv $tmp_dir/$REPOSITORY-$BRANCH/* $DOTFILES_DIR mv $tmp_dir/$repository-$branch/* $setup_dir
rm -rf $tmp_dir rm -rf $tmp_dir
echo "Done!" echo "Done!"
$DOTFILES_DIR/scripts/install.sh $setup_dir/scripts/install.sh

View File

@@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
tag=`uuidgen` tag=$(uuidgen)
docker build . \ docker build . \
-t dotfiles:$tag \ --build-arg UUID=$tag \
--tag dotfiles:$tag \
--target test --target test
docker run dotfiles:$tag docker run \
-v "$(pwd)"/logs:/home/test-user/.dotfiles/logs \
dotfiles:$tag

3
tests/run.sh Normal file → Executable file
View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
poetry install bash -l -c "poetry install && poetry run pytest"
poetry run pytest