From 5c0637db751c03bb827f96a1c00ba14c105eb589 Mon Sep 17 00:00:00 2001 From: Andrejus Date: Sun, 23 Feb 2020 18:57:29 +0000 Subject: [PATCH] Fish and Docker install scripts --- .gitignore | 3 ++- Makefile | 7 +++++++ install.sh | 47 +++++++++++++++++++++++++++++++++++++++++++ install/00-apt.sh | 8 ++++++++ install/00-setup.sh | 1 - install/01-apt.sh | 7 ------- install/01-fish.sh | 6 ++++++ install/02-fish.sh | 16 --------------- install/10-setup.sh | 1 - install/11-docker.sh | 42 +++++++++++++++++--------------------- install/setup.sh | 38 ---------------------------------- setup.sh | 32 ----------------------------- colors.sh => utils.sh | 2 ++ 13 files changed, 91 insertions(+), 119 deletions(-) create mode 100644 Makefile create mode 100755 install.sh create mode 100644 install/00-apt.sh delete mode 100644 install/00-setup.sh delete mode 100644 install/01-apt.sh create mode 100644 install/01-fish.sh delete mode 100644 install/02-fish.sh delete mode 100644 install/10-setup.sh delete mode 100644 install/setup.sh delete mode 100755 setup.sh rename colors.sh => utils.sh (92%) diff --git a/.gitignore b/.gitignore index e1f8f8a..4aa84dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -install/.state \ No newline at end of file +install/*.lock +install.lock \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..03721d3 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: clean +clean: + rm -f install.lock install/*.lock + +.PHONY: clear +clear: + rm -f install.lock diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..82281d6 --- /dev/null +++ b/install.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Runs all install scripts + +# set -xv +set -o pipefail + +dir=`dirname $0` +name=`basename $0 ".sh"` +source $dir/utils.sh +printf "${C_CYAN}andrejusk/dotfiles${C_NC}\n\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 +fi + +# Run all install scripts +install_dir="$dir/install" +for script in $install_dir/*.sh; +do + script_name=`basename $script ".sh"` + script_lock="$install_dir/$script_name.lock" + if [ -f $script_lock ]; then + printf "skipping $script_name\n" + else + printf "running $script_name\n" + touch $script_lock + bash -o pipefail $script | indent + fi +done + +# Exit +make clear +exit 0 diff --git a/install/00-apt.sh b/install/00-apt.sh new file mode 100644 index 0000000..d6dcdac --- /dev/null +++ b/install/00-apt.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +apt-get -y update +DEBIAN_FRONTEND=noninteractive apt-get -y \ + -o Dpkg::Options::="--force-confdef" \ + -o Dpkg::Options::="--force-confold" upgrade +apt-get -y autoremove +apt-get -y autoclean diff --git a/install/00-setup.sh b/install/00-setup.sh deleted file mode 100644 index 25b9607..0000000 --- a/install/00-setup.sh +++ /dev/null @@ -1 +0,0 @@ -touch $state_dir \ No newline at end of file diff --git a/install/01-apt.sh b/install/01-apt.sh deleted file mode 100644 index 498f16a..0000000 --- a/install/01-apt.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -GREY='\033[0;37m' -NC='\033[0m' -echo "${GREY}andrejusk/dotfiles/apt${NC}" - -sudo apt-get update -sudo apt-get upgrade -y diff --git a/install/01-fish.sh b/install/01-fish.sh new file mode 100644 index 0000000..a6db4de --- /dev/null +++ b/install/01-fish.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +apt-add-repository -y ppa:fish-shell/release-3 +apt update +apt-get -y install fish +chsh -s `which fish` diff --git a/install/02-fish.sh b/install/02-fish.sh deleted file mode 100644 index 2e465cf..0000000 --- a/install/02-fish.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -GREY='\033[0;37m' -NC='\033[0m' -echo "${GREY}andrejusk/dotfiles/fish${NC}" - - -if grep -q SomeString "$File"; then - -elif - -fi - - -sudo apt-add-repository ppa:fish-shell/release-3 -sudo apt-get update -sudo apt-get install fish diff --git a/install/10-setup.sh b/install/10-setup.sh deleted file mode 100644 index 4287ca8..0000000 --- a/install/10-setup.sh +++ /dev/null @@ -1 +0,0 @@ -# \ No newline at end of file diff --git a/install/11-docker.sh b/install/11-docker.sh index a49d7ec..b382972 100644 --- a/install/11-docker.sh +++ b/install/11-docker.sh @@ -1,27 +1,23 @@ #!/bin/bash -GREY='\033[0;37m' -NC='\033[0m' -echo "${GREY}andrejusk/dotfiles/docker${NC}" -if grep -q SomeString "$File"; then - -elif - -fi - - - -sudo apt-get install \ - apt-transport-https \ - ca-certificates \ - curl \ - gnupg-agent \ - software-properties-common +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 - -sudo apt-key fingerprint 0EBFCD88 - - sudo add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" +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 diff --git a/install/setup.sh b/install/setup.sh deleted file mode 100644 index 43429a8..0000000 --- a/install/setup.sh +++ /dev/null @@ -1,38 +0,0 @@ -# # start -# export DEBIAN_FRONTEND=noninteractive - - -# # set up -# ln -s /mnt/c/git ~/git - - -# # # # shell - -# # apt -# # brew -# yes '' | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" -# echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >>~/.profile -# eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) -# sudo apt-get install build-essential -# brew install gcc - -# # zsh -# sudo apt install zsh -y -# sudo apt-get install powerline fonts-powerline -y - -# # oh my zsh -# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" - -# # highlighting -# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.zsh-syntax-highlighting" --depth 1 -# echo "source $HOME/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> "$HOME/.zshrc" - -# # spaceship -# git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" -# ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme" -# sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="spaceship"/g' ~/.zshrc - - -# # cleanup -# sudo apt autoremove -y -# export DEBIAN_FRONTEND=readline diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 1b695b1..0000000 --- a/setup.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -dir=`dirname "$0"` -source "$dir/colors.sh" -printf "${C_CYAN}andrejusk/dotfiles${C_NC}\n" - -# Check if running -lock_file="$dir/setup.lock" -if [ -f "$dir/.lock" ]; then - printf "${C_RED}Script already running${C_NC}\n" - exit 1 -elif - touch -fi - -# Check for root -if [[ $EUID -ne 0 ]]; then - printf "${C_RED}Called without sudo, please run:${C_NC}\n" - printf "sudo !!\n\n" - exit 1 -fi - -# Run all install scripts -install_dir="$dir/install" -for script in $install_dir/*.sh; -do - if [ -f "$script.lock" ]; then - printf "$script\n" - fi - printf $script - # sh $script; - -done diff --git a/colors.sh b/utils.sh similarity index 92% rename from colors.sh rename to utils.sh index 2c156a6..202085c 100644 --- a/colors.sh +++ b/utils.sh @@ -1,3 +1,5 @@ +indent() { sed 's/^/ /'; } + C_BLACK='\033[0;30m' C_DGRAY='\033[1;30m' C_RED='\033[0;31m'