From 5e843462eb0c5636f506ca6fcd402686ac68c47b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 11 May 2015 14:28:28 +0300 Subject: move service mgmt utils to libservice/utils/ --- utils/libservice/CMakeLists.txt | 1 + utils/libservice/utils/CMakeLists.txt | 11 ++++++++++ utils/libservice/utils/install_service.cpp | 32 ++++++++++++++++++++++++++++ utils/libservice/utils/start_service.cpp | 32 ++++++++++++++++++++++++++++ utils/libservice/utils/stop_service.cpp | 32 ++++++++++++++++++++++++++++ utils/libservice/utils/uninstall_service.cpp | 32 ++++++++++++++++++++++++++++ 6 files changed, 140 insertions(+) create mode 100644 utils/libservice/utils/CMakeLists.txt create mode 100644 utils/libservice/utils/install_service.cpp create mode 100644 utils/libservice/utils/start_service.cpp create mode 100644 utils/libservice/utils/stop_service.cpp create mode 100644 utils/libservice/utils/uninstall_service.cpp (limited to 'utils/libservice') diff --git a/utils/libservice/CMakeLists.txt b/utils/libservice/CMakeLists.txt index 169a641..ad9e065 100644 --- a/utils/libservice/CMakeLists.txt +++ b/utils/libservice/CMakeLists.txt @@ -6,3 +6,4 @@ add_library(${PROJECT_NAME} ${${PROJECT_NAME}_sources} target_include_directories(${PROJECT_NAME} PUBLIC include) add_subdirectory(test) +add_subdirectory(utils) diff --git a/utils/libservice/utils/CMakeLists.txt b/utils/libservice/utils/CMakeLists.txt new file mode 100644 index 0000000..061ab25 --- /dev/null +++ b/utils/libservice/utils/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(install_service install_service.cpp) +target_link_libraries(install_service libservice) + +add_executable(start_service start_service.cpp) +target_link_libraries(start_service libservice) + +add_executable(stop_service stop_service.cpp) +target_link_libraries(stop_service libservice) + +add_executable(uninstall_service uninstall_service.cpp) +target_link_libraries(uninstall_service libservice) diff --git a/utils/libservice/utils/install_service.cpp b/utils/libservice/utils/install_service.cpp new file mode 100644 index 0000000..fd9e339 --- /dev/null +++ b/utils/libservice/utils/install_service.cpp @@ -0,0 +1,32 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include +#include + +int main(int argc, char* argv[]) +{ + if (argc != 3) + { + std::cout << "Usage: " << argv[0] << " NAME SYS_PATH\n"; + return 1; + } + + try + { + libservice::Service::install(libservice::ServiceManager::open(), argv[1], argv[2]); + } + catch (const std::exception& e) + { + std::cerr << e.what() << "\n"; + return 1; + } + return 0; +} diff --git a/utils/libservice/utils/start_service.cpp b/utils/libservice/utils/start_service.cpp new file mode 100644 index 0000000..09b5b35 --- /dev/null +++ b/utils/libservice/utils/start_service.cpp @@ -0,0 +1,32 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include +#include + +int main(int argc, char* argv[]) +{ + if (argc != 2) + { + std::cout << "Usage: " << argv[0] << " NAME\n"; + return 1; + } + + try + { + libservice::Service::open(libservice::ServiceManager::open(), argv[1]).start(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << "\n"; + return 1; + } + return 0; +} diff --git a/utils/libservice/utils/stop_service.cpp b/utils/libservice/utils/stop_service.cpp new file mode 100644 index 0000000..48b4c92 --- /dev/null +++ b/utils/libservice/utils/stop_service.cpp @@ -0,0 +1,32 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include +#include + +int main(int argc, char* argv[]) +{ + if (argc != 2) + { + std::cout << "Usage: " << argv[0] << " NAME\n"; + return 1; + } + + try + { + libservice::Service::open(libservice::ServiceManager::open(), argv[1]).stop(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << "\n"; + return 1; + } + return 0; +} diff --git a/utils/libservice/utils/uninstall_service.cpp b/utils/libservice/utils/uninstall_service.cpp new file mode 100644 index 0000000..8497fbf --- /dev/null +++ b/utils/libservice/utils/uninstall_service.cpp @@ -0,0 +1,32 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include +#include + +int main(int argc, char* argv[]) +{ + if (argc != 2) + { + std::cout << "Usage: " << argv[0] << " NAME\n"; + return 1; + } + + try + { + libservice::Service::open(libservice::ServiceManager::open(), argv[1]).uninstall(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << "\n"; + return 1; + } + return 0; +} -- cgit v1.2.3