|
@@ -197,98 +197,64 @@ static int KickoffSpRestartInner(int options)
|
|
|
|
|
|
#else
|
|
|
|
|
|
-#if 0
|
|
|
-
|
|
|
- if (env && env->cfg && env->cfg->args && env->cfg->args->program) {
|
|
|
- char app[MAX_PATH] = { '\0' };
|
|
|
- tk_process_t* process = NULL;
|
|
|
- tk_process_option_t option;
|
|
|
- if (env->cfg->args->arguments == NULL) {
|
|
|
- sprintf(app, "%s -Rwait", env->cfg->args->program);
|
|
|
- } else {
|
|
|
- sprintf(app, "%s %s -Rwait", env->cfg->args->program, env->cfg->args->arguments);
|
|
|
- }
|
|
|
- option.exit_cb = NULL;
|
|
|
- option.file = NULL;
|
|
|
- option.flags = 0;
|
|
|
- option.params = app;
|
|
|
- char szldPath[1024] = {'\0'};
|
|
|
- size_t szldLen = 1023;
|
|
|
- const int ldRet = toolkit_getenv("LD_LIBRARY_PATH", szldPath, &szldLen);
|
|
|
- if (ldRet == 0) {
|
|
|
- toolkit_unsetenv("LD_LIBRARY_PATH");
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("GetEnv of LD_LIBRARY_PATH failed: %s", toolkit_strerror(ldRet));
|
|
|
- }
|
|
|
-
|
|
|
- if (0 == process_spawn(&option, &process)) {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create new process succ pid=%u! %s", process->pid, app);
|
|
|
- FREE(process);
|
|
|
- return 0;
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("create new process failed! %s", app);
|
|
|
- if (ldRet == 0) {
|
|
|
- toolkit_setenv("LD_LIBRARY_PATH", szldPath);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Env has no any program startup information!");
|
|
|
- }
|
|
|
-
|
|
|
-#else
|
|
|
-
|
|
|
- sp_env_t* env = sp_get_env();
|
|
|
- if (env && env->dir) {
|
|
|
- tk_process_t* process = NULL;
|
|
|
- tk_process_option_t option;
|
|
|
+ sp_env_t* env = sp_get_env();
|
|
|
+ if (env && env->dir) {
|
|
|
+ tk_process_t* process = NULL;
|
|
|
+ tk_process_option_t option;
|
|
|
char app[MAX_PATH] = { '\0' };
|
|
|
- char shell_scripts[MAX_PATH] = { '\0' };
|
|
|
- sprintf(shell_scripts, "%s/%s", env->dir->root_ver_path, "spexplorer.sh");
|
|
|
+ char shell_scripts[MAX_PATH] = { '\0' };
|
|
|
+ sprintf(shell_scripts, "%s/%s", env->dir->root_ver_path, "sudo_spexplorer.sh");
|
|
|
if (options == RESTART_FRAMEWORK) {
|
|
|
- if (env && env->cfg && env->cfg->args && env->cfg->args->arguments) {
|
|
|
- sprintf(app, "%s %s -Rwait", shell_scripts, env->cfg->args->arguments);
|
|
|
- } else {
|
|
|
- sprintf(app, "%s -Rwait", shell_scripts);
|
|
|
- }
|
|
|
- } else if(options == SHUTDOWN_FRAMEWORK) {
|
|
|
+ if (env && env->cfg && env->cfg->args && env->cfg->args->arguments) {
|
|
|
+ sprintf(app, "%s %s -Rwait", shell_scripts, env->cfg->args->arguments);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sprintf(app, "%s -Rwait", shell_scripts);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (options == SHUTDOWN_FRAMEWORK) {
|
|
|
sprintf(app, "%s --shutdown", shell_scripts);
|
|
|
- } else if (options == RESTART_PC) {
|
|
|
+ }
|
|
|
+ else if (options == RESTART_PC) {
|
|
|
sprintf(app, "%s --reboot", shell_scripts);
|
|
|
- } else if (options == SHUTDOWN_PC) {
|
|
|
+ }
|
|
|
+ else if (options == SHUTDOWN_PC) {
|
|
|
sprintf(app, "%s --systemoff", shell_scripts);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("invalid restart pararm: %d", options);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- option.exit_cb = NULL;
|
|
|
- option.file = NULL;
|
|
|
- option.flags = 0;
|
|
|
- option.params = app;
|
|
|
- char szldPath[1024] = { '\0' };
|
|
|
- size_t szldLen = 1023;
|
|
|
- const int ldRet = toolkit_getenv("LD_LIBRARY_PATH", szldPath, &szldLen);
|
|
|
- if (ldRet == 0) {
|
|
|
+ option.exit_cb = NULL;
|
|
|
+ option.file = NULL;
|
|
|
+ option.flags = 0;
|
|
|
+ option.params = app;
|
|
|
+ char szldPath[1024] = { '\0' };
|
|
|
+ size_t szldLen = 1023;
|
|
|
+ const int ldRet = toolkit_getenv("LD_LIBRARY_PATH", szldPath, &szldLen);
|
|
|
+ if (ldRet == 0) {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get library path: %s", szldPath);
|
|
|
- toolkit_unsetenv("LD_LIBRARY_PATH");
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetEnv of LD_LIBRARY_PATH failed: %s", toolkit_strerror(ldRet));
|
|
|
- }
|
|
|
- if (0 == process_spawn(&option, &process)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create new process succ pid=%u! %s", process->pid, app);
|
|
|
- FREE(process);
|
|
|
- return 0;
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("create new process failed! %s", app);
|
|
|
- if (ldRet == 0) {
|
|
|
- toolkit_setenv("LD_LIBRARY_PATH", szldPath);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Env has no any dir information!");
|
|
|
- }
|
|
|
-
|
|
|
-#endif
|
|
|
+ toolkit_unsetenv("LD_LIBRARY_PATH");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetEnv of LD_LIBRARY_PATH failed: %s", toolkit_strerror(ldRet));
|
|
|
+ }
|
|
|
+ if (0 == process_spawn(&option, &process)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create new process succ pid=%u! %s", process->pid, app);
|
|
|
+ FREE(process);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("create new process failed! %s", app);
|
|
|
+ if (ldRet == 0) {
|
|
|
+ toolkit_setenv("LD_LIBRARY_PATH", szldPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Env has no any dir information!");
|
|
|
+ }
|
|
|
|
|
|
return -1;
|
|
|
|