Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/integrate on off boarding scripts #14

Merged
merged 11 commits into from
Dec 21, 2023

Conversation

ionut-cmd
Copy link
Contributor

Integrated onboarding script and fixed some minor issues. - not tested - do not merge please

// Set the response code based on script_result
int response_code = (script_result == 0) ? MHD_HTTP_OK : MHD_HTTP_INTERNAL_SERVER_ERROR;
ret = MHD_queue_response(connection, response_code, response);
const char *output_file = "/opt/demo-server/html/log_file.txt";
Copy link
Contributor

@mereacre mereacre Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the constant string as a #define in a config.h file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem 👍 . Sorry for leaving paths like that.

ret = MHD_queue_response(connection, response_code, response);
const char *output_file = "/opt/demo-server/html/log_file.txt";
// Execute the onboarding script
int script_result = execute_script_async("/opt/demo-server/bash-scripts/onboard.sh", output_file);
Copy link
Contributor

@mereacre mereacre Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same with the string "/opt...". Needs to be defined as a constant in config.h

@@ -109,7 +109,15 @@ static enum MHD_Result answer_to_connection(void *cls, struct MHD_Connection *co

if (strcmp(url, "/onboard") == 0) {
fprintf(stdout, "Received onboard request\n");
execute_script("/opt/demo-server/bash-scripts/onboard.sh");
int script_result = execute_script("/opt/demo-server/bash-scripts/onboard.sh");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this needs to be in the config.h

@mereacre
Copy link
Contributor

Ideally the "opt" paths need be created by the debian installer in the process of installing the package.

@ionut-cmd
Copy link
Contributor Author

Ideally the "opt" paths need be created by the debian installer in the process of installing the package.

Added "opt" path creation to postinst file.

@ionut-cmd
Copy link
Contributor Author

ionut-cmd commented Dec 15, 2023

I have opened the http port 8082 on the nqm-perfect-pi so you can test the web app. You can click this https://openport.io/l/49503/fuiOyLGf0OX79Z7n to activate the connection and then this http://openport.io:49503/ to access the app. Please do let me know if anything is wrong or needs changing.

For displaying the logs I have used a simple file, so may not be exactly real time logs. I think is quite a complex task to achieve real-time displaying using libmicrohttpd.

@ionut-cmd ionut-cmd merged commit 1b82d55 into main Dec 21, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants