about summary refs log tree commit diff
path: root/install.sh
blob: e849263f2f93eed34cfcdc5ffa5076833c0698d5 (plain) (blame)
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
#! /usr/bin/env sh

if ! command -v dotnet &> /dev/null
then
    echo "'dotnet' could not be found, please refer to your distribution's documentation to install it."
    echo "Hint: NixOS: nix shell nixpkgs#dotnet-sdk_9"
    echo "Hint: Fedora: sudo dnf5 install dotnet-sdk-9.0"
    exit1
fi

if [ ! -f "MatrixAntiDmSpam.sln" ]; then
    echo "Please run this script from the root of the repository."
    exit 1
fi

cd MatrixAntiDmSpam || exit 1
echo "Elevation required to install the service!"

if [ ! -d "/opt/MatrixAntiDmSpam" ]; then
    echo "Creating directory /opt/MatrixAntiDmSpam"
    sudo mkdir -p /opt/MatrixAntiDmSpam
fi

# Ensure working directory is clean
sudo rm -rf /opt/MatrixAntiDmSpam
rm -rf bin/target

# Build
dotnet publish -c Release -o bin/target -p:PublishSingleFile=false

# Install
rm -rv bin/target/appsettings*.json
sudo rsync -raP --delete-during bin/target/ /opt/MatrixAntiDmSpam