WHY2/configure.sh

58 lines
2.0 KiB
Bash
Raw Normal View History

2022-04-04 18:06:01 +02:00
#!/bin/bash
# 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
DISTRO=$(lsb_release -is)
2022-04-27 18:28:42 +02:00
if [[ $(id -u) != "0" ]] && [[ $1 != "force" ]]; then
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
COMMON="gcc make tmux"
2023-10-04 11:00:16 +02:00
ARCH_GENTOO_COMMON="$COMMON json-c curl libgit2"
2023-08-27 12:26:50 +02:00
2022-04-04 18:06:01 +02:00
# Get COMMAND
if [[ $DISTRO == "Arch" ]]; then
2023-10-04 11:00:16 +02:00
COMMAND="pacman -S --needed --noconfirm $ARCH_GENTOO_COMMON libyaml"
2022-04-04 18:06:01 +02:00
elif [[ $DISTRO == "Ubuntu" ]] || [[ $DISTRO == "Debian" ]]; then
COMMAND="apt install -y $COMMON libjson-c-dev libcurl4-nss-dev libgit2-dev libyaml-dev"
2023-10-04 09:57:51 +02:00
elif [[ $DISTRO == "Gentoo" ]]; then
2023-10-04 11:00:16 +02:00
COMMAND="emerge -vn $ARCH_GENTOO_COMMON dev-libs/libyaml"
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
env-update && source /etc/profile
2022-04-04 18:06:01 +02:00
else
# 'Unsupported' distro
2023-08-27 12:26:50 +02:00
echo "It seems you are using unsupported distribution... Don't worry, just install 'gcc', 'json-c', 'curl', 'libgit2', 'tmux', 'libyaml' and 'make' and 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
# Install Rust
if ! [ -x "$(command -v cargo)" ]; then
2024-01-23 21:46:20 +01:00
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
# Config Rust version
rustup default stable