-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-linux.sh
More file actions
76 lines (65 loc) · 2.35 KB
/
setup-linux.sh
File metadata and controls
76 lines (65 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run with sudo"
exit 1
fi
echo "Installing prerequisites..."
# Detect OS
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
fi
# Update packages
if [[ "$OS" == *"Ubuntu"* ]] || [[ "$OS" == *"Debian"* ]]; then
apt-get update -qq
PKG="apt-get"
elif [[ "$OS" == *"Fedora"* ]] || [[ "$OS" == *"Red Hat"* ]] || [[ "$OS" == *"CentOS"* ]]; then
dnf update -y -q
PKG="dnf"
else
echo "Unsupported OS"
exit 1
fi
# Install .NET 8 SDK
if ! command -v dotnet &> /dev/null; then
if [[ "$OS" == *"Ubuntu"* ]] || [[ "$OS" == *"Debian"* ]]; then
wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt-get update -qq
apt-get install -y -qq dotnet-sdk-8.0
elif [[ "$OS" == *"Fedora"* ]]; then
dnf install -y -q dotnet-sdk-8.0
fi
fi
# Docker
read -p "Install Docker? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [[ "$OS" == *"Ubuntu"* ]] || [[ "$OS" == *"Debian"* ]]; then
apt-get install -y -qq ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update -qq
apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin
elif [[ "$OS" == *"Fedora"* ]]; then
dnf -y -q install dnf-plugins-core
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
dnf install -y -q docker-ce docker-ce-cli containerd.io docker-compose-plugin
fi
systemctl start docker
systemctl enable docker
fi
# Install EF tools
dotnet tool install --global dotnet-ef
export PATH="$PATH:$HOME/.dotnet/tools"
echo 'export PATH="$PATH:$HOME/.dotnet/tools"' >> ~/.bashrc
# Restore project
if [ -f "VALHÄUS.sln" ]; then
dotnet restore VALHÄUS.sln
fi
echo ""
echo "Setup complete!"
echo "Run: dotnet run --project VALHÄUS/VALHAUS.csproj"