Import groupfolders from configfile

This commit is contained in:
2025-06-07 14:41:31 +02:00
parent 3db83f14fe
commit 4dc9ea3acb
3 changed files with 20 additions and 1 deletions

View File

@@ -1,2 +1,3 @@
NEXTCLOUD_CONTAINER_NAME=nextcloud
NEXTCLOUD_USERS=username1 username2 username3
NEXTCLOUD_USERS=username1 username2 username3
NEXTCLOUD_GROUPFOLDER_IDS=1 2 3 4

View File

@@ -107,6 +107,7 @@ void scannerThreadFunc()
int main()
{
manager.tryAddUsersFromConfig(cfm);
manager.tryAddGroupIDsFromConfig(cfm);
std::thread readingThread(readingThreadFunc);
std::thread scannerThread(scannerThreadFunc);

View File

@@ -136,6 +136,23 @@ public:
std::cerr << "No user added from configuration file" << std::endl;
}
}
void tryAddGroupIDsFromConfig(configfilemanager &cfm)
{
try
{
std::vector<std::string> allids = splitString(cfm.at("NEXTCLOUD_GROUPFOLDER_IDS"), ' ');
for (const std::string& id : allids)
{
addUser("__groupfolder/" + id);
}
}
catch (std::exception e)
{
std::cerr << "No groupfolder added from configuration file" << std::endl;
}
}
};
#endif // _USERMAN_H