Add installation/installWithoutPostgress.sh
This commit is contained in:
parent
b92228e9ff
commit
f55ee678e3
52
installation/installWithoutPostgress.sh
Normal file
52
installation/installWithoutPostgress.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Updating system packages..."
|
||||||
|
sudo apt update && sudo apt upgrade -y
|
||||||
|
|
||||||
|
echo "Installing prerequisites..."
|
||||||
|
sudo apt install -y apt-transport-https ca-certificates gnupg wget
|
||||||
|
|
||||||
|
echo "Adding Microsoft package repository for .NET 8..."
|
||||||
|
wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
||||||
|
sudo dpkg -i packages-microsoft-prod.deb
|
||||||
|
sudo apt update
|
||||||
|
|
||||||
|
echo "Installing .NET 8 SDK and runtime..."
|
||||||
|
sudo apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0
|
||||||
|
|
||||||
|
APP_DIR=/opt/api
|
||||||
|
echo "Creating application directory $APP_DIR..."
|
||||||
|
sudo mkdir -p $APP_DIR
|
||||||
|
sudo chown $(whoami):$(whoami) $APP_DIR
|
||||||
|
|
||||||
|
echo "Please copy your published .NET API files (DLL, appsettings.json) into $APP_DIR before continuing."
|
||||||
|
read -p "Press Enter to continue after copying files..."
|
||||||
|
|
||||||
|
echo "Creating systemd service file..."
|
||||||
|
sudo tee /etc/systemd/system/mydotnetapi.service > /dev/null <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=My .NET Web API
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=$APP_DIR
|
||||||
|
ExecStart=/usr/bin/dotnet $APP_DIR/Taekwondo.WebApi.dll
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
SyslogIdentifier=dotnet-api
|
||||||
|
User=$(whoami)
|
||||||
|
Environment=ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Reloading systemd daemon and starting mydotnetapi service..."
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable mydotnetapi
|
||||||
|
sudo systemctl start mydotnetapi
|
||||||
|
|
||||||
|
echo "Setup complete."
|
||||||
|
echo "Verify the service status with 'sudo systemctl status mydotnetapi'"
|
||||||
|
echo "Test your API endpoints with curl or Postman."
|
||||||
Loading…
x
Reference in New Issue
Block a user