mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
retroshare-service CMake and WebUI support
Fix retroshare-service webui terminal password checking Install WebUI along with retroshare-service
This commit is contained in:
parent
1ddba795d4
commit
d0c4d1ade2
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: (C) 2004-2019 Retroshare Team <contact@retroshare.cc>
|
||||
# SPDX-FileCopyrightText: (C) 2004-2022 Retroshare Team <contact@retroshare.cc>
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
*.o
|
||||
@ -17,3 +17,6 @@ Thumbs.db
|
||||
*.kdev4
|
||||
|
||||
!supportlibs/libsam3/Makefile
|
||||
|
||||
# QtCreator cruft
|
||||
*CMakeLists.txt.user
|
||||
|
162
retroshare-service/CMakeLists.txt
Normal file
162
retroshare-service/CMakeLists.txt
Normal file
@ -0,0 +1,162 @@
|
||||
# RetroShare decentralized communication platform
|
||||
#
|
||||
# Copyright (C) 2021-2022 Gioacchino Mazzurco <gio@retroshare.cc>
|
||||
# Copyright (C) 2021-2022 Asociación Civil Altermundi <info@altermundi.net>
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
cmake_minimum_required (VERSION 3.18.0)
|
||||
project(retroshare-service)
|
||||
|
||||
include(CMakeDependentOption)
|
||||
|
||||
option(
|
||||
RS_DEVELOPMENT_BUILD
|
||||
"Disable optimization to speed up build, enable verbose build log. \
|
||||
just for development purposes, not suitable for library usage"
|
||||
OFF )
|
||||
|
||||
option(
|
||||
RS_JSON_API
|
||||
"Use restbed to expose libretroshare as JSON API via HTTP"
|
||||
ON )
|
||||
|
||||
option(
|
||||
RS_SERVICE_DESKTOP
|
||||
"Install icons and shortcuts for desktop environements"
|
||||
OFF )
|
||||
|
||||
option(
|
||||
RS_SERVICE_TERMINAL_LOGIN
|
||||
"Enable RetroShare login via terminal"
|
||||
ON )
|
||||
|
||||
cmake_dependent_option(
|
||||
RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||
"Enable settin Web UI password via terminal in retroshare-service"
|
||||
OFF
|
||||
"RS_WEBUI"
|
||||
ON )
|
||||
|
||||
cmake_dependent_option(
|
||||
RS_WEBUI
|
||||
"Install RetroShare Web UI"
|
||||
OFF
|
||||
"RS_JSON_API"
|
||||
ON )
|
||||
|
||||
################################################################################
|
||||
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
include(FetchContent)
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_DEVELOPMENT_BUILD)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
endif(RS_DEVELOPMENT_BUILD)
|
||||
|
||||
################################################################################
|
||||
|
||||
list(
|
||||
APPEND RS_SERVICE_SOURCES
|
||||
src/retroshare-service.cc )
|
||||
|
||||
add_executable(${PROJECT_NAME} ${RS_SERVICE_SOURCES})
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_DEVELOPMENT_BUILD)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE "-O0")
|
||||
endif(RS_DEVELOPMENT_BUILD)
|
||||
|
||||
################################################################################
|
||||
|
||||
set(LIBRETROSHARE_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libretroshare/")
|
||||
if(EXISTS "${LIBRETROSHARE_DEVEL_DIR}/.git" )
|
||||
message(
|
||||
STATUS
|
||||
"libretroshare submodule found at ${LIBRETROSHARE_DEVEL_DIR} using it" )
|
||||
add_subdirectory(
|
||||
"${LIBRETROSHARE_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/libretroshare" )
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
libretroshare
|
||||
GIT_REPOSITORY "https://gitlab.com/RetroShare/libretroshare.git"
|
||||
GIT_TAG "origin/master"
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
TIMEOUT 10
|
||||
)
|
||||
FetchContent_MakeAvailable(libretroshare)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE retroshare)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_SERVICE_DESKTOP)
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(
|
||||
FILES data/retroshare-service.svg
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/ )
|
||||
|
||||
install(
|
||||
FILES data/retroshare-service_48x48.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps/retroshare-service.png )
|
||||
|
||||
install(
|
||||
FILES data/retroshare-service_128x128.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/128x128/apps/retroshare-service.png )
|
||||
|
||||
install(
|
||||
FILES data/retroshare-service.desktop
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/data/retroshare-service.desktop )
|
||||
endif(UNIX AND NOT APPLE)
|
||||
endif(RS_SERVICE_DESKTOP)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_JSON_API)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_JSONAPI)
|
||||
endif(RS_JSON_API)
|
||||
|
||||
if(RS_SERVICE_TERMINAL_LOGIN)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_SERVICE_TERMINAL_LOGIN)
|
||||
endif(RS_SERVICE_TERMINAL_LOGIN)
|
||||
|
||||
if(RS_WEBUI)
|
||||
set(RS_WEBUI_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../webui/")
|
||||
if(EXISTS "${RS_WEBUI_DEVEL_DIR}/.git" )
|
||||
message(
|
||||
STATUS
|
||||
"RetroShare WebUI repository found at ${RS_WEBUI_DEVEL_DIR} using it" )
|
||||
add_subdirectory(
|
||||
"${RS_WEBUI_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/webui" )
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
webui
|
||||
GIT_REPOSITORY "https://gitlab.com/RetroShare/RetroShareWebUI.git"
|
||||
GIT_TAG "origin/master"
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
TIMEOUT 10
|
||||
)
|
||||
FetchContent_MakeAvailable(webui)
|
||||
endif()
|
||||
|
||||
add_dependencies(${PROJECT_NAME} retroshare-webui)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_WEBUI)
|
||||
endif(RS_WEBUI)
|
||||
|
||||
if(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PUBLIC RS_SERVICE_TERMINAL_WEBUI_PASSWORD )
|
||||
endif(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
|
||||
|
||||
################################################################################
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RetroShare Service
|
||||
* Copyright (C) 2016-2021 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net>
|
||||
* Copyright (C) 2016-2022 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
* Copyright (C) 2021-2022 Asociación Civil Altermundi <info@altermundi.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@ -26,15 +26,16 @@
|
||||
#include <iomanip>
|
||||
#include <atomic>
|
||||
|
||||
#include "util/stacktrace.h"
|
||||
#include "util/argstream.h"
|
||||
#include "util/rskbdinput.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
#include "retroshare/rstor.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
||||
#include "util/stacktrace.h"
|
||||
#include "util/argstream.h"
|
||||
#include "util/rskbdinput.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
@ -176,7 +177,7 @@ int main(int argc, char* argv[])
|
||||
as.defaultErrorHandling(true, true);
|
||||
|
||||
#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
|
||||
std::string webui_pass1 = "Y";
|
||||
std::string webui_pass1;
|
||||
if(askWebUiPassword)
|
||||
{
|
||||
std::string webui_pass2 = "N";
|
||||
@ -210,8 +211,8 @@ int main(int argc, char* argv[])
|
||||
int initResult = RsInit::InitRetroShare(conf);
|
||||
if(initResult != RS_INIT_OK)
|
||||
{
|
||||
RsErr() << "Retroshare core initalization failed with: " << initResult
|
||||
<< std::endl;
|
||||
RsFatal() << "Retroshare core initalization failed with: " << initResult
|
||||
<< std::endl;
|
||||
return -initResult;
|
||||
}
|
||||
|
||||
@ -331,11 +332,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
|
||||
if(rsJsonApi && !webui_pass1.empty())
|
||||
{
|
||||
{
|
||||
rsWebUi->setHtmlFilesDirectory(webui_base_directory);
|
||||
rsWebUi->setUserPassword(webui_pass1);
|
||||
rsWebUi->restart();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
rsControl->setShutdownCallback([&](int){keepRunning = false;});
|
||||
|
Loading…
Reference in New Issue
Block a user