update firmware on backend

This commit is contained in:
Noe 2024-03-19 17:45:52 +01:00
parent 2851e34e47
commit b1cb60549f
2 changed files with 4 additions and 5 deletions

View File

@ -518,7 +518,6 @@ public class Controller : ControllerBase
{ {
var session = Db.GetSession(authToken); var session = Db.GetSession(authToken);
var installationToUpdate = Db.GetInstallationById(installationId); var installationToUpdate = Db.GetInstallationById(installationId);
Console.WriteLine("Inside firmware function controller,batteryNode="+batteryNode+ "and installation is "+installationId);
if (installationToUpdate != null) if (installationToUpdate != null)
{ {

View File

@ -70,23 +70,23 @@ public static class SessionMethods
public static async Task RunScriptInBackground(this Session? session, String vpnIp, Int64 batteryNode) public static async Task RunScriptInBackground(this Session? session, String vpnIp, Int64 batteryNode)
{ {
Console.WriteLine("11111111111111111111111111111111111111111111111111111111111111"); Console.WriteLine("-----------------------------------Start updating firmware-----------------------------------");
string scriptPath = "/home/ubuntu/backend/uploadBatteryFw/update_firmware.sh"; string scriptPath = "/home/ubuntu/backend/uploadBatteryFw/update_firmware.sh";
await Task.Run(() => await Task.Run(() =>
{ {
Process process = new Process(); Process process = new Process();
process.StartInfo.FileName = "/bin/bash"; process.StartInfo.FileName = "/bin/bash";
process.StartInfo.Arguments = $"{scriptPath} {vpnIp} {batteryNode}"; // Pass batteryNode as argument to the script process.StartInfo.Arguments = $"{scriptPath} {vpnIp} {batteryNode}";
process.StartInfo.UseShellExecute = false; process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardOutput = true;
process.Start(); process.Start();
string output = process.StandardOutput.ReadToEnd(); string output = process.StandardOutput.ReadToEnd();
process.WaitForExit(); // This can be removed if you don't need to wait for the process to finish process.WaitForExit();
Console.WriteLine(output); Console.WriteLine(output);
}); });
Console.WriteLine("222222222222222222222222222222222222222222222222222222222222222"); Console.WriteLine("-----------------------------------Stop updating firmware-----------------------------------");
} }