diff options
Diffstat (limited to 'utils/libservice')
-rw-r--r-- | utils/libservice/CMakeLists.txt | 1 | ||||
-rw-r--r-- | utils/libservice/utils/CMakeLists.txt | 11 | ||||
-rw-r--r-- | utils/libservice/utils/install_service.cpp | 32 | ||||
-rw-r--r-- | utils/libservice/utils/start_service.cpp | 32 | ||||
-rw-r--r-- | utils/libservice/utils/stop_service.cpp | 32 | ||||
-rw-r--r-- | utils/libservice/utils/uninstall_service.cpp | 32 |
6 files changed, 140 insertions, 0 deletions
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 <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include <exception> +#include <iostream> + +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 <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include <exception> +#include <iostream> + +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 <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include <exception> +#include <iostream> + +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 <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "libservice/all.hpp" + +#include <exception> +#include <iostream> + +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; +} |