From b2e45c8af16c5e1750c2c1fe4193fd5d08b7bfe8 Mon Sep 17 00:00:00 2001 From: Severin Kaderli Date: Sun, 2 Feb 2020 20:20:32 +0100 Subject: [PATCH] Overhaul install script Signed-off-by: Severin Kaderli --- .gitlab-ci.yml | 3 + .install/arch.sh | 33 ++ .install/aur.sh | 33 ++ .install/composer.sh | 23 + .install/directories.sh | 31 ++ .install/etc.sh | 37 ++ .install/fonts.sh | 16 + .install/groups.sh | 26 ++ .install/issue.sh | 21 + .install/lib/lib.sh | 5 + .install/lib/output.sh | 55 +++ .install/lockscreen.sh | 15 + .install/npm.sh | 26 ++ .install/ntp.sh | 15 + .../packages}/packages.aur.list | 29 +- .../packages}/packages.native.list | 33 +- .install/permissions.sh | 24 + .install/prerequisites.sh | 32 ++ .install/ruby.sh | 21 + .install/rust.sh | 31 ++ .install/shell.sh | 15 + .install/symlinks.sh | 81 ++++ .install/systemd.sh | 45 ++ .install/udev.sh | 21 + install | 418 ++---------------- system/.local/bin/utils | 10 - 26 files changed, 692 insertions(+), 407 deletions(-) create mode 100644 .install/arch.sh create mode 100644 .install/aur.sh create mode 100644 .install/composer.sh create mode 100644 .install/directories.sh create mode 100644 .install/etc.sh create mode 100644 .install/fonts.sh create mode 100644 .install/groups.sh create mode 100644 .install/issue.sh create mode 100644 .install/lib/lib.sh create mode 100755 .install/lib/output.sh create mode 100644 .install/lockscreen.sh create mode 100644 .install/npm.sh create mode 100644 .install/ntp.sh rename {packages => .install/packages}/packages.aur.list (64%) rename {packages => .install/packages}/packages.native.list (91%) create mode 100644 .install/permissions.sh create mode 100644 .install/prerequisites.sh create mode 100644 .install/ruby.sh create mode 100644 .install/rust.sh create mode 100644 .install/shell.sh create mode 100644 .install/symlinks.sh create mode 100644 .install/systemd.sh create mode 100644 .install/udev.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2662e73..36f0ec9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - Lint + Lint: image: koalaman/shellcheck-alpine:latest stage: Lint @@ -17,3 +18,5 @@ Lint: - shellcheck ./system/.config/zsh/.zshrc - shellcheck ./system/.config/X11/xsetup - shellcheck ./install + - shellcheck ./.install/*.sh + - shellcheck ./.install/lib/*.sh \ No newline at end of file diff --git a/.install/arch.sh b/.install/arch.sh new file mode 100644 index 0000000..4e366c1 --- /dev/null +++ b/.install/arch.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# arch.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Installs arch packages from the offical repositories + +output::section "Arch Packages" + +# List created using: yay -Qqen > packages.native.list +if output::prompt "Do you want to install Arch packages?"; then + output::log "Updating package database" + yay -Syy |& output::debug + output::success "Package database successfully updated" + + package_count=$(< "${INSTALL_DIR}/packages/packages.native.list" wc -l) + output::log "Installing ${package_count} packages" + yay -S \ + --asexplicit \ + --noconfirm \ + --sudoloop \ + --needed \ + --devel \ + --nopgpfetch \ + --mflags \ + --skippgpcheck \ + - < "${INSTALL_DIR}/packages/packages.native.list" |& output::debug + output::success "Packages successfully installed" +fi diff --git a/.install/aur.sh b/.install/aur.sh new file mode 100644 index 0000000..f611c4d --- /dev/null +++ b/.install/aur.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# aur.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Installs arch packages from the AUR + +output::section "AUR Packages" + +# List created using: yay -Qqem > packages.aur.list +if output::prompt "Do you want to install AUR packages?"; then + output::log "Updating package database" + yay -Syy |& output::debug + output::success "Package database successfully updated" + + package_count=$(< "${INSTALL_DIR}/packages/packages.aur.list" wc -l) + output::log "Installing ${package_count} packages. This may take a few hours" + yay -S \ + --asexplicit \ + --noconfirm \ + --sudoloop \ + --needed \ + --devel \ + --nopgpfetch \ + --mflags \ + --skippgpcheck \ + - < "${INSTALL_DIR}/packages/packages.aur.list" |& output::debug + output::success "Packages successfully installed" +fi \ No newline at end of file diff --git a/.install/composer.sh b/.install/composer.sh new file mode 100644 index 0000000..083b8f3 --- /dev/null +++ b/.install/composer.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# composer.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Installs global composer packages + +CONFIG_COMPOSER_PACKAGES=( + "laravel/installer" +) + +output::section "Composer" + +if output::prompt "Do you want to install global composer packages?"; then + output::log "Installing ${#CONFIG_COMPOSER_PACKAGES[@]} packages" + output::list ${CONFIG_COMPOSER_PACKAGES[@]} + composer global require "${CONFIG_COMPOSER_PACKAGES[@]}" |& output::debug + output::success "Packages successfully installed" +fi \ No newline at end of file diff --git a/.install/directories.sh b/.install/directories.sh new file mode 100644 index 0000000..4327b3e --- /dev/null +++ b/.install/directories.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# directories.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Creates directories in the home directory + +CONFIG_DIRECTORIES=( + ".local/log" + ".local/share/gnupg" + ".local/share/vpn" + "dev/build" + "dev/opensource" + "dev/pkg" + "dev/projects" + "downloads" + "games" + "videos" +) + +output::section "Creating directories" + +for dir in "${CONFIG_DIRECTORIES[@]}"; do + output::log "Creating directory ${YELLOW}${HOME}/${dir}${DEFAULT}" + mkdir -p "${HOME}/${dir}" +done +output::success "Successfully created directories" \ No newline at end of file diff --git a/.install/etc.sh b/.install/etc.sh new file mode 100644 index 0000000..2cf574e --- /dev/null +++ b/.install/etc.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# etc.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Copies files to /etc + +declare -A CONFIG_ETC_FILES +CONFIG_ETC_FILES=( + ["/etc/cron.daily/update-mirror"]="755" + ["/etc/default/tlp"]="644" + ["/etc/docker/daemon.json"]="644" + ["/etc/gemrc"]="644" + ["/etc/logrotate.d/custom.conf"]="644" + ["/etc/mkinitcpio.conf"]="644" + ["/etc/NetworkManager/conf.d/dns.conf"]="644" + ["/etc/pacman.conf"]="644" + ["/etc/resolv.conf"]="644" + ["/etc/sudoers.d/severin"]="0440" + ["/etc/vconsole.conf"]="644" + ["/etc/X11/nvidia-xorg.conf.d/00-keyboard.conf"]="644" + ["/etc/X11/nvidia-xorg.conf.d/20-displaylink.conf"]="644" + ["/etc/X11/xorg.conf.d/00-keyboard.conf"]="644" + ["/etc/X11/xorg.conf.d/20-displaylink.conf"]="644" + ["/etc/zsh/zshenv"]="644" +) + +output::section "Copying /etc files" +for file in "${!CONFIG_ETC_FILES[@]}"; do + output::log "Copying ${YELLOW}${file}${DEFAULT}" + sudo install -Dm "${CONFIG_ETC_FILES[${file}]}" "${SYSTEM_DIR}${file}" "${file}" |& output::debug +done +output::success "Successfully copied /etc files" \ No newline at end of file diff --git a/.install/fonts.sh b/.install/fonts.sh new file mode 100644 index 0000000..4d39536 --- /dev/null +++ b/.install/fonts.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# fonts.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Setups fonts + +output::section "Fonts" +output::log "Prepare xorg fonts" +sudo mkfontdir /usr/share/fonts/75dpi |& output::debug +sudo mkfontdir /usr/share/fonts/100dpi |& output::debug +output::success "Successfully prepared xorg fonts" diff --git a/.install/groups.sh b/.install/groups.sh new file mode 100644 index 0000000..d746e70 --- /dev/null +++ b/.install/groups.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# groups.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Adds the current user to the configured groups. + +CONFIG_GROUPS=( + "docker" + "log" + "mpd" + "wheel" + "video" +) + +output::section "Groups" +output::log "Current user: ${USER}" +for group in "${CONFIG_GROUPS[@]}"; do + output::log "Adding user to group ${YELLOW}${group}${DEFAULT}" + sudo gpasswd -a "${USER}" "${group}" |& output::debug +done +output::success "Successfully added user to groups" \ No newline at end of file diff --git a/.install/issue.sh b/.install/issue.sh new file mode 100644 index 0000000..ca06c18 --- /dev/null +++ b/.install/issue.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# issue.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Creates the /etc/issue file + +output::section "Issue" +output::log "Creating /etc/issue" +{ + echo '\e{red}'; + < "/etc/hostname" tr '[:lower:]' '[:upper:]' | figlet -f big | sed "s/\\\\/\\\\\\\/g"; + echo -e "\\\r (\\\l)"; + echo '\e{reset}'; +} > "/tmp/issue" +sudo install "/tmp/issue" "/etc/issue" |& output::debug +output::log "Successfully created /etc/issue" \ No newline at end of file diff --git a/.install/lib/lib.sh b/.install/lib/lib.sh new file mode 100644 index 0000000..aace156 --- /dev/null +++ b/.install/lib/lib.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +declare LIB_DIR="$(dirname "${BASH_SOURCE[0]}")" + +source "${LIB_DIR}/output.sh" \ No newline at end of file diff --git a/.install/lib/output.sh b/.install/lib/output.sh new file mode 100755 index 0000000..c564ea5 --- /dev/null +++ b/.install/lib/output.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +RESET="$(tput sgr0)" +GREEN="$(tput setaf 2)" +RED="$(tput setaf 1)" +BLUE="$(tput setaf 4)" +DEFAULT="$(tput op)" +YELLOW="$(tput setaf 3)" +BOLD="$(tput bold)" + +output::log() { + echo -e " ● ${1}" |& tee -a "${INSTALL_LOG}" +} + +output::debug() { + if [ -n "${INSTALL_DEBUG}" ]; then + tee -a "${INSTALL_LOG}" + else + cat > "${INSTALL_LOG}" + fi +} + +output::list() { + for element in "${@}"; do + echo -e " - ${element}" + done +} + +output::success() { + echo -e " ${GREEN}●${DEFAULT} ${1}" |& tee -a "${INSTALL_LOG}" +} + +output::question() { + printf " ${YELLOW}${1}${DEFAULT}" |& tee -a "${INSTALL_LOG}" +} + +output::error() { + echo -e " ${RED}✘${DEFAULT} ${1}" |& tee -a "${INSTALL_LOG}" +} + +output::section() { + echo -e "\n${BOLD}-- ${1} --${RESET}" |& tee -a "${INSTALL_LOG}" +} + +output::prompt() { + output::question "${1} [y/N] " + read -n 1 -r + echo "" + + if [[ ${REPLY} =~ ^[yY]$ ]]; then + return 0 + fi + + return 1 +} \ No newline at end of file diff --git a/.install/lockscreen.sh b/.install/lockscreen.sh new file mode 100644 index 0000000..2f5320f --- /dev/null +++ b/.install/lockscreen.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# lockscreen.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Sets the lockscreen image + +output::section "Lockscreen" +output::log "Setting lockscreen iamge" +betterlockscreen -u "${DOTFILES}/assets/lockscreen.${HOST}.jpg" |& output::debug +output::success "Successfully set lockscreen image" \ No newline at end of file diff --git a/.install/npm.sh b/.install/npm.sh new file mode 100644 index 0000000..837e61f --- /dev/null +++ b/.install/npm.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# npm.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Installs global npm packages + +CONFIG_NPM_PACKAGES=( + "@vue/cli" + "eslint" + "gatsby-cli" + "npm-check-updates" +) + +output::section "NPM" + +if output::prompt "Do you want to install global npm packages?"; then + output::log "Installing ${#CONFIG_NPM_PACKAGES[@]} packages" + output::list ${CONFIG_NPM_PACKAGES[@]} + npm i -g "${CONFIG_NPM_PACKAGES[@]}" |& output::debug + output::success "Packages successfully installed" +fi \ No newline at end of file diff --git a/.install/ntp.sh b/.install/ntp.sh new file mode 100644 index 0000000..0b4caad --- /dev/null +++ b/.install/ntp.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# ntp.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Enables NTP + +output::section "NTP" +output::log "Enabling NTP" +sudo timedatectl set-ntp true |& output::debug +output::success "Successfully enabled NTP" \ No newline at end of file diff --git a/packages/packages.aur.list b/.install/packages/packages.aur.list similarity index 64% rename from packages/packages.aur.list rename to .install/packages/packages.aur.list index 063cbb5..0594d9a 100644 --- a/packages/packages.aur.list +++ b/.install/packages/packages.aur.list @@ -1,52 +1,65 @@ +autojump autokey betterlockscreen-git cava chromium-vaapi-bin +chromium-widevine citra-qt-git clonehero cloog cutentr-git displaylink dolphin-emu-git +dust escrotum-git evhz-git +ferdi-bin flips-git g810-led-git gamemode gitflow-avh gksu -godot-mono-bin gotop-bin -hamsket-git -intellij-idea-ultimate-edition isl +jdk-jetbrains jstest-gtk-git -lastpass +just +kunst-git lib32-gamemode +meli-git melonds-git -mesen-git minecraft-launcher +mingw-w64-binutils +mingw-w64-crt +mingw-w64-gcc +mingw-w64-headers +mingw-w64-winpthreads mupen64plus-qt +nerd-fonts-fira-code nerd-fonts-fira-mono nvidia-xrun-git osl +pacaudit paper-icon-theme pegasus-frontend-git phonon-qt4 -phpstorm plata-theme polybar python-gspread-git +python-pefile +python2-notify rpcs3-git sameboy-git -sampler sxiv-git +tale-git +talk-cli-git tealdeer topgrade ttf-mac-fonts ttf-ms-fonts vita3k-git -xboxdrv +vvvvvv-git +wine-tkg-staging-fsync-git xwiimote-git xwinwrap-git yay diff --git a/packages/packages.native.list b/.install/packages/packages.native.list similarity index 91% rename from packages/packages.native.list rename to .install/packages/packages.native.list index f30c742..816e713 100644 --- a/packages/packages.native.list +++ b/.install/packages/packages.native.list @@ -3,13 +3,15 @@ acpid adobe-source-code-pro-fonts adobe-source-sans-pro-fonts alacritty +alacritty-terminfo alsa-utils anki +anthy arandr autoconf -autojump automake autopep8 +base bash bash-completion bat @@ -21,11 +23,12 @@ bison blueman bluez-utils bzip2 +calibre ccache +chromaprint clang code composer -compton coreutils cpupower cronie @@ -60,10 +63,13 @@ gawk gcc gcc-libs gettext +ghex gimp git +glances glibc gnome-keyring +gnuplot go-pie gparted gpick @@ -79,17 +85,23 @@ gvfs-smb gzip hplip httpie +hyperfine i3-gaps +i7z ibus ibus-anthy inetutils +inkscape inotify-tools +intellij-idea-community-edition iproute2 iputils +java-openjfx jdk-openjdk jdk8-openjdk jfsutils jpegoptim +jq jre-openjdk keepassxc kvantum-theme-adapta @@ -97,6 +109,7 @@ less lib32-giflib lib32-gst-plugins-base-libs lib32-gtk3 +lib32-libpng12 lib32-libpulse lib32-libva lib32-mesa @@ -106,6 +119,7 @@ lib32-openal lib32-v4l-utils lib32-virtualgl lib32-vulkan-icd-loader +libgdiplus libmgba libreoffice-fresh libudev0-shim @@ -114,6 +128,7 @@ licenses light linux linux-firmware +linuxconsole logrotate lsb-release lsd @@ -122,15 +137,19 @@ lvm2 lxappearance lzop m4 +mailcap make man-db man-pages +mariadb maven mdadm mesa mesa-demos +meson mgba-qt min +mono mpc mpd mpv @@ -177,11 +196,13 @@ pciutils perl perl-archive-zip picard +picom powertop procps-ng psmisc pulseaudio pulseaudio-alsa +pv pyside2 python-atspi python-black @@ -194,7 +215,6 @@ python-pylint python-pyqt5 python-pyusb python-reportlab -python2-notify python2-numpy python2-service-identity qt-gstreamer @@ -215,6 +235,7 @@ ruby rust-racer rustup s-nail +scapy sd seahorse sed @@ -223,8 +244,10 @@ shellcheck simple-scan slock smartmontools +splint sqlitebrowser steam +stfl streamlink subversion sudo @@ -258,6 +281,7 @@ tokei ttf-croscore ttf-dejavu ttf-droid +ttf-fira-code ttf-fira-mono ttf-fira-sans ttf-font-awesome @@ -275,10 +299,12 @@ wget which whois winetricks +wireshark-qt wqy-zenhei xclip xdelta3 xdg-user-dirs +xdotool xf86-video-intel xfsprogs xorg-fonts-alias @@ -288,6 +314,7 @@ xorg-xbacklight xorg-xev xorg-xhost xorg-xinit +xorg-xmessage xorg-xprop xorg-xrandr xorg-xwininfo diff --git a/.install/permissions.sh b/.install/permissions.sh new file mode 100644 index 0000000..af1ac1b --- /dev/null +++ b/.install/permissions.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# groups.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Sets permissions for folders and files + +declare -A CONFIG_PERMISSIONS +CONFIG_PERMISSIONS=( + ["${XDG_BIN_HOME}"]="744" +) + +output::section "Permissions" +for permission in "${!CONFIG_PERMISSIONS[@]}"; do + output::log "Changing owner of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${USER}${DEFAULT}" + sudo chown -R "${USER}" "${permission}" |& output::debug + output::log "Changing permission of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${CONFIG_PERMISSIONS[${permission}]}${DEFAULT}" + sudo chmod -R "${CONFIG_PERMISSIONS[${permission}]}" "${permission}" |& output::debug +done +output::success "Successfully set permissions" diff --git a/.install/prerequisites.sh b/.install/prerequisites.sh new file mode 100644 index 0000000..117f24d --- /dev/null +++ b/.install/prerequisites.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# prerequisites.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Installs the prerequisites for the installation script. + +output::section "Prerequisites" + +output::log "Installing requirements for install script" +sudo pacman -S sudo ccache git base-devel --noconfirm --needed |& output::debug +output::success "Requirements successfully installed" + +is_yay_installed=$(command -v yay) +output::log "Installing yay" +if [ -z "${is_yay_installed}" ]; then + TMP_DIR=$(mktemp -d) + git clone https://aur.archlinux.org/yay.git "${TMP_DIR}" |& output::debug + + ( + cd "${TMP_DIR}"|| exit + makepkg -si --noconfirm --skippgpcheck |& output::debug + ) + + output::success "yay installed" +else + output::success "Yay is already installed" +fi \ No newline at end of file diff --git a/.install/ruby.sh b/.install/ruby.sh new file mode 100644 index 0000000..deb5d02 --- /dev/null +++ b/.install/ruby.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# ruby.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Installs ruby gems + +CONFIG_RUBY_GEMS=() + +output::section "Ruby" + +if output::prompt "Do you want to install ruby gems?"; then + output::log "Installing ${#CONFIG_RUBY_GEMS[@]} gems" + output::list ${CONFIG_RUBY_GEMS[@]} + gem install "${CONFIG_RUBY_GEMS[@]}" |& output::debug + output::success "Gems successfully installed" +fi \ No newline at end of file diff --git a/.install/rust.sh b/.install/rust.sh new file mode 100644 index 0000000..9043e97 --- /dev/null +++ b/.install/rust.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# rust.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Install a Rust toolchain and components using Rustup + +CONFIG_RUST_CHANNEL="beta" +CONFIG_RUST_COMPONENTS=( + "clippy" + "rls" + "rustfmt" +) + +output::section "Rust" + +if output::prompt "Do you want to install a Rust toolchain?"; then + output::log "Installing Rust using ${CONFIG_RUST_CHANNEL} channel" + rustup -q toolchain install "${CONFIG_RUST_CHANNEL}" |& output::debug + rustup -q default "${CONFIG_RUST_CHANNEL}" |& output::debug + output::success "Rust toolchain was installed and activated" + + output::log "Installing components for Rust" + output::list ${CONFIG_RUST_COMPONENTS[@]} + rustup -q component add "${CONFIG_RUST_COMPONENTS[@]}" |& output::debug + output::success "Rust components were successfully installed" +fi \ No newline at end of file diff --git a/.install/shell.sh b/.install/shell.sh new file mode 100644 index 0000000..1a40466 --- /dev/null +++ b/.install/shell.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# shell.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Sets default shell + +output::section "Shell" +output::log "Setting default shell to zsh" +chsh -s "/bin/zsh" +output::success "Successfully set default shell to zsh" diff --git a/.install/symlinks.sh b/.install/symlinks.sh new file mode 100644 index 0000000..b4de2f9 --- /dev/null +++ b/.install/symlinks.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# symlinks.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Creates symlinks + +CONFIG_LINKED_FILES_HOME=( + ".config/alacritty" + ".config/autokey" + ".config/bat" + ".config/ccache" + ".config/cmus" + ".config/compton" + ".config/cron" + ".config/custom" + ".config/chromium-flags.conf" + ".config/dconf" + ".config/dunst" + ".config/git" + ".config/gtk-2.0" + ".config/gtk-3.0" + ".config/httpie" + ".config/i3" + ".config/maven" + ".config/mpd" + ".config/mpv" + ".config/MusicBrainz" + ".config/ncmpcpp" + ".config/npm" + ".config/octave" + ".config/pacman" + ".config/phpstorm" + ".config/polybar" + ".config/python" + ".config/redshift" + ".config/sqlite3" + ".config/streamlink" + ".config/ssh" + ".config/sxhkd" + ".config/topgrade.toml" + ".config/Trolltech.conf" + ".config/user-dirs.dirs" + ".config/user-dirs.locale" + ".config/vim" + ".config/vue" + ".config/wget" + ".config/X11" + ".config/yay" + ".config/zathura" + ".config/zsh" + ".local/bin" + ".local/share/gnupg/gpg-agent.conf" +) + +declare -A CONFIG_LINKED_FILES +CONFIG_LINKED_FILES=( + ["${HOME}/.PhpStorm2019.1"]="${XDG_CONFIG_HOME}/phpstorm" + ["${HOME}/.PhpStorm2019.2"]="${XDG_CONFIG_HOME}/phpstorm" + ["${HOME}/documents"]="${HOME}/data/Documents" + ["${HOME}/music"]="${HOME}/data/Media/Music" + ["${HOME}/pictures"]="${HOME}/data/Media/Pictures" +) + +output::section "Symlinks" +for file in "${CONFIG_LINKED_FILES_HOME[@]}"; do + output::log "Linking ${YELLOW}\${HOME}/${file}${DEFAULT} to ${YELLOW}\${SYSTEM_DIR}/${file}${DEFAULT}" + rm -rf "${HOME:?}/${file}" |& output::debug + ln -fs "${SYSTEM_DIR}/${file}" "${HOME}/${file}" |& output::debug +done + +for file in "${!CONFIG_LINKED_FILES[@]}"; do + output::log "Linking ${YELLOW}${file}${DEFAULT} to ${YELLOW}${CONFIG_LINKED_FILES[${file}]}${DEFAULT}" + rm -rf "${file}" |& output::debug + ln -fs "${CONFIG_LINKED_FILES[${file}]}" "${file}" |& output::debug +done +output::success "Successfully created symlinks" \ No newline at end of file diff --git a/.install/systemd.sh b/.install/systemd.sh new file mode 100644 index 0000000..7aefd2d --- /dev/null +++ b/.install/systemd.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# systemd.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Copies custom systemd services and enables needed services. + +CONFIG_SYSTEMD_SERVICES=( + "acpid" + "bluetooth" + "cronie" + "docker" + "NetworkManager" + "org.cups.cupsd" + "suspend" + "systemd-timesyncd" +) + +CONFIG_SYSTEMD_USER_SERVICES=( + "mpd" +) + +output::section "Copying systemd services" +for service in "${SYSTEM_DIR}/etc/systemd/system/"*; do + output::log "Copying service ${YELLOW}$(basename "${service}")${DEFAULT}" + sudo install -m 644 "${service}" "/etc/systemd/system" |& output::debug +done +output::success "Successfully copied systemd services" + + +output::section "Enabling systemd services" +for service in "${CONFIG_SYSTEMD_SERVICES[@]}"; do + output::log "Enabling service ${YELLOW}${service}${DEFAULT}" + sudo systemctl enable "${service}" |& output::debug +done + +for service in "${CONFIG_SYSTEMD_USER_SERVICES[@]}"; do + output::log "Enabling service ${YELLOW}${service}${DEFAULT}" + systemctl --user enable "${service}" |& output::debug +done +output::success "Successfully enabled systemd services" \ No newline at end of file diff --git a/.install/udev.sh b/.install/udev.sh new file mode 100644 index 0000000..5ccb84b --- /dev/null +++ b/.install/udev.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# SCRIPT NAME: +# udev.sh +# +# AUTHOR: +# Severin Kaderli +# +# DESCRIPTION: +# Copying custom udev rules + +output::section "Copying custom udev rules" +for file in "${SYSTEM_DIR}/etc/udev/rules.d/"*.rules; do + output::log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/udev/rules.d/${DEFAULT}" + sudo cp "${file}" "/etc/udev/rules.d/" |& output::debug +done + +output::log "Reload rules" +sudo udevadm control --reload-rules |& output::debug + +output::success "Successfully copied udev rules" \ No newline at end of file diff --git a/install b/install index a788307..7c46003 100755 --- a/install +++ b/install @@ -13,169 +13,22 @@ # # USAGE: # ./install -. ./system/.config/custom/env -. ./system/.local/bin/utils +declare DOT_DIR="$(dirname "${BASH_SOURCE[0]}" | cd | pwd)" +declare INSTALL_DIR="${DOT_DIR}/.install" +declare SYSTEM_DIR="${DOT_DIR}/system" +INSTALL_LOG="${XDG_LOG_HOME}/install.log" + +source "${INSTALL_DIR}/lib/lib.sh" + + +#. ./system/.config/custom/env +#. ./system/.local/bin/utils ############################################################################### # Configuration variables # ############################################################################### HOST="$(hostname)" -# Directories which should be created -DIRECTORIES=( - ".local/log" - ".local/share/gnupg" - ".local/share/vpn" - "dev/build" - "dev/opensource" - "dev/pkg" - "dev/projects" - "downloads" - "games" - "videos" -) - -# Files which should be symlinked in the home folder -LINKED_FILES_HOME=( - ".config/alacritty" - ".config/autokey" - ".config/bat" - ".config/ccache" - ".config/cmus" - ".config/compton" - ".config/cron" - ".config/custom" - ".config/chromium-flags.conf" - ".config/dconf" - ".config/dunst" - ".config/git" - ".config/gtk-2.0" - ".config/gtk-3.0" - ".config/httpie" - ".config/i3" - ".config/maven" - ".config/mpd" - ".config/mpv" - ".config/MusicBrainz" - ".config/ncmpcpp" - ".config/npm" - ".config/octave" - ".config/pacman" - ".config/phpstorm" - ".config/polybar" - ".config/python" - ".config/redshift" - ".config/sqlite3" - ".config/streamlink" - ".config/ssh" - ".config/sxhkd" - ".config/topgrade.toml" - ".config/Trolltech.conf" - ".config/user-dirs.dirs" - ".config/user-dirs.locale" - ".config/vim" - ".config/vue" - ".config/wget" - ".config/X11" - ".config/yay" - ".config/zathura" - ".config/zsh" - ".local/bin" - ".local/share/gnupg/gpg-agent.conf" -) - -# Symlinks which will be created -declare -A LINKED_FILES -LINKED_FILES=( - ["${HOME}/.PhpStorm2019.1"]="${XDG_CONFIG_HOME}/phpstorm" - ["${HOME}/.PhpStorm2019.2"]="${XDG_CONFIG_HOME}/phpstorm" - ["${HOME}/documents"]="${HOME}/data/Documents" - ["${HOME}/music"]="${HOME}/data/Media/Music" - ["${HOME}/pictures"]="${HOME}/data/Media/Pictures" -) - -# Permissions to set for folders and files -declare -A PERMISSIONS -PERMISSIONS=( - ["${XDG_BIN_HOME}"]="744" -) - -# Groups the user should be added to -ADD_GROUPS=( - "docker" - "log" - "mpd" - "wheel" - "video" -) - -# Array of systemd services which should be enabled -SYSTEMD_SERVICES=( - "acpid" - "bluetooth" - "cronie" - "docker" - "NetworkManager" - "org.cups.cupsd" - "suspend" - "systemd-timesyncd" - "tlp" - "tlp-sleep" - "xboxdrv" -) - -SYSTEMD_USER_SERVICES=( - "mpd" -) - -# Rust components which should be installed -RUST_COMPONENTS=( - "clippy" - "rls" - "rustfmt" -) - -# npm packages which should be installed globally -NPM_PACKAGES=( - "@vue/cli" - "eslint" - "gatsby-cli" - "mtgaup" - "npm-check-updates" -) - -# Ruby gems which should be installed -RUBY_GEMS=( - "docker-sync" -) - -# composer packages which should be installed globally -COMPOSER_PACKAGES=( - "laravel/installer" -) - -# Root files which should be copied -declare -A COPY_ROOT_FILES -COPY_ROOT_FILES=( - ["/etc/cron.daily/update-mirror"]="755" - ["/etc/default/tlp"]="644" - ["/etc/docker/daemon.json"]="644" - ["/etc/gemrc"]="644" - ["/etc/logrotate.d/custom.conf"]="644" - ["/etc/mkinitcpio.conf"]="644" - ["/etc/NetworkManager/conf.d/dns.conf"]="644" - ["/etc/pacman.conf"]="644" - ["/etc/resolv.conf"]="644" - ["/etc/sudoers.d/severin"]="0440" - ["/etc/vconsole.conf"]="644" - ["/etc/X11/nvidia-xorg.conf.d/00-keyboard.conf"]="644" - ["/etc/X11/nvidia-xorg.conf.d/20-displaylink.conf"]="644" - ["/etc/X11/xorg.conf.d/00-keyboard.conf"]="644" - ["/etc/X11/xorg.conf.d/20-displaylink.conf"]="644" - ["/etc/zsh/zshenv"]="644" -) - - ############################################################################### # Installtion information # ############################################################################### @@ -184,241 +37,34 @@ echo " • The user severin is added to the sudoers file" echo " • The multilib repository is uncommented in /etc/pacman.conf" echo -e " • Your SSH keys are located in ~/.ssh${RESET}\n" -if ! ask_prompt "Are you ready to continue?"; then +if ! output::prompt "Are you ready to continue?"; then exit 1 fi +source "${INSTALL_DIR}/prerequisites.sh" -############################################################################### -# Work specific settings # -############################################################################### -if [ "${IS_WORK}" = "1" ]; then - export GIT_SSH_COMMAND="ssh -i /home/severin/.ssh/severin_id_rsa" -fi +sudo printf "" +source "${INSTALL_DIR}/arch.sh" +source "${INSTALL_DIR}/rust.sh" +source "${INSTALL_DIR}/aur.sh" +source "${INSTALL_DIR}/npm.sh" +source "${INSTALL_DIR}/composer.sh" +source "${INSTALL_DIR}/ruby.sh" +source "${INSTALL_DIR}/directories.sh" +source "${INSTALL_DIR}/symlinks.sh" +source "${INSTALL_DIR}/permissions.sh" +source "${INSTALL_DIR}/groups.sh" +source "${INSTALL_DIR}/systemd.sh" +source "${INSTALL_DIR}/udev.sh" +source "${INSTALL_DIR}/etc.sh" +source "${INSTALL_DIR}/ntp.sh" +source "${INSTALL_DIR}/lockscreen.sh" +source "${INSTALL_DIR}/issue.sh" +source "${INSTALL_DIR}/fonts.sh" +source "${INSTALL_DIR}/shell.sh" -############################################################################### -# Install package manager and packages # -############################################################################### -#print_section "Installing package requirements" -# sudo pacman -S sudo ccache git base-devel --noconfirm --needed - -# print_section "Installing yay" -# is_yay_installed=$(command -v yay) - -# # Install yay if not already installed -# if [ -z "${is_yay_installed}" ]; then -# git clone https://aur.archlinux.org/yay.git -# ( -# cd yay || exit -# makepkg -si --noconfirm --skippgpcheck -# ) -# rm -rf yay -# else -# print_log "yay is already installed" -# fi - -# List created using: yay -Qqen > packages.native.list -package_count=$(< "${PACKAGES_DIR}/packages.native.list" wc -l) - -if ask_prompt "Do you want to install ${package_count} Arch packages?"; then - print_log "Installing ${package_count} Arch packages" - yay -Syy > /dev/null 2>&1 - yay -S --asexplicit --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.native.list" -fi - - -if ask_prompt "Do you want to install a rust toolchain?"; then - rustup toolchain install beta - rustup default beta - rustup component add "${RUST_COMPONENTS[@]}" - rustup default beta -fi - -# List created using: yay -Qqem > packages.aur.list -package_count=$(< "${PACKAGES_DIR}/packages.aur.list" wc -l) - -if ask_prompt "Do you want to install ${package_count} AUR packages?"; then - print_log "Installing ${package_count} AUR packages" - yay -Syy > /dev/null 2>&1 - yay -S --asexplicit --noconfirm --sudoloop --needed --devel --nopgpfetch --mflags --skippgpcheck - < "${PACKAGES_DIR}/packages.aur.list" -fi - -# Remove unneeded packages -#if ask_prompt "Do you want to remove all unneeded packages?"; then -# yay -Rsnu $(comm -23 <(pacman -Qqtt | sort) <(cat "${PACKAGES_DIR}/packages.native.list" "${PACKAGES_DIR}/packages.aur.list" | sort)) -#fi - -if ask_prompt "Do you want to install ${#NPM_PACKAGES[@]} global npm packages?"; then - print_log "Installing ${#NPM_PACKAGES[@]} packages" - npm i -g "${NPM_PACKAGES[@]}" -fi - -if ask_prompt "Do you want to install ${#COMPOSER_PACKAGES[@]} global composer packages?"; then - print_log "Installing ${#COMPOSER_PACKAGES[@]} packages" - composer global require "${COMPOSER_PACKAGES[@]}" -fi - -if ask_prompt "Do you want to install ${#RUBY_GEMS[@]} ruby gems?"; then - print_log "Installing ${#RUBY_GEMS[@]} gems" - gem install "${RUBY_GEMS[@]}" -fi - -############################################################################### -# Creating directories # -############################################################################### -print_section "Creating directories" - -for dir in "${DIRECTORIES[@]}" -do - print_log "Creating directory ${YELLOW}${HOME}/${dir}${DEFAULT}" - mkdir -p "${HOME}/${dir}" -done - - -############################################################################### -# Prepare work tools # -############################################################################### -print_section "Prepare work tools" - -############################################################################### -# Creating symlinks # -############################################################################### -print_section "Creating symlinks" -for file in "${LINKED_FILES_HOME[@]}"; -do - print_log "Linking ${YELLOW}${HOME}/${file}${DEFAULT} to ${YELLOW}${SYSTEM_DIR}/${file}${DEFAULT}" - rm -rf "${HOME:?}/${file}" - ln -fs "${SYSTEM_DIR}/${file}" "${HOME}/${file}" -done - -for file in "${!LINKED_FILES[@]}"; do - print_log "Linking ${YELLOW}${file}${DEFAULT} to ${YELLOW}${LINKED_FILES[${file}]}${DEFAULT}" - rm -rf "${file}" - ln -fs "${LINKED_FILES[${file}]}" "${file}" -done - - -############################################################################### -# Giving permissions # -############################################################################### -print_section "Giving permissions" -for permission in "${!PERMISSIONS[@]}"; do - print_log "Changing owner of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${USER}${DEFAULT}" - sudo chown -R "${USER}" "${permission}" - print_log "Changing permission of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${PERMISSIONS[${permission}]}${DEFAULT}" - sudo chmod -R "${PERMISSIONS[${permission}]}" "${permission}" -done - - -############################################################################### -# Adding user to groups # -############################################################################### -print_section "Adding user to groups" -for group in "${ADD_GROUPS[@]}" -do - print_log "Adding user ${YELLOW}${USER}${DEFAULT} to group ${YELLOW}${group}${DEFAULT}" - sudo gpasswd -a "${USER}" "${group}" > /dev/null 2>&1 -done - - -############################################################################### -# Copying systemd services # -############################################################################### -print_section "Copying systemd services" -for file in "${SYSTEM_DIR}/etc/systemd/system/"* -do - print_log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/systemd/system${DEFAULT}" - sudo install -m 644 "${file}" "/etc/systemd/system" -done - - -############################################################################### -# Enabling systemd services # -############################################################################### -print_section "Enabling systemd services" -for service in "${SYSTEMD_SERVICES[@]}" -do - print_log "Enabling service ${YELLOW}${service}${DEFAULT}" - sudo systemctl enable "${service}" -done - -for service in "${SYSTEMD_USER_SERVICES[@]}" -do - print_log "Enabling service ${YELLOW}${service}${DEFAULT}" - systemctl --user enable "${service}" -done - - -############################################################################### -# Enabling systemd services # -############################################################################### -print_section "Copying custom udev rules" -for file in "${SYSTEM_DIR}/etc/udev/rules.d/"*.rules -do - print_log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/udev/rules.d/${DEFAULT}" - sudo cp "${file}" "/etc/udev/rules.d/" -done -sudo udevadm control --reload-rules - - -############################################################################### -# Copying root files # -############################################################################### -print_section "Copying root files" -for file in "${!COPY_ROOT_FILES[@]}"; do - print_log "Copying ${YELLOW}${file}${DEFAULT}" - sudo install -Dm "${COPY_ROOT_FILES[${file}]}" "${SYSTEM_DIR}${file}" "${file}" -done - - -############################################################################### -# Enable ntp # -############################################################################### -print_section "Enabling ntp" -sudo timedatectl set-ntp true - - -############################################################################### -# Setting lockscreen image # -############################################################################### -print_section "Setting lockscreen image" -betterlockscreen -u "${DOTFILES}/assets/lockscreen.${HOST}.jpg" > /dev/null 2>&1 -print_log "Lockscreen generated" - - -############################################################################### -# Creating issue file # -############################################################################### -print_section "Creating issue file" -{ - echo '\e{red}'; - < "/etc/hostname" tr '[:lower:]' '[:upper:]' | figlet -f big | sed "s/\\\\/\\\\\\\/g"; - echo -e "\\\r (\\\l)"; - echo '\e{reset}'; -} > "/tmp/issue" -sudo install "/tmp/issue" "/etc/issue" -print_log "Issue file created" - -############################################################################### -# Fonts # -############################################################################### -print_section "Fonts" -sudo mkfontdir /usr/share/fonts/75dpi -sudo mkfontdir /usr/share/fonts/100dpi -print_log "Prepare xorg fonts" - -############################################################################### -# Set default shell # -############################################################################### -print_section "Set default shell" -chsh -s "/bin/zsh" -print_log "Set default shell to zsh" - -############################################################################### -# Post installation information # -############################################################################### -print_section "Post installation information" +output::section "Post installation information" echo "${BOLD}Make sure you do the following after this installation:" echo " • Download settings for Visual Studio Code" echo " • Reboot the system" \ No newline at end of file diff --git a/system/.local/bin/utils b/system/.local/bin/utils index 4a0d17b..2a1d94f 100755 --- a/system/.local/bin/utils +++ b/system/.local/bin/utils @@ -57,13 +57,3 @@ function print_log() { echo -e " ${BLUE}->${DEFAULT} ${1}" } -function ask_prompt() { - read -p "${BOLD}${BLUE}::${DEFAULT} ${1} [y/N] ${RESET}" -n 1 -r - echo "" - - if [[ ${REPLY} =~ ^[^yY]$ ]]; then - return 1 - fi - - return 0 -} \ No newline at end of file