Try making sunshine on Linux stateless
This commit is contained in:
@@ -230,6 +230,14 @@ if(NOT SUNSHINE_ASSETS_DIR)
|
|||||||
set(SUNSHINE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
|
set(SUNSHINE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT SUNSHINE_CONFIG_DIR)
|
||||||
|
set(SUNSHINE_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT SUNSHINE_DEFAULT_DIR)
|
||||||
|
set(SUNSHINE_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND CBS_EXTERNAL_LIBRARIES
|
list(APPEND CBS_EXTERNAL_LIBRARIES
|
||||||
cbs)
|
cbs)
|
||||||
|
|
||||||
@@ -246,6 +254,8 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
|
|||||||
${PLATFORM_LIBRARIES})
|
${PLATFORM_LIBRARIES})
|
||||||
|
|
||||||
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
|
||||||
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR}")
|
||||||
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}")
|
||||||
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
|
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
|
||||||
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES})
|
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES})
|
||||||
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
|
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ using namespace std::literals;
|
|||||||
#define PRIVATE_KEY_FILE CA_DIR "/cakey.pem"
|
#define PRIVATE_KEY_FILE CA_DIR "/cakey.pem"
|
||||||
#define CERTIFICATE_FILE CA_DIR "/cacert.pem"
|
#define CERTIFICATE_FILE CA_DIR "/cacert.pem"
|
||||||
|
|
||||||
#define APPS_JSON_PATH SUNSHINE_ASSETS_DIR "/" APPS_JSON
|
#define APPS_JSON_PATH SUNSHINE_CONFIG_DIR "/" APPS_JSON
|
||||||
namespace config {
|
namespace config {
|
||||||
|
|
||||||
namespace nv {
|
namespace nv {
|
||||||
@@ -223,7 +223,7 @@ sunshine_t sunshine {
|
|||||||
{}, // Username
|
{}, // Username
|
||||||
{}, // Password
|
{}, // Password
|
||||||
{}, // Password Salt
|
{}, // Password Salt
|
||||||
SUNSHINE_ASSETS_DIR "/sunshine.conf", // config file
|
SUNSHINE_CONFIG_DIR "/sunshine.conf", // config file
|
||||||
{}, // cmd args
|
{}, // cmd args
|
||||||
47989,
|
47989,
|
||||||
};
|
};
|
||||||
@@ -573,6 +573,10 @@ int apply_flags(const char *line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void apply_config(std::unordered_map<std::string, std::string> &&vars) {
|
void apply_config(std::unordered_map<std::string, std::string> &&vars) {
|
||||||
|
if(!fs::exists(stream.file_apps.c_str())) {
|
||||||
|
stream.file_apps = SUNSHINE_DEFAULT_DIR "/" APPS_JSON;
|
||||||
|
}
|
||||||
|
|
||||||
for(auto &[name, val] : vars) {
|
for(auto &[name, val] : vars) {
|
||||||
std::cout << "["sv << name << "] -- ["sv << val << ']' << std::endl;
|
std::cout << "["sv << name << "] -- ["sv << val << ']' << std::endl;
|
||||||
}
|
}
|
||||||
@@ -754,6 +758,10 @@ int parse(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!fs::exists(sunshine.config_file.c_str())) {
|
||||||
|
sunshine.config_file = SUNSHINE_DEFAULT_DIR "/sunshine.conf";
|
||||||
|
}
|
||||||
|
|
||||||
auto vars = parse_config(read_file(sunshine.config_file.c_str()));
|
auto vars = parse_config(read_file(sunshine.config_file.c_str()));
|
||||||
|
|
||||||
for(auto &[name, value] : cmd_vars) {
|
for(auto &[name, value] : cmd_vars) {
|
||||||
|
|||||||
@@ -250,7 +250,8 @@ void saveApp(resp_https_t response, req_https_t request) {
|
|||||||
fileTree.erase("apps");
|
fileTree.erase("apps");
|
||||||
fileTree.push_back(std::make_pair("apps", newApps));
|
fileTree.push_back(std::make_pair("apps", newApps));
|
||||||
}
|
}
|
||||||
pt::write_json(config::stream.file_apps, fileTree);
|
std::string sunshine_apps_path = SUNSHINE_CONFIG_DIR "/" APPS_JSON;
|
||||||
|
pt::write_json(sunshine_apps_path, fileTree);
|
||||||
}
|
}
|
||||||
catch(std::exception &e) {
|
catch(std::exception &e) {
|
||||||
BOOST_LOG(warning) << "SaveApp: "sv << e.what();
|
BOOST_LOG(warning) << "SaveApp: "sv << e.what();
|
||||||
@@ -360,7 +361,8 @@ void saveConfig(resp_https_t response, req_https_t request) {
|
|||||||
|
|
||||||
configStream << kv.first << " = " << value << std::endl;
|
configStream << kv.first << " = " << value << std::endl;
|
||||||
}
|
}
|
||||||
write_file(config::sunshine.config_file.c_str(), configStream.str());
|
std::string sunshine_config_path = SUNSHINE_CONFIG_DIR "/sunshine.conf";
|
||||||
|
write_file(sunshine_config_path.c_str(), configStream.str());
|
||||||
}
|
}
|
||||||
catch(std::exception &e) {
|
catch(std::exception &e) {
|
||||||
BOOST_LOG(warning) << "SaveConfig: "sv << e.what();
|
BOOST_LOG(warning) << "SaveConfig: "sv << e.what();
|
||||||
|
|||||||
Reference in New Issue
Block a user