commit 73c0a672e4a5d2c871ba98786ef38a16078f28dc Author: junikimm717 Date: Fri Jan 21 19:54:33 2022 -0500 first commit diff --git a/asroot.sh b/asroot.sh new file mode 100755 index 0000000..39af5b5 --- /dev/null +++ b/asroot.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# script must start at home directory +cd "$HOME" || exit 1; + +#DIR="$(realpath "$(dirname "$0")")" + +usertest() { + if test "$(id -u)" -ne 0; then + echo "You must run this script as root."; + exit 1; + fi +} + +createjunikim() { + # create junikim + adduser -g "Juni Kim" junikim + adduser junikim video + adduser junikim input + adduser junikim wheel +} + +installdoas() { + apk add doas + echo "permit persist :wheel" >> /etc/doas.conf +} + +usertest && createjunikim && installdoas diff --git a/asuser.sh b/asuser.sh new file mode 100755 index 0000000..74e52cb --- /dev/null +++ b/asuser.sh @@ -0,0 +1,104 @@ +#!/bin/sh + +# script must start at home directory +cd "$HOME" || exit 1; + +DIR="$(realpath "$(dirname "$0")")" + +usertest() { + if test "$(id -u)" -eq 0; then + echo "You cannot run this script as root."; + exit 1; + fi + if ! (getent passwd junikim 2>&1) > /dev/null; then + echo "User junikim must exist."; + exit 1 + fi + + if ! (apk list | grep 'doas'); then + echo "doas is not installed."; + exit 1 + fi +} + +dev() { + echo "Developer tools..." + doas apk add git make python3 nodejs npm neovim +} + +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; +} + +shell() { + echo "zsh installation and configuration as login shell" + doas apk add zsh + # set user permissions + awk -F ':' -v OFS=':' '{ +if ($1 == "junikim") { +print $1,$2,$3,$4,$5,$6,"/bin/zsh" +} else { +print $1,$2,$3,$4,$5,$6,$7 +}}' /etc/passwd > passwd.tmp + doas mv passwd.tmp /etc/passwd + # add starship and oh my zsh + doas apk add starfish +} + +# neovim must be installed. +plugins() { + # install vim-plug, oh-my-zsh, and zsh-syntax-highlighting + sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \ + "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/zsh-syntax-highlighting +} + +dotfiles() { + echo "Adding vim and zsh configs" + if ! test -d "$DIR/dotfiles"; then + echo "$DIR/dotfiles folder not found."; + exit 1; + fi + mkdir -p "$HOME/.config/nvim" + cp "$DIR/dotfiles/.zshrc" "$HOME/.zshrc" + cp "$DIR/dotfiles/init.vim" "$HOME/.config/nvim/init.vim" +} + +competitiveprogramming() { + echo "CP Compilers..." + doas apk add g++ + doas apk add clang-dev + cd "$HOME" || exit 1; + git clone https://git.junickim.me/junikimm717/linuxcp "$HOME/cp" +} + +(usertest && dev && sysinfo && shell && plugins && dotfiles) || exit 1 + +cat <