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.
241 lines
6.5 KiB
241 lines
6.5 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 alpine-conf
|
|
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:
|
|
|
|
-F,--nfs install aliases for connecting to nases
|
|
-G,--graphical install xorg and wm
|
|
-N,--nvim install neovim
|
|
-C,--cp install competitive programming scripts
|
|
EOF
|
|
}
|
|
|
|
GRAPHICAL=
|
|
CP=
|
|
NVIM=
|
|
NFS=
|
|
while test $# -ne 0; do
|
|
case $1 in
|
|
-G|--graphical)
|
|
GRAPHICAL=1
|
|
;;
|
|
-C|--cp)
|
|
CP=1
|
|
;;
|
|
-N|--nvim)
|
|
NVIM=1
|
|
;;
|
|
-F|--nfs)
|
|
NFS=1
|
|
;;
|
|
*)
|
|
echo "invalid option $1"
|
|
help_text
|
|
exit
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if ! (apk list | grep 'doas' 2>&1) > /dev/null; then
|
|
echo "doas is not installed.";
|
|
exit 1
|
|
fi
|
|
|
|
dev() {
|
|
echo "Developer tools..."
|
|
doas sed -i "s|#http|http|g" /etc/apk/repositories
|
|
doas apk update
|
|
doas apk add build-base python3 nodejs npm go curl bash shadow git || exit 1
|
|
if ! test -z "$NVIM"; then
|
|
doas apk add cargo
|
|
fi
|
|
}
|
|
|
|
|
|
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 zsh-vcs 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
|
|
}
|
|
|
|
nfs() {
|
|
doas apk add nfs-utils samba cifs-utils
|
|
mkdir -p "$HOME/nfs/rpi" && mkdir -p "$HOME/nfs/d2"
|
|
echo 'export WORKSPACES=$HOME/nfs/d2/ohsg11/s2:$HOME/nfs/rpi/ohsg11/s2:$WORKSPACES' >> ~/.zshrc
|
|
echo "alias schoolmount='doas mount 192.168.1.34:/srv/nfs ~/nfs/rpi'" >> ~/.zshrc
|
|
cat <<EOF >> ~/.zshrc
|
|
alias d2mount='doas mount.cifs -o username=junikim,uid=\$(id -u),gid=\$(id -g) //157.245.86.196/d2nas ~/nfs/d2'
|
|
EOF
|
|
}
|
|
|
|
graphical() {
|
|
# xorg and drivers
|
|
doas setup-xorg-base
|
|
doas apk add xf86-video-qxl xf86-video-vmware virtualbox-guest-additions-x11 mesa-egl xrandr
|
|
doas apk add xf86-input-evdev
|
|
|
|
# wm applications
|
|
doas apk add i3wm alacritty polybar i3lock rofi feh picom firefox
|
|
|
|
# misc
|
|
doas apk add xsel
|
|
|
|
# fonts
|
|
doas apk add font-jetbrains-mono-nerd terminus-font ttf-inconsolata ttf-dejavu font-noto font-noto-cjk ttf-font-awesome font-noto-extra
|
|
|
|
mkdir -p "$HOME/.local/share/fonts" || exit 1
|
|
wget https://github.com/fauno/siji/raw/master/ttf/siji.ttf -O "$HOME/.local/share/fonts/siji.ttf" || exit 1
|
|
fc-cache -rv
|
|
|
|
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
|
|
sed -i "s/brave-browser/firefox/" "$HOME/.config/i3/config"
|
|
cp "$DIR/dots/picom.conf" "$HOME/.config/picom/picom.conf" || exit 1
|
|
|
|
mkdir -p "$HOME/.config/alacritty" || exit 1
|
|
cp "$DIR/dots/alacritty.yml" "$HOME/.config/alacritty/alacritty.yml" || exit 1
|
|
echo "exec i3" > "$HOME/.xinitrc"
|
|
|
|
# wallpaper
|
|
mkdir -p "$HOME/wallpaper"
|
|
wget https://alpinelinux.org/banner.jpg -o "$HOME/wallpaper/banner.jpg"
|
|
sed -i "s|exec --no-startup-id nitrogen --restore|exec --no-startup-id feh --bg-fill ~/wallpaper/banner.jpg|" "$HOME/.config/i3/config"
|
|
}
|
|
|
|
(dev && sysinfo && dotfiles && vimconfigs) || exit 1
|
|
if ! test -z "$NVIM"; then
|
|
neovim || exit 1
|
|
fi
|
|
if ! test -z "$CP"; then
|
|
competitiveprogramming || exit 1
|
|
fi
|
|
if ! test -z "$GRAPHICAL"; then
|
|
graphical || exit 1
|
|
fi
|
|
if ! test -z "$NFS"; then
|
|
nfs || 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
|