Join all install scripts and make them more flexible

This commit is contained in:
har0ke 2023-10-05 20:29:41 +02:00
parent afb072c0cc
commit 0187e952ea
7 changed files with 235 additions and 117 deletions

103
arch.sh
View File

@ -1,103 +0,0 @@
#!/usr/bin/env bash
set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
trap cleanup EXIT
cleanup () {
rm -rf "$SCRIPT_DIR/pikaur"
}
declare -ar base_system=(
alsa-utils
ethtool
htop
llvm
lshw
make
man-db
man-pages
networkmanager
perf
pulseaudio
pv
sshfs
tcpdump
tmux
tree
vim
wget
zsh
)
declare -ar base_dev=(
autoconf
automake
cmake
gdb
git
ninja
)
declare -ar i3_environment=(
acpilight
dmenu
i3-gaps
i3status-rust
i3lock-color
playerctl
rofi
ttf-font-awesome
wmctrl
xidlehook pkgconf # undocumented dependency
xss-lock
xterm
xorg-server
xorg-xinit
xorg-xrandr
network-manager-applet
)
declare -ar apps_core=(
chromium
firefox
keepassxc
nextcloud-client
pavucontrol
thunderbird
protonmail-bridge-bin
)
declare -ar apps_dev=(
meld
tk # git gui
visual-studio-code-bin
)
declare -ar apps_extra=(
audacity
darktable
gimp
spotify
vlc
)
if ! pacman -Qqe | grep pikaur > /dev/null; then
sudo pacman -Sy --needed git pyalm python-markdown-it-py asp \
python-defusedxml python-pysocks
git clone https://aur.archlinux.org/pikaur.git "$SCRIPT_DIR/pikaur" || true
cd "$SCRIPT_DIR/pikaur"
git pull
makepkg -i
fi
sudo pikaur -Sy --needed \
"${base_system[@]}" \
"${base_dev[@]}" \
"${i3_environment[@]}" \
"${apps_core[@]}" \
"${apps_dev[@]}" \
"${apps_extra[@]}"

45
common.sh Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/bash
ALL=0
WORKSTATION=0
EXTRA=0
DEV=0
if [[ "$#" -eq 0 ]]; then
ALL=1
fi
options=$(getopt -o awed -l all,workstation,extra,dev -- "$@")
[ $? -eq 0 ] || {
echo "Incorrect options provided"
exit 1
}
eval set -- "$options"
while true; do
case "$1" in
-a | --all)
ALL=1
;;
-w | --workstation)
WORKSTATION=1
;;
-e | --extra)
EXTRA=1
;;
-d | --dev)
DEV=1
;;
--)
shift
break
;;
esac
shift
done
if [ "${ALL}" -eq 1 ]; then
WORKSTATION=1
EXTRA=1
DEV=1
fi

16
install.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
declare -ar args=("${@}")
source "${SCRIPT_DIR}/common.sh"
./install_packages_arch.sh "${args[@]}"
./install_dotfiles.sh "${args[@]}"
./install_vimplug.sh
if [ "${DEV}" -eq 1 ] && [ "${WORKSTATION}" -eq 1 ]; then
./install_code_extensions.sh
fi

View File

@ -1,4 +1,7 @@
#!/usr/bin/bash
set -euo pipefail
code \
--install-extension rozbo.papercolor-vscode \
--install-extension dcasella.i3 \

View File

