2019-09-30 13:44:02 +02:00
|
|
|
#!/bin/bash
|
2020-05-02 14:40:28 +02:00
|
|
|
# @author Kevin Veen-Birkenbach
|
2020-05-05 11:50:20 +02:00
|
|
|
# shellcheck disable=SC2015 # Deactivating bool hint
|
2019-10-01 12:30:27 +02:00
|
|
|
# shellcheck source=/dev/null # Deactivate SC1090
|
2020-05-06 12:30:16 +02:00
|
|
|
# shellcheck disable=SC2005 # Deactivate wrong shellcheck interpretation
|
2020-05-06 12:11:15 +02:00
|
|
|
# shellcheck disable=SC2086 # Deactivating escaping warning, because it's wrong concerning pacman_packages
|
2020-05-02 12:37:26 +02:00
|
|
|
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
2020-05-03 21:28:40 +02:00
|
|
|
|
2020-05-06 12:11:15 +02:00
|
|
|
get_packages(){
|
|
|
|
for package_collection in "$@"
|
|
|
|
do
|
|
|
|
echo "$(sed -e "/^#/d" -e "s/#.*//" "$PACKAGE_PATH""$package_collection.txt" | tr '\n' ' ')" || error "Loading package wasn't possible."
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_yay_packages_if_needed(){
|
|
|
|
info "Checking yay packages [ $1 ]..."
|
|
|
|
for package in $1; do
|
|
|
|
if [ "$(pacman -Qi "$package" 2> /dev/null)" ]; then
|
|
|
|
info "Package \"$package\" is allready installed. Skipped installation."
|
|
|
|
else
|
|
|
|
info "Install package \"$package\" with yay..." &&
|
|
|
|
yay -S "$package" || error "Failed to install package \"$package\"."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-05-02 12:37:26 +02:00
|
|
|
info "Start setup of customized core software..."
|
2020-05-03 18:47:21 +02:00
|
|
|
|
|
|
|
info "Copying templates to home folder..." &&
|
2020-05-02 13:15:15 +02:00
|
|
|
cp -rfv "$TEMPLATE_PATH/." "$HOME" || error "Copy templates failed."
|
2020-05-03 18:47:21 +02:00
|
|
|
|
|
|
|
info "Update packages..." &&
|
2020-05-02 13:15:15 +02:00
|
|
|
sudo pacman -Syyu || error "Package syncronisation failed."
|
2020-05-03 18:47:21 +02:00
|
|
|
|
2020-05-06 12:11:15 +02:00
|
|
|
pacman_packages="$(get_packages "general" "client/pacman/general")"
|
|
|
|
info "Synchronizing pacman packages [$pacman_packages]..." &&
|
|
|
|
sudo pacman -S --needed $pacman_packages || error "Syncronisation failed."
|
2020-05-03 21:28:40 +02:00
|
|
|
|
2020-05-06 12:11:15 +02:00
|
|
|
info "Synchronizing yay packages..." &&
|
|
|
|
install_yay_packages_if_needed "$(get_packages "client/yay/general")";
|
2020-05-03 18:47:21 +02:00
|
|
|
|
2019-10-30 10:29:26 +01:00
|
|
|
FSTAB_SWAP_ENTRY="/swapfile none swap defaults 0 0"
|
|
|
|
SWAP_FILE="/swapfile"
|
|
|
|
FSTAB_FILE="/etc/fstab"
|
|
|
|
if grep -q "$FSTAB_SWAP_ENTRY" "$FSTAB_FILE"; then
|
2020-05-02 13:28:03 +02:00
|
|
|
info "Skipping creation of swap partion because entry allready exists in \"$FSTAB_FILE\"!"
|
2019-10-30 10:29:26 +01:00
|
|
|
else
|
2020-05-03 18:47:21 +02:00
|
|
|
info "Creating swap partition..." &&
|
|
|
|
sudo fallocate -l 16G "$SWAP_FILE" &&
|
|
|
|
sudo chmod 600 "$SWAP_FILE" &&
|
|
|
|
sudo mkswap "$SWAP_FILE" &&
|
|
|
|
sudo swapon "$SWAP_FILE" &&
|
|
|
|
sudo sh -c "echo \"$FSTAB_SWAP_ENTRY\">>\"$FSTAB_FILE\"" || error "Creation of swap partition failed."
|
2019-10-30 10:29:26 +01:00
|
|
|
fi
|
2020-05-03 18:47:21 +02:00
|
|
|
|
2020-05-02 13:28:03 +02:00
|
|
|
info "Setup SSH key..."
|
2019-09-30 16:13:26 +02:00
|
|
|
ssh_key_path="$HOME/.ssh/id_rsa"
|
|
|
|
if [ ! -f "$ssh_key_path" ]; then
|
2020-05-02 13:28:03 +02:00
|
|
|
info "SSH key $ssh_key_path doesn't exists!"
|
2019-09-30 16:13:26 +02:00
|
|
|
if [ ! -f "./data$ssh_key_path" ]; then
|
2020-05-03 18:47:21 +02:00
|
|
|
info "Importing ssh key by copying data..." &&
|
|
|
|
bash "$SCRIPT_PATH""/data/export-to-system.sh" || error "Copying failed."
|
2019-09-30 16:13:26 +02:00
|
|
|
else
|
2020-05-03 18:47:21 +02:00
|
|
|
info "Generating ssh key..." &&
|
|
|
|
ssh-keygen -t rsa -b 4096 -C "$USER@$HOSTNAME" || error "Key generation failed."
|
2019-09-30 16:13:26 +02:00
|
|
|
fi
|
|
|
|
fi
|
2020-05-03 20:04:14 +02:00
|
|
|
|
|
|
|
info "Installing nonfree drivers..." &&
|
|
|
|
sudo mhwd -a pci nonfree 0300 || error "Failed."
|
|
|
|
|
|
|
|
info "Setup, configuration and installation of dependencies for installed software..."
|
|
|
|
|
|
|
|
if pacman -Qi "arduino" > /dev/null ; then
|
|
|
|
info "Configurate system for arduino..." &&
|
|
|
|
sudo usermod -a -G uucp "$USER" &&
|
|
|
|
sudo usermod -a -G lock "$USER" || error "Couldn't add \"$USER\" to the relevant groups."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if pacman -Qi "atom" > /dev/null ; then
|
2020-05-05 11:26:35 +02:00
|
|
|
info "Installing atom dependencies..."
|
|
|
|
info "Installing \"apm\" packages..." &&
|
2020-05-04 15:51:50 +02:00
|
|
|
get_packages "client/apm/general" | apm install --verbose -c - || error "Failed."
|
2020-05-05 11:26:35 +02:00
|
|
|
info "Installing \"npm\" packages..." &&
|
2020-05-03 20:04:14 +02:00
|
|
|
sudo npm i -g bash-language-server &&
|
2020-05-05 11:26:35 +02:00
|
|
|
info "Installing \"python\" packages..." &&
|
|
|
|
python -m pip install 'python-language-server[all]' &&
|
|
|
|
info "Installing atom dependencies was successfull."|| error " Installing atom dependencies failed."
|
2019-11-21 15:16:46 +01:00
|
|
|
fi
|
2020-05-03 18:47:21 +02:00
|
|
|
|
2020-05-03 20:04:14 +02:00
|
|
|
if pacman -Qi "docker" > /dev/null ; then
|
|
|
|
info "Setting up docker..." &&
|
|
|
|
info "Add current user \"$USER\" to user group docker..." &&
|
2020-05-05 11:26:35 +02:00
|
|
|
sudo usermod -a -G docker "$USER" || error "Failed to add user."
|
2020-05-05 12:34:47 +02:00
|
|
|
info "Restarting docker service..." &&
|
|
|
|
sudo systemctl restart docker &&
|
|
|
|
info "Disable and stop docker service..." &&
|
|
|
|
sudo systemctl disable --now docker || error "\"systemctl\" produced an error."
|
2020-05-05 11:26:35 +02:00
|
|
|
info "For performance reasons docker is not enabled. Start docker by executing \"sudo systemctl restart docker\" when you need it."
|
2020-04-16 19:27:14 +02:00
|
|
|
fi
|
2020-05-02 14:27:57 +02:00
|
|
|
|
2020-05-06 09:25:53 +02:00
|
|
|
if [ ! "$(pacman -Qi "virtualbox")" ] ; then
|
2020-05-03 20:04:14 +02:00
|
|
|
info "Setting up virtualbox..." &&
|
2020-05-06 09:25:53 +02:00
|
|
|
pamac install virtualbox "$(pacman -Qsq "^linux" | grep "^linux[0-9]*[-rt]*$" | awk '{print $1"-virtualbox-host-modules"}' ORS=' ')" &&
|
2020-05-03 20:04:14 +02:00
|
|
|
sudo vboxreload &&
|
|
|
|
pamac build virtualbox-ext-oracle &&
|
|
|
|
sudo gpasswd -a "$USER" vboxusers || error "Failed."
|
|
|
|
info "Keep in mind to install the guest additions in the virtualized system. See https://wiki.manjaro.org/index.php?title=VirtualBox"
|
2019-12-16 21:38:31 +01:00
|
|
|
fi
|
2020-05-03 20:04:14 +02:00
|
|
|
|
2019-12-16 21:38:31 +01:00
|
|
|
if [ "$XDG_SESSION_TYPE" == "x11" ]; then
|
2020-05-03 20:04:14 +02:00
|
|
|
info "Synchronizing xserver tools..." &&
|
|
|
|
sudo pacman --needed -S xbindkeys &&
|
|
|
|
xbindkeys --poll-rc || error "Failed."
|
2019-12-16 21:38:31 +01:00
|
|
|
fi
|
2020-05-03 20:04:14 +02:00
|
|
|
|
2020-05-03 21:53:48 +02:00
|
|
|
install_gnome_extension(){
|
2020-05-04 15:51:50 +02:00
|
|
|
info "Install GNOME extension \"$1\"..."
|
|
|
|
extension_folder="$HOME/.local/share/gnome-shell/extensions/$1/"
|
2020-05-04 15:01:36 +02:00
|
|
|
if [ -d "$extension_folder" ];
|
|
|
|
then
|
|
|
|
if [ -d "$extension_folder"".git" ];
|
|
|
|
then
|
2020-05-04 15:51:50 +02:00
|
|
|
warning "Found a .git repository didn't expect to find this here." &&
|
2020-05-04 15:01:36 +02:00
|
|
|
info "Pulling changes from git..." &&
|
|
|
|
(cd "$extension_folder" && git pull) || error "Failed."
|
|
|
|
else
|
|
|
|
info "No git repository. Extension will not be updated."
|
|
|
|
fi
|
|
|
|
else
|
2020-05-04 15:51:50 +02:00
|
|
|
info "Install..." &&
|
2020-05-06 08:59:48 +02:00
|
|
|
git clone "$2" "$extension_folder" || error "Failed."
|
2020-05-03 21:53:48 +02:00
|
|
|
fi
|
2020-05-04 15:51:50 +02:00
|
|
|
|
|
|
|
if [ -f "$extension_folder""Makefile" ];
|
|
|
|
then
|
|
|
|
|
|
|
|
tmp_extension_folder="/tmp/$1"
|
2020-05-06 08:59:48 +02:00
|
|
|
mv "$extension_folder" "$tmp_extension_folder"
|
2020-05-04 15:51:50 +02:00
|
|
|
info "Compilling extension.."
|
2020-05-06 08:59:48 +02:00
|
|
|
(cd "$tmp_extension_folder" && make install) || error "Compilation with failed."
|
2020-05-04 15:51:50 +02:00
|
|
|
|
|
|
|
info "Cleaning up tmp-extension folder..."&&
|
2020-05-06 08:59:48 +02:00
|
|
|
rm -fr "$tmp_extension_folder" || error "Failed."
|
2020-05-04 15:51:50 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
info "No Makefile found. Skipping compilation..."
|
|
|
|
fi
|
|
|
|
|
2020-05-04 15:01:36 +02:00
|
|
|
info "Activating GNOME extension \"$1\"..." &&
|
2020-05-06 08:59:48 +02:00
|
|
|
gnome-extensions enable "$1" || error "Failed."
|
2020-05-03 21:53:48 +02:00
|
|
|
}
|
|
|
|
|
2019-12-16 21:38:31 +01:00
|
|
|
if [ "$DESKTOP_SESSION" == "gnome" ]; then
|
2020-05-03 20:04:14 +02:00
|
|
|
info "Synchronizing gnome tools..." &&
|
|
|
|
sudo pacman --needed -S gnome-shell-extensions gnome-terminal &&
|
|
|
|
info "Setting up gnome dash favourites..." &&
|
2019-12-16 21:38:31 +01:00
|
|
|
gsettings set org.gnome.shell favorite-apps "['org.gnome.Nautilus.desktop',
|
|
|
|
'org.gnome.Terminal.desktop',
|
|
|
|
'org.keepassxc.KeePassXC.desktop',
|
|
|
|
'firefox.desktop',
|
|
|
|
'chromium.desktop',
|
|
|
|
'atom.desktop',
|
|
|
|
'arduino.desktop',
|
|
|
|
'eclipse.desktop',
|
|
|
|
'vlc.desktop',
|
|
|
|
'gimp.desktop',
|
|
|
|
'blender.desktop',
|
|
|
|
'rhythmbox.desktop',
|
2020-05-03 21:53:48 +02:00
|
|
|
'org.gnome.Screenshot.desktop']" || error "Failed."
|
|
|
|
|
2020-05-03 20:04:14 +02:00
|
|
|
info "Install GNOME extensions..." &&
|
2020-05-03 21:53:48 +02:00
|
|
|
install_gnome_extension "nasa_apod@elinvention.ovh" "https://github.com/Elinvention/gnome-shell-extension-nasa-apod.git"
|
|
|
|
install_gnome_extension "dash-to-panel@jderose9.github.com" "https://github.com/home-sweet-gnome/dash-to-panel"
|
|
|
|
info "Deactivating \"Dash to Dock\"..." &&
|
2020-05-03 20:04:14 +02:00
|
|
|
gnome-extensions disable dash-to-dock@micxgx.gmail.com || error "Failed."
|
2020-05-04 15:01:36 +02:00
|
|
|
|
2019-12-16 21:38:31 +01:00
|
|
|
fi
|
2020-05-03 20:04:14 +02:00
|
|
|
|
2020-05-06 12:11:15 +02:00
|
|
|
info "Testing if computer has more then 4GB of memory to process games..." &&
|
|
|
|
if [ "$(echo "( $(grep MemTotal /proc/meminfo | awk '{print $2}') / (1024 ^ 2) ) > 4" | bc -l)" = "1" ];
|
|
|
|
then
|
|
|
|
pacman_game_packages="$(get_packages "client/pacman/games")"
|
|
|
|
yay_game_packages="$(get_packages "client/yay/games")"
|
|
|
|
success "Ok" &&
|
|
|
|
info "Installing games..." &&
|
|
|
|
info "Installing yay packages [ $yay_game_packages ]..." &&
|
|
|
|
install_yay_packages_if_needed "$yay_game_packages" &&
|
|
|
|
info "Installing pacman packages [ $pacman_game_packages ]..." &&
|
|
|
|
sudo pacman -S --needed "$(get_packages "client/pacman/games")" || error "Syncronisation failed.";
|
|
|
|
else
|
|
|
|
warning "Not enough ressources." &&
|
|
|
|
info "Skipping game installation";
|
|
|
|
fi
|
|
|
|
|
2020-05-04 15:01:36 +02:00
|
|
|
info "Removing all software from user startup..."
|
|
|
|
autostart_folder="$HOME/.config/autostart/"
|
2020-05-06 09:25:53 +02:00
|
|
|
if [ "$(ls -A "$autostart_folder")" ]
|
2020-05-04 15:01:36 +02:00
|
|
|
then
|
|
|
|
(rm "$autostart_folder"* && info "Startups had been removed.") || error "Removing startup software failed."
|
|
|
|
else
|
|
|
|
info "No startup entries found. Skipped removing."
|
|
|
|
fi
|
2020-05-03 20:04:14 +02:00
|
|
|
|
2020-05-07 14:34:44 +02:00
|
|
|
info "Showing the installed Java versions..." &&
|
|
|
|
archlinux-java status &&
|
|
|
|
info "Keep in mind to set the right Java-Version if it's neccessary." ||
|
|
|
|
error "Failed."
|
|
|
|
|
2020-05-04 15:51:50 +02:00
|
|
|
info "Please restart the computer, so that all updates get applied."
|
2020-05-03 20:04:14 +02:00
|
|
|
success "Setup finished successfully :)" && exit 0
|