You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

177 lines
4.3 KiB

#!/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
}
if test -z "$DOCKERBUILD"; then
usertest && createuser && installdoas
else
usertest && installdoas
fi
}
user_setup() {
cd "$HOME" || exit 1;
help_text() {
cat <<EOF
./install_alpine.sh user [options]
Options:
-G,--graphical install xorg and wm
-C,--cp install competitive programming scripts
EOF
}
GRAPHICAL=
CP=
while test $# -ne 0; do
case $1 in
-G|--graphical)
GRAPHICAL=1
;;
-C|--cp)
CP=1
;;
*)
echo "invalid option $1"
exit
;;
esac
shift
done
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"
doas apk add neofetch pfetch fff
}
dotfiles() {
echo "Adding zsh and tmux configs"
# zsh plugins
doas apk add zsh tmux shellcheck fzf
export RUNZSH=no
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"
# install tpm and plugins
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm || exit 1
tmux start \; \
new -d \; \
run "$HOME/.tmux/plugins/tpm/scripts/install_plugins.sh" \; \
kill-session || exit 1
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
}
vimconfigs() {
doas apk add vim
wget https://git.junickim.me/junikimm717/vim2023/raw/branch/master/lsp.vimrc -o .vimrc
}
competitiveprogramming() {
echo "CP..."
git clone https://git.junickim.me/junikimm717/linuxcp "$HOME/cp"
go install git.junickim.me/junikimm717/cpgo@latest
}
graphical() {
# xorg and drivers
doas setup-xorg-base
doas apk add xf86-video-qxl mesa-egl
doas apk add xf86-input-keyboard xf86-input-mouse xf86-input-evdev
# wm applications
doas apk add i3wm nitrogen alacritty polybar i3lock
# fonts
apk add font-jetbrains-mono-nerd font-siji
mkdir -p "$HOME/.config/polybar" || exit 1
mkdir -p "$HOME/.config/i3" || exit 1
mkdir -p "$HOME/.config/picom" || exit 1
cp "$DIR/dots/polybar.ini" "$HOME/.config/polybar/config" || exit 1
cp "$DIR/dots/i3config" "$HOME/.config/i3/config" || exit 1
cp "$DIR/dots/picom.conf" "$HOME/.config/picom/picom.conf" || exit 1
}
(dev && sysinfo && dotfiles && vimconfigs && neovim) || exit 1
if ! test -z "$CP"; then
competitiveprogramming || exit 1
fi
if ! test -z "$GRAPHICAL"; then
graphical || exit 1
fi
}
if test $# -eq 0; then
echo "at least one argument: root or user" && exit 1
fi
case $1 in
root|r)
shift
root_setup "$@"
;;
user|u)
shift
user_setup "$@"
;;
*)
echo "Invalid option $1"
exit 1
;;
esac