Innovenergy_trunk/csharp/App/SchneiderMeterDriver/deploy.sh

62 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
csproj="SchneiderMeterDriver.csproj"
exe="SchneiderMeterDriver"
remote="10.2.4.114"
platform="linux-arm"
netVersion="net6.0"
config="Release"
host="root@$remote"
dir="/opt/innovenergy/$exe"
log_dir="/var/log/SchneiderMeterDriver"
set -e
# Publish the project locally
dotnet publish "$csproj" -c $config -r $platform -p:SuppressTrimmAnalysisWarnings=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false --self-contained true
# Sync the published files to the remote server
rsync -av "bin/$config/$netVersion/$platform/publish/" "$host:$dir"
# Execute commands on the remote server
ssh "$host" << 'EOF'
set -e
# Remount the root filesystem with read and write permissions
mount -o remount,rw /
# Create service and log directories
mkdir -p /opt/innovenergy/SchneiderMeterDriver/service
mkdir -p /opt/innovenergy/SchneiderMeterDriver/service/log
mkdir -p /var/log/SchneiderMeterDriver
# Create the service run script
cat << 'EOL' > /opt/innovenergy/SchneiderMeterDriver/service/run
#!/bin/sh
exec 2>&1
exec softlimit -d 200000000 -s 2000000 -a 200000000 /opt/innovenergy/SchneiderMeterDriver/SchniederDriver
EOL
chmod +x /opt/innovenergy/SchneiderMeterDriver/service/run
# Create the log run script
cat << 'EOL' > /opt/innovenergy/SchneiderMeterDriver/service/log/run
#!/bin/sh
exec 2>&1
exec multilog t s25000 n4 /var/log/SchneiderMeterDriver
EOL
chmod +x /opt/innovenergy/SchneiderMeterDriver/service/log/run
# Create the symbolic link for the service
ln -sf /opt/innovenergy/SchneiderMeterDriver/service /service/SchneiderMeterDriver
# Wait a bit for the symlink to be recognized
sleep 2
# Start the service
start SchneiderMeterDriver
EOF
echo "Deployment and service setup completed successfully."