2024-06-19 15:40:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
csproj="SchneiderMeterDriver.csproj"
|
|
|
|
exe="SchneiderMeterDriver"
|
2024-06-26 13:53:19 +00:00
|
|
|
remote="10.2.4.114"
|
2024-06-19 15:40:33 +00:00
|
|
|
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
|
|
|
|
|
2024-07-01 13:12:12 +00:00
|
|
|
# Wait a bit for the symlink to be recognized
|
2024-06-19 15:40:33 +00:00
|
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# Start the service
|
|
|
|
start SchneiderMeterDriver
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo "Deployment and service setup completed successfully."
|