@ -5,6 +5,8 @@ set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "${SCRIPT_DIR}"
source "${SCRIPT_DIR}/common.sh"
function run_as_user() {
echo "Run with user $1:" "${@:2}"
sudo -u "${@}"
@ -116,24 +118,17 @@ mode="${1-terminal}"
echo $mode
install -d "${HOME}/.dotfiles" "./"
if [[ $mode =~ "terminal" ]] || [[ $mode =~ "workstation" ]] || [[ $mode =~ "all" ]]; then
install .oh-my-zsh/themes/oke.zsh-theme
install .zshrc
install .vimrc
install .winfo.sh
fi
install .oh-my-zsh/themes/oke.zsh-theme
install .zshrc
install .vimrc
install .winfo.sh
if [[ $mode =~ "user" ]] || [[ $mode =~ "all" ]]; then
install .config/i3/config
install .config/i3status-rust/config.toml
install .config/Code/User/settings.json
install .config/Code/User/keybindings.json
if [ "${WORKSTATION}" -eq 1 ]; then
install .Xmodmap
install .Xresources
install .xinitrc
fi
if [[ $mode =~ "workstation" ]] || [[ $mode =~ "all" ]]; then
install .config/i3/config
install .config/i3status-rust/config.toml
install -r etc/modprobe.d/nobeep.conf
install -r etc/systemd/logind.conf
install -r etc/acpi/handler.sh
@ -142,3 +137,7 @@ if [[ $mode =~ "workstation" ]] || [[ $mode =~ "all" ]]; then
install -r usr/share/X11/xorg.conf.d/40-libinput.conf
fi
if [ "${DEV}" -eq 1 ] && [ "${WORKSTATION}" -eq 1 ]; then
install .config/Code/User/settings.json
install .config/Code/User/keybindings.json
fi

156
install_packages_arch.sh Executable file
View File

@ -0,0 +1,156 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}/common.sh"
trap cleanup EXIT
cleanup () {
rm -rf "$SCRIPT_DIR/pikaur"
}
declare -ar pkgs_system_base=(
autoconf
automake
cmake
ethtool
gcc
gdb
git
gitui
htop
lshw
make
pv
sshfs
tcpdump
tmux
tree
vim
wget
zsh
)
declare -ar pkgs_system_workstation=(
alsa-utils
networkmanager
pulseaudio
)
declare -ar pkgs_tools_dev=(
llvm
man-db
man-pages
perf
ninja
)
declare -ar pkgs_i3_environment=(
acpilight
dmenu
i3-gaps
i3status-rust
i3lock-color
network-manager-applet
playerctl
rofi
ttf-font-awesome
wmctrl
xidlehook pkgconf # undocumented dependency
xss-lock
xterm
xorg-server
xorg-xinit
xorg-xrandr
)
declare -ar pkgs_apps_core=(
chromium
firefox
nextcloud-client
pavucontrol
protonmail-bridge-bin
thunar gvfs gvfs-mtp thunar-archive-plugin thunar-media-tags-plugin tumbler ffmpegthumbnailer
thunderbird
)
declare -ar pkgs_apps_dev=(
meld
tk # git gui
visual-studio-code-bin
)
declare -ar pkgs_apps_extra=(
audacity
darktable
gimp
gnucash
keepassxc
spotify
vlc
)
mapfile -t pkgl_all < <( compgen -v pkgs_ )
declare -a pkgl_not_used=("${pkgl_all[@]}")
declare -a packages_to_install=()
declare -a pkgl_used=()
function add_pkg_list() {
local -r list_name="$1"
local -n list_packages="$1"
for i in "${!pkgl_not_used[@]}"; do
if [[ ${pkgl_not_used[i]} = "${list_name}" ]]; then
unset 'pkgl_not_used[i]'
fi
done
pkgl_used+=("${list_name}")
packages_to_install+=("${list_packages[@]}")
}
add_pkg_list pkgs_system_base
if [ "${WORKSTATION}" -eq 1 ]; then
add_pkg_list pkgs_system_workstation
add_pkg_list pkgs_i3_environment
add_pkg_list pkgs_apps_core
fi
if [ "${DEV}" -eq 1 ]; then
add_pkg_list pkgs_tools_dev
fi
if [ "${DEV}" -eq 1 ] && [ "${WORKSTATION}" -eq 1 ]; then
add_pkg_list pkgs_apps_dev
fi
if [ "${EXTRA}" -eq 1 ] && [ "${WORKSTATION}" -eq 1 ]; then
add_pkg_list pkgs_apps_extra
fi
for arg in "${@:1}"; do
add_pkg_list "${arg}"
done
printf "Packets to install:\n"
printf "\t%s\n" "${packages_to_install[@]}"
printf "\nNot installed groups:\n"
printf "\t%s\n" "${pkgl_not_used[@]}"
printf "\nInstalled groups:\n"
printf "\t%s\n" "${pkgl_used[@]}"
if ! pacman -Qqe | grep pikaur > /dev/null; then
git clone https://aur.archlinux.org/pikaur.git "$SCRIPT_DIR/pikaur" || true
cd "$SCRIPT_DIR/pikaur"
git pull
makepkg -irs
fi
sudo pikaur -Sy --noedit --needed "${packages_to_install[@]}"

View File

@ -1,5 +1,7 @@
#!/usr/bin/bash
set -euo pipefail
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim