| #include "gsw_sys_interface.h" |
| |
| #define LOG_LEVLE_CONFIG_FILE "/etc/telinit" |
| |
| int gsw_sys_svr_ftp_start(const char *cfg) |
| { |
| int ret = GSW_HAL_SUCCESS; |
| char command[128] = "vsftpd &"; |
| if(NULL == cfg) |
| { |
| ret = system(command); |
| } |
| else |
| { |
| sprintf(command, "vsftpd %s &", cfg); |
| ret = system(command); |
| } |
| |
| if(ret != 0) { |
| printf("command execution failed command:%s.\n", command); |
| return GSW_HAL_NORMAL_FAIL; |
| } |
| |
| return GSW_HAL_SUCCESS; |
| } |
| |
| int gsw_sys_svr_ftp_stop() |
| { |
| int ret = GSW_HAL_SUCCESS; |
| char command[] = "killall -TERM vsftpd"; |
| |
| ret = system(command); |
| if(ret != 0) |
| { |
| printf("command execution failed command:%s.\n", command); |
| return GSW_HAL_NORMAL_FAIL; |
| } |
| |
| return GSW_HAL_SUCCESS; |
| |
| } |
| |
| int gsw_sys_svr_ssh_start(const char *cfg) |
| { |
| int ret= GSW_HAL_SUCCESS; |
| char command[128] = "/usr/sbin/dropbear &"; |
| |
| if(NULL == cfg) |
| { |
| ret = system(command); |
| } |
| else |
| { |
| sprintf(command, "/usr/sbin/dropbear %s &", cfg); |
| ret = system(command); |
| } |
| |
| if(ret != 0) |
| { |
| printf("command execution failed command:%s.\n", command); |
| return GSW_HAL_NORMAL_FAIL; |
| |
| } |
| return GSW_HAL_SUCCESS; |
| } |
| |
| int gsw_sys_svr_ssh_stop() |
| { |
| int ret = GSW_HAL_SUCCESS; |
| char command[] = "killall dropbear"; |
| |
| ret = system(command); |
| if(ret != 0) |
| { |
| printf("command execution failed command:%s.\n", command); |
| return GSW_HAL_NORMAL_FAIL; |
| } |
| |
| return GSW_HAL_SUCCESS; |
| } |
| |
| int gsw_sys_svr_syslog_restart(const char *log_lvl) |
| { |
| (void)log_lvl; |
| char command[256] = {0}; |
| |
| snprintf(command, sizeof(command), |
| "grep -q 'setprop sys.default.loglevel' %s", LOG_LEVLE_CONFIG_FILE); |
| |
| int exists = system(command); |
| if (exists != 0) { |
| printf("config option not exist.\n"); |
| return GSW_HAL_NORMAL_FAIL; |
| } |
| |
| if(1 == strlen(log_lvl)) |
| { |
| snprintf(command, sizeof(command), |
| "sed -i 's/\\(setprop sys.default.loglevel \\)\\S*/\\1%s/' %s", |
| log_lvl, LOG_LEVLE_CONFIG_FILE); |
| |
| int result = system(command); |
| if (result != 0) { |
| printf("command execution failed.\n"); |
| return GSW_HAL_SUCCESS; |
| } |
| |
| } |
| |
| return GSW_HAL_NORMAL_FAIL; |
| } |
| |
| |