2022-04-04 18:06:01 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-12-04 18:54:57 +01:00
|
|
|
# This is part of WHY2
|
|
|
|
# Copyright (C) 2022 Václav Šmejkal
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2022-04-04 18:06:01 +02:00
|
|
|
# Get linux distro
|
2025-01-25 10:44:16 +01:00
|
|
|
DISTRO=$(grep ^ID_LIKE= /etc/os-release | cut -d= -f2 | tr -d '"')
|
|
|
|
if [ -e $DISTRO ]
|
|
|
|
then
|
|
|
|
DISTRO=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
|
|
|
|
fi
|
2022-04-04 18:06:01 +02:00
|
|
|
|
2025-01-25 10:44:16 +01:00
|
|
|
if [[ $(id -u) != "0" ]] && [[ $1 != "force" ]]
|
|
|
|
then
|
2022-04-27 18:28:42 +02:00
|
|
|
echo "You must run this script as root! (To skip this, run with 'force' arg: \"./configure.sh force\")"
|
2022-04-27 18:47:57 +02:00
|
|
|
exit 1
|
2022-04-27 18:28:42 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-24 11:37:43 +01:00
|
|
|
COMMON="gcc make tmux curl"
|
2025-01-29 16:35:45 +01:00
|
|
|
ARCH_GENTOO_COMMON="$COMMON json-c libgit2 openssl"
|
2023-08-27 12:26:50 +02:00
|
|
|
|
2022-04-04 18:06:01 +02:00
|
|
|
# Get COMMAND
|
2025-01-25 10:44:16 +01:00
|
|
|
if [[ $DISTRO == "arch" ]]
|
|
|
|
then
|
2024-01-24 12:07:46 +01:00
|
|
|
COMMAND="pacman -S --needed --noconfirm $ARCH_GENTOO_COMMON"
|
2025-01-25 10:50:52 +01:00
|
|
|
elif [[ $DISTRO == "debian" ]]
|
2025-01-25 10:44:16 +01:00
|
|
|
then
|
2025-01-29 16:35:45 +01:00
|
|
|
COMMAND="apt-get install -y $COMMON libjson-c-dev libcurl4-openssl-dev libgit2-dev libssl-dev"
|
2025-01-25 10:50:52 +01:00
|
|
|
elif [[ $DISTRO == "gentoo" ]]
|
2025-01-25 10:44:16 +01:00
|
|
|
then
|
2024-01-24 12:07:46 +01:00
|
|
|
COMMAND="emerge -vn $ARCH_GENTOO_COMMON"
|
2023-10-04 09:57:51 +02:00
|
|
|
|
|
|
|
# Add
|
|
|
|
echo "LDPATH=/usr/lib/libwhy2.so" > /etc/env.d/99why2-core
|
|
|
|
echo "LDPATH=/usr/lib/libwhy2-logger.so" > /etc/env.d/99why2-logger
|
|
|
|
echo "LDPATH=/usr/lib/libwhy2-chat.so" > /etc/env.d/99why2-chat
|
2024-01-25 20:50:29 +01:00
|
|
|
echo "LDPATH=/usr/lib/libwhy2-chat-config.so" > /etc/env.d/99why2-chat-config
|
2023-10-04 09:57:51 +02:00
|
|
|
env-update && source /etc/profile
|
2024-02-23 09:52:33 +01:00
|
|
|
else # 'Unsupported' distro
|
|
|
|
IFS=' ' read -r -a dependency_array <<< "$ARCH_GENTOO_COMMON" # Split into dependency_array
|
|
|
|
|
|
|
|
echo -e "It seems you are using unsupported distribution...\nDon't worry, just install these dependencies:\n"
|
|
|
|
|
|
|
|
for dependency in "${dependency_array[@]}" # Iter
|
|
|
|
do
|
|
|
|
echo "$dependency"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo -e "\nand you'll be fine."
|
|
|
|
|
2022-04-27 18:28:42 +02:00
|
|
|
exit
|
2022-04-04 18:06:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Execute COMMAND
|
2022-04-06 19:05:21 +02:00
|
|
|
$COMMAND
|
2024-01-23 21:38:03 +01:00
|
|
|
|
2024-01-24 11:37:43 +01:00
|
|
|
# Install Rust
|
2025-01-25 10:44:16 +01:00
|
|
|
if ! [ -x "$(command -v cargo)" ]
|
|
|
|
then
|
2024-01-24 11:37:43 +01:00
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Install Rust and components
|
2024-04-13 17:19:07 +02:00
|
|
|
source "$HOME/.cargo/env"
|
2024-01-24 11:37:43 +01:00
|
|
|
fi
|