From f6a3610f1463698d20a743ce91fb4e0985649496 Mon Sep 17 00:00:00 2001 From: Juni Kim Date: Sun, 29 Jan 2023 17:03:54 -0500 Subject: [PATCH] alpine --- Makefile | 7 ++- install_alpine.sh | 118 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 2 deletions(-) create mode 100755 install_alpine.sh diff --git a/Makefile b/Makefile index 5cbd170..1f99de2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ ubuntu: - docker run -it --rm -v $(CURDIR):/root/serverconfigs ubuntu /bin/bash + docker run -it --rm -v $(CURDIR):/root/sc ubuntu /bin/bash #docker run -it -v $(pwd):/root/serverconfigs --rm ubuntu /bin/bash fedora: - docker run -it --rm -v $(CURDIR):/root/serverconfigs fedora /bin/bash + docker run -it --rm -v $(CURDIR):/root/sc fedora /bin/bash + +alpine: + docker run -it --rm -v $(CURDIR):/root/sc alpine /bin/ash .PHONY: ubuntu fedora diff --git a/install_alpine.sh b/install_alpine.sh new file mode 100755 index 0000000..0d2ecd3 --- /dev/null +++ b/install_alpine.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +DIR="$(realpath "$(dirname "$0")")" + +root_setup() { + # script must start at home directory + cd "$HOME" || exit 1; + usertest() { + if test "$(id -u)" -ne 0; then + echo "You must run this script as root."; + exit 1; + fi + } + createuser() { + printf 'full name: ' >&2 + read -r NAME + printf 'login: ' >&2 + read -r LOGIN + adduser -g "$NAME" "$LOGIN" || exit 1 + adduser "$LOGIN" video || exit 1 + adduser "$LOGIN" input || exit 1 + adduser "$LOGIN" wheel || exit 1 + adduser root wheel || exit 1 + } + installdoas() { + apk add doas + echo "permit nopass :wheel" >> /etc/doas.d/doas.conf + } + usertest && createuser && installdoas +} + +user_setup() { + cd "$HOME" || exit 1; + + if ! (apk list | grep 'doas' 2>&1) > /dev/null; then + echo "doas is not installed."; + exit 1 + fi + + dev() { + echo "Developer tools..." + doas apk add git make python3 nodejs npm go cargo g++ gcc curl bash shadow || exit 1 + } + + + sysinfo() { + echo "Dylan Araps scripts" + cd "$HOME" || exit 1; + mkdir -p repos + git clone https://github.com/dylanaraps/pfetch "$HOME/repos/pfetch" + git clone https://github.com/dylanaraps/neofetch "$HOME/repos/neofetch" + git clone https://github.com/dylanaraps/fff "$HOME/repos/fff" + + cd "$HOME/repos/pfetch" || exit 1; + doas make install || exit 2; + cd "$HOME" || exit 1; + + cd "$HOME/repos/neofetch" || exit 1; + doas make install || exit 2; + cd "$HOME" || exit 1; + + cd "$HOME/repos/fff" || exit 1; + doas make install || exit 2; + cd "$HOME" || exit 1; + } + + dotfiles() { + echo "Adding zsh and tmux configs" + # zsh plugins + doas apk add zsh tmux shellcheck fzf + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" + # dotfiles + if ! test -d "$DIR/dots"; then + echo "$DIR/dots folder not found."; + exit 1; + fi + cp "$DIR/dots/zshrc" "$HOME/.zshrc" + cp "$DIR/dots/tmux.conf" "$HOME/.tmux.conf" + mkdir -p "$HOME/.local/bin" || exit 1 + cp -r "$DIR/scripts/." "$HOME/.local/bin/" || exit 1 + } + + neovim() { + # install neovim + doas apk add neovim tree-sitter tree-sitter-cli + git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim || exit 1 + git clone https://git.junickim.me/junikimm717/nvim2023 ~/.config/nvim || exit 1 + nvim -c PackerSync -c 'sleep 10' -c qa --headless + echo "sleeping to compile" + nvim -c 'sleep 60' -c qa --headless + } + + competitiveprogramming() { + echo "CP..." + git clone https://git.junickim.me/junikimm717/linuxcp "$HOME/cp" + go install git.junickim.me/junikimm717/cpgo@latest + } + + (dev && sysinfo && dotfiles && neovim) || exit 1 +} + +if test $# -eq 0; then + echo "at least one argument: root or user" && exit 1 +fi + +case $1 in + root|r) + root_setup + ;; + user|u) + user_setup + ;; + *) + echo "Invalid option $1" + exit 1 + ;; +esac