Compare commits
27 Commits
2951b48680
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a2eefe411c | |||
| f1b94cbfd8 | |||
| 1b44dd10db | |||
| 1fef08bc55 | |||
| 4dc9ea3acb | |||
| 3db83f14fe | |||
| 2d1eed4289 | |||
| 45c1182947 | |||
| 2974629995 | |||
| c59e7532c2 | |||
| 1430508121 | |||
| f3d93e1e46 | |||
| e98a8daad7 | |||
| 0a9fe8f4f8 | |||
| 5d4cd30d95 | |||
| f8b66b4e07 | |||
| 31ec926793 | |||
| ed068875c3 | |||
| a1b8d589be | |||
| e95d9bb552 | |||
| 754cc29a83 | |||
| bd9ccd33ef | |||
| c0a1b0bbd5 | |||
| cd52871632 | |||
| a2058ce2d6 | |||
| bad5123b02 | |||
| 15fe1b0e9b |
@@ -1,17 +1,28 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push: {}
|
push:
|
||||||
|
tags:
|
||||||
|
- '*' # Triggers on all tags
|
||||||
|
branches:
|
||||||
|
- '**' # Triggers on all branches
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: .
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu
|
||||||
|
container:
|
||||||
|
image: node:20
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install build tools
|
- name: Install tools
|
||||||
run: sudo apt update && sudo apt install -y build-essential zip
|
run: apt update && apt install -y build-essential
|
||||||
|
|
||||||
- name: Compile project
|
- name: Compile project
|
||||||
run: make
|
run: make
|
||||||
@@ -24,11 +35,16 @@ jobs:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
needs: build
|
needs: build
|
||||||
|
runs-on: ubuntu
|
||||||
|
container:
|
||||||
|
image: node:20
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install build tools
|
||||||
|
run: apt update && apt install -y zip
|
||||||
|
|
||||||
- name: Download compiled binary
|
- name: Download compiled binary
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
@@ -40,19 +56,24 @@ jobs:
|
|||||||
mkdir build
|
mkdir build
|
||||||
cp ncsambawatcher build/ncsambawatcher
|
cp ncsambawatcher build/ncsambawatcher
|
||||||
cp configs/ncsambawatcher.config.default build/ncsambawatcher.config
|
cp configs/ncsambawatcher.config.default build/ncsambawatcher.config
|
||||||
cp init.sh config/init.sh
|
cp configs/ncsambawatcher.service.default build/ncsambawatcher.service
|
||||||
|
cp init.sh build/init.sh
|
||||||
|
|
||||||
- name: Create release zip
|
- name: Create release zip
|
||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
zip ../ncsambawatcher.zip ./*
|
ls -al
|
||||||
|
zip -rv ../ncsambawatcher.zip ./*
|
||||||
|
cd ../
|
||||||
|
ls -al
|
||||||
|
|
||||||
- name: Publish release
|
- name: Publish release
|
||||||
uses: actions/create-release@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.RELEASE_SECRET }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref_name }}
|
tag_name: ${{ github.ref_name }}
|
||||||
release_name: Release ${{ github.ref_name }}
|
name: Release ${{ github.ref_name }}
|
||||||
files: |
|
files: ./ncsambawatcher.zip
|
||||||
ncsambawatcher.zip
|
token: ${{ secrets.RELEASE_SECRET }}
|
||||||
|
draft: true
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -91,4 +91,5 @@ watch.c
|
|||||||
ncwatchfile
|
ncwatchfile
|
||||||
ncsambawatcher
|
ncsambawatcher
|
||||||
|
|
||||||
obj/
|
obj/
|
||||||
|
build/
|
||||||
58
README.md
58
README.md
@@ -1,3 +1,57 @@
|
|||||||
# nextcloud-samba-sync
|
# Nextcloud-Samba Sync
|
||||||
|
|
||||||
A Nextcloud-Samba File scanner system
|
## Pre installation
|
||||||
|
|
||||||
|
- Install `samba` and `vfs-modules`
|
||||||
|
```
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install samba samba-vfs-modules
|
||||||
|
```
|
||||||
|
- Create shares. The example is in `configs` folder
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. Download a `ncsambawatcher.zip` file from a release above 2.0
|
||||||
|
2. Extract somewhere on your server (I recommend your user folder)
|
||||||
|
3. Make sure the samba configuration file is correct (See `configs/smb.24.04.conf`)
|
||||||
|
4. Configurate the `ncsambawatcher.config` file
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>NEXTCLOUD_CONTAINER_NAME</code></td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>The nextcloud's docker container name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>NEXTCLOUD_USERS</code></td>
|
||||||
|
<td>No</td>
|
||||||
|
<td>Usernames separated with spaces</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>NEXTCLOUD_GROUPFOLDER_IDS</code></td>
|
||||||
|
<td>No</td>
|
||||||
|
<td>Groupfolder ids separated with spaces (only the number)</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
Example 1:
|
||||||
|
```
|
||||||
|
NEXTCLOUD_CONTAINER_NAME=nextcloud
|
||||||
|
```
|
||||||
|
Example 2: (See `configs/ncsambawatcher.config.default`)
|
||||||
|
|
||||||
|
5. Run the `init.sh` script
|
||||||
|
6. You're done :)
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- You don't need to add users and groupfolders to the configfile because the program add automaticly from the logfile
|
||||||
|
- For a user (not groupfolder): The username and the samba share name **MUST BE THE SAME**
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
NEXTCLOUD_CONTAINER_NAME=nextcloud
|
NEXTCLOUD_CONTAINER_NAME=nextcloud
|
||||||
|
NEXTCLOUD_USERS=username1 username2 username3
|
||||||
|
NEXTCLOUD_GROUPFOLDER_IDS=1 2 3 4
|
||||||
@@ -4,12 +4,11 @@ After=network.target docker.service
|
|||||||
Requires=docker.service
|
Requires=docker.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/ncsambawatcher
|
ExecStart=/path/to/folder/ncsambawatcher
|
||||||
|
WorkingDirectory=/path/to/folder/
|
||||||
Restart=always
|
Restart=always
|
||||||
User=root
|
User=root
|
||||||
Group=root
|
Group=root
|
||||||
WorkingDirectory=/usr/bin/
|
|
||||||
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
SyslogIdentifier=ncsambawatcher
|
SyslogIdentifier=ncsambawatcher
|
||||||
8
init.sh
8
init.sh
@@ -1,11 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
make
|
current_dir=$(pwd)
|
||||||
|
sed -i "s|/path/to/folder/|$current_dir/|g" ncsambawatcher.service
|
||||||
|
|
||||||
sudo cp ncsambawatcher /usr/bin/
|
sudo cp ./ncsambawatcher.service /etc/systemd/system
|
||||||
sudo chmod +x /usr/bin/ncsambawatcher
|
|
||||||
|
|
||||||
sudo cp configs/ncsambawatcher.service /etc/systemd/system
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable ncsambawatcher.service
|
sudo systemctl enable ncsambawatcher.service
|
||||||
|
|||||||
1
src/configfilemanager.cpp
Normal file
1
src/configfilemanager.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "configfilemanager.h"
|
||||||
68
src/configfilemanager.h
Normal file
68
src/configfilemanager.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#ifndef _CONFIGFILEMANAGER_H
|
||||||
|
#define _CONFIGFILEMANAGER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <mutex>
|
||||||
|
#include "definitions.h"
|
||||||
|
|
||||||
|
class configfilemanager{
|
||||||
|
private:
|
||||||
|
std::map<std::string, std::string> configs;
|
||||||
|
std::mutex mtx;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
configfilemanager(std::string filepath = "./ncsambawatcher.config")
|
||||||
|
{
|
||||||
|
std::ifstream is(filepath);
|
||||||
|
if(!is.good())
|
||||||
|
{
|
||||||
|
std::cerr << "File not exits: " << filepath << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
std::string tmp;
|
||||||
|
|
||||||
|
while(!is.eof())
|
||||||
|
{
|
||||||
|
std::getline(is, tmp);
|
||||||
|
std::cout << tmp << std::endl;
|
||||||
|
if (tmp.at(0) == '#') // ignore comments
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::vector<std::string> splited = splitString(tmp, '=');
|
||||||
|
if (splited.size() != 2)
|
||||||
|
{
|
||||||
|
std::cerr << "Invalid line: " << tmp << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
configs.insert(std::make_pair(splited.at(0), splited.at(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configs.count("NEXTCLOUD_CONTAINER_NAME") == 0)
|
||||||
|
{
|
||||||
|
std::cerr << "The container's name not added" << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Config file loaded successfuly" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string at(const std::string &config)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
return configs.at(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string at(const char* config)
|
||||||
|
{
|
||||||
|
return at(std::string(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _CONFIGFILEMANAGER_H
|
||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
#define USER_LOG_LOCATION 3
|
#define USER_LOG_LOCATION 3
|
||||||
|
|
||||||
#define SCAN_CMD_USR "docker exec --user www-data nextcloud /var/www/html/occ files:scan --path="
|
#define SCAN_CMD_USR "docker exec --user www-data %1% /var/www/html/occ files:scan --path="
|
||||||
#define SCAN_CMD_GRP "docker exec --user www-data nextcloud /var/www/html/occ groupfolder:scan "
|
#define SCAN_CMD_GRP "docker exec --user www-data %1% /var/www/html/occ groupfolder:scan "
|
||||||
|
|
||||||
|
std::vector<std::string> splitString(const std::string& input, char delimiter);
|
||||||
|
|
||||||
#endif // _LOCATIONS_H
|
#endif // _LOCATIONS_H
|
||||||
25
src/main.cpp
25
src/main.cpp
@@ -5,17 +5,34 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <unordered_set>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include "definitions.h"
|
||||||
#include "usermanager.h"
|
#include "usermanager.h"
|
||||||
|
#include "configfilemanager.h"
|
||||||
|
|
||||||
|
configfilemanager cfm;
|
||||||
userManager manager;
|
userManager manager;
|
||||||
std::condition_variable cv;
|
std::condition_variable cv;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
|
||||||
|
std::vector<std::string> splitString(const std::string& str, char delimiter = '|')
|
||||||
|
{
|
||||||
|
std::vector<std::string> ret;
|
||||||
|
std::stringstream ss(str);
|
||||||
|
std::string token;
|
||||||
|
|
||||||
|
while (std::getline(ss, token, delimiter)) {
|
||||||
|
ret.push_back(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void readingThreadFunc()
|
void readingThreadFunc()
|
||||||
{
|
{
|
||||||
FILE *logpipe = popen(LOGFILE, "r");
|
FILE *logpipe = popen(LOGFILE, "r");
|
||||||
@@ -52,7 +69,7 @@ void scannerThreadFunc()
|
|||||||
cv.wait(lock, []
|
cv.wait(lock, []
|
||||||
{ return manager.isAnybodyFlagged(); });
|
{ return manager.isAnybodyFlagged(); });
|
||||||
|
|
||||||
std::set<std::string> scanUsers = manager.getFlaggedUsers();
|
std::unordered_set<std::string> scanUsers = manager.getFlaggedUsers();
|
||||||
manager.unflagAllUsers();
|
manager.unflagAllUsers();
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -68,7 +85,8 @@ void scannerThreadFunc()
|
|||||||
}
|
}
|
||||||
else if (child == 0) // child
|
else if (child == 0) // child
|
||||||
{
|
{
|
||||||
std::string cmd = userManager::getScanCommandFromUser(user);
|
std::string cmd = userManager::getScanCommandFromUser(user, cfm);
|
||||||
|
std::cout << "Run command: " << cmd << std::endl;
|
||||||
execl("/bin/sh", "sh", "-c", cmd.c_str(), static_cast<char *>(nullptr));
|
execl("/bin/sh", "sh", "-c", cmd.c_str(), static_cast<char *>(nullptr));
|
||||||
std::cerr << "Scan failed" << std::endl;
|
std::cerr << "Scan failed" << std::endl;
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
@@ -90,6 +108,9 @@ void scannerThreadFunc()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
manager.tryAddUsersFromConfig(cfm);
|
||||||
|
manager.tryAddGroupIDsFromConfig(cfm);
|
||||||
|
|
||||||
std::thread readingThread(readingThreadFunc);
|
std::thread readingThread(readingThreadFunc);
|
||||||
std::thread scannerThread(scannerThreadFunc);
|
std::thread scannerThread(scannerThreadFunc);
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
#include "usermanager.h"
|
#include "usermanager.h"
|
||||||
|
|
||||||
std::vector<std::string> splitString(const std::string& str, char delimiter = '|')
|
std::string userManager::getScanCommandFromUser(const std::string &user, configfilemanager &cfm)
|
||||||
{
|
|
||||||
std::vector<std::string> ret;
|
|
||||||
std::stringstream ss(str);
|
|
||||||
std::string token;
|
|
||||||
|
|
||||||
while (std::getline(ss, token, delimiter)) {
|
|
||||||
ret.push_back(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string userManager::getScanCommandFromUser(const std::string &user)
|
|
||||||
{
|
{
|
||||||
|
std::string contname = cfm.at("NEXTCLOUD_CONTAINER_NAME");
|
||||||
|
std::string baseCommand;
|
||||||
|
std::string userCommand;
|
||||||
|
std::string placeholder("%1%");
|
||||||
|
|
||||||
if (user.find("__groupfolder") != std::string::npos)
|
if (user.find("__groupfolder") != std::string::npos)
|
||||||
{
|
{
|
||||||
return std::string(SCAN_CMD_GRP) + splitString(user, '/').back();
|
baseCommand = SCAN_CMD_GRP;
|
||||||
|
userCommand = splitString(user, '/').back();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
baseCommand = SCAN_CMD_USR;
|
||||||
|
userCommand = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(SCAN_CMD_USR) + user;
|
size_t pos = 0;
|
||||||
|
while ((pos = baseCommand.find(placeholder, pos)) != std::string::npos) {
|
||||||
|
baseCommand.replace(pos, placeholder.length(), contname);
|
||||||
|
pos += contname.length(); // Move past the replacement
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseCommand + userCommand;
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <unordered_set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <stdexcept>
|
||||||
#include "definitions.h"
|
#include "definitions.h"
|
||||||
|
#include "configfilemanager.h"
|
||||||
std::vector<std::string> splitString(const std::string& input, char delimiter);
|
|
||||||
|
|
||||||
class userManager
|
class userManager
|
||||||
{
|
{
|
||||||
@@ -19,35 +19,37 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static std::string getScanCommandFromUser(const std::string&);
|
static std::string getScanCommandFromUser(const std::string&, configfilemanager& cfm);
|
||||||
|
|
||||||
void addUserFromLogLine(std::string &line)
|
void addUserFromLogLine(std::string &line)
|
||||||
{
|
{
|
||||||
addUser(splitString(line, '|').at(USER_LOG_LOCATION));
|
addUser(splitString(line, '|').at(USER_LOG_LOCATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addUser(std::string &user)
|
void addUser(const std::string &user)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
if (users.count(user) == 0)
|
if (users.count(user) == 0)
|
||||||
{
|
{
|
||||||
users[user] = false;
|
users[user] = false;
|
||||||
|
std::cout << "User added the list: " << user << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeUser(std::string &user)
|
void removeUser(const std::string &user)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
users.erase(user);
|
users.erase(user);
|
||||||
|
std::cout << "User removed the list: " << user << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isContains(std::string &user)
|
bool isContains(const std::string &user)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
return users.count(user) == 1;
|
return users.count(user) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUserFlagged(std::string &user)
|
void setUserFlagged(const std::string &user)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
if (users.count(user) == 1)
|
if (users.count(user) == 1)
|
||||||
@@ -56,7 +58,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUserUnflagged(std::string &user)
|
void setUserUnflagged(const std::string &user)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
if (users.count(user) == 1)
|
if (users.count(user) == 1)
|
||||||
@@ -74,9 +76,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> getUsers()
|
std::unordered_set<std::string> getUsers()
|
||||||
{
|
{
|
||||||
std::set<std::string> ret;
|
std::unordered_set<std::string> ret;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
|
||||||
@@ -88,9 +90,9 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> getFlaggedUsers()
|
std::unordered_set<std::string> getFlaggedUsers()
|
||||||
{
|
{
|
||||||
std::set<std::string> ret;
|
std::unordered_set<std::string> ret;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
|
||||||
@@ -117,6 +119,40 @@ public:
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tryAddUsersFromConfig(configfilemanager &cfm)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::vector<std::string> alluser = splitString(cfm.at("NEXTCLOUD_USERS"), ' ');
|
||||||
|
|
||||||
|
for (const std::string& user : alluser)
|
||||||
|
{
|
||||||
|
addUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
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("__groupfolders/" + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
std::cerr << "No groupfolder added from configuration file" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _USERMAN_H
|
#endif // _USERMAN_H
|
||||||
Reference in New Issue
Block a user