Overhaul install script
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
ce2413484c
commit
b2e45c8af1
26 changed files with 692 additions and 407 deletions
418
install
418
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"
|
Loading…
Add table
Add a link
Reference in a new issue