update documenation, add FUSE options

This commit is contained in:
Jonathan Senkerik 2025-11-23 22:39:18 -05:00
parent cb68942340
commit ead9dfe572
5 changed files with 190 additions and 2 deletions

134
LOG-MANAGEMENT.md Normal file
View File

@ -0,0 +1,134 @@
# Log Management Guide
This guide covers log configuration and rotation for `pcloudcc`.
## Log Files
`pcloudcc` supports two types of logs:
1. **Debug Log** - Operational information, errors, and debug messages
- Default location: `~/.pcloud/debug.log`
- Configure with: `--log-path` and `--log-level`
2. **Filesystem Events Log** - Clean log of file/folder operations only
- Disabled by default
- Enable with: `--fs-event-log`
## Log Configuration
### Log Level
Control verbosity with `--log-level`:
```bash
# Errors only
pcloudcc -u user@example.com -d --log-level ERROR
# Normal operation (default)
pcloudcc -u user@example.com -d --log-level INFO
# Detailed debugging
pcloudcc -u user@example.com -d --log-level DEBUG
# Disable logging
pcloudcc -u user@example.com -d --log-level NONE
```
Available levels: `NONE`, `ERROR`, `WARNING`, `INFO`, `NOTICE`, `DEBUG`
### Custom Log Path
```bash
# System-wide log
pcloudcc -u user@example.com -d --log-path /var/log/pcloudcc.log
# Custom user location
pcloudcc -u user@example.com -d --log-path ~/logs/pcloud.log
```
### Filesystem Events Log
Enable a separate log containing only filesystem events:
```bash
pcloudcc -u user@example.com -d --fs-event-log ~/.pcloud/fs-events.log
```
Event format: `<timestamp> <event_type> <path>`
Example events:
```
Wed, 12 Nov 2025 05:24:23.032 +0000 file deleted /tmp/xxx
Wed, 12 Nov 2025 05:24:47.861 +0000 folder moved /tmp/test2 -> /tmp/test3
Wed, 12 Nov 2025 05:25:10.445 +0000 file created /tmp/newfile.txt
```
## Log Rotation
### System-Wide (with logrotate)
Install the provided configuration:
```bash
sudo cp pcloudcc.logrotate /etc/logrotate.d/pcloudcc
```
This rotates logs daily, keeps 7 days of history, and compresses old logs.
### User-Specific Rotation
Create `~/.logrotate.conf`:
```
/home/username/.pcloud/debug.log /home/username/.pcloud/fs-events.log {
weekly
rotate 4
compress
missingok
notifempty
create 0600 username username
maxsize 50M
postrotate
pkill -USR2 -u username pcloudcc 2>/dev/null || true
endscript
}
```
Add to crontab:
```bash
crontab -e
# Add this line:
0 2 * * * /usr/sbin/logrotate -s ~/.logrotate.state ~/.logrotate.conf
```
### Manual Rotation
```bash
# Move current logs
mv ~/.pcloud/debug.log ~/.pcloud/debug.log.old
mv ~/.pcloud/fs-events.log ~/.pcloud/fs-events.log.old
# Signal pcloudcc to reopen logs
pkill -SIGUSR2 pcloudcc
```
## Cache Management
Configure cache size (default 5GB):
```bash
# Set to 10GB
pcloudcc -u user@example.com -d --cache-size 10
# Set to 1GB for limited storage
pcloudcc -u user@example.com -d --cache-size 1
```
Check cache usage:
```bash
du -sh ~/.pcloud/Cache
```
Cache is stored in `~/.pcloud/Cache/` and managed automatically by `pcloudcc`.

View File

@ -41,4 +41,5 @@ file.
`pcloudcc`.
- [Log Management Guide](./LOG-MANAGEMENT.md): Read this to configure log rotation,
cache size limits, and custom log paths.
cache size limits, and custom log paths. To set up automatic log rotation, copy
`pcloudcc.logrotate` to `/etc/logrotate.d/pcloudcc`.

View File

@ -84,6 +84,30 @@ Wed, 12 Nov 2025 05:25:10.445 +0000 file created /tmp/newfile.txt
See [LOG-MANAGEMENT.md](../LOG-MANAGEMENT.md) for monitoring scripts and log rotation setup.
### FUSE Mount Options
Pass custom FUSE mount options with `--fuse-opts`:
```bash
# Allow other users to access the mount
pcloudcc -u example@myemail.com -d --fuse-opts allow_other
# Multiple options (comma-separated)
pcloudcc -u example@myemail.com -d --fuse-opts allow_other,allow_root
# Set custom permissions
pcloudcc -u example@myemail.com -d --fuse-opts default_permissions,uid=1000,gid=1000
```
**Common FUSE options:**
- `allow_other` - Allow all users to access files (requires `/etc/fuse.conf` setting)
- `allow_root` - Allow root to access files
- `default_permissions` - Enable kernel permission checking
- `uid=N`, `gid=N` - Set file owner/group
- `umask=OCTAL` - Set file permission mask
See `man fuse` for complete list of available options.
## First Use
Start the service in the foreground using the -p switch to enter your

View File

@ -76,7 +76,8 @@ int main(int argc, char **argv) {
("cache-size", po::value<uint64_t>(), "Maximum cache size in GB (default: 5GB).")
("log-path", po::value<std::string>(), "Custom path for debug.log (default: ~/.pcloud/debug.log).")
("log-level", po::value<std::string>(), "Logging level: NONE, ERROR, WARNING, INFO (default), NOTICE, DEBUG.")
("fs-event-log", po::value<std::string>(), "Path to filesystem events log (default: disabled).");
("fs-event-log", po::value<std::string>(), "Path to filesystem events log (default: disabled).")
("fuse-opts,O", po::value<std::string>(), "FUSE mount options (e.g., 'allow_other,allow_root').");
po::command_line_parser parser{argc, argv};
po::positional_options_description p;
@ -166,6 +167,10 @@ int main(int argc, char **argv) {
setenv("PCLOUD_FS_EVENT_LOG", vm["fs-event-log"].as<std::string>().c_str(), 1);
}
if (vm.count("fuse-opts")) {
setenv("PCLOUD_FUSE_OPTS", vm["fuse-opts"].as<std::string>().c_str(), 1);
}
cc::clibrary::pclsync_lib::get_lib().newuser_ = newuser;
cc::clibrary::pclsync_lib::get_lib().set_savepass(save_pass);
cc::clibrary::pclsync_lib::get_lib().set_daemon(daemon);

View File

@ -3690,6 +3690,30 @@ static int psync_fs_do_start() {
}
fuse_opt_add_arg(&args, "-ohard_remove");
// Add user-specified FUSE options from environment variable
const char *fuse_opts_env = getenv("PCLOUD_FUSE_OPTS");
if (fuse_opts_env && fuse_opts_env[0] != '\0') {
char *fuse_opts = strdup(fuse_opts_env);
if (fuse_opts) {
char *token = strtok(fuse_opts, ",");
while (token) {
// Trim leading/trailing whitespace
while (*token == ' ' || *token == '\t') token++;
char *end = token + strlen(token) - 1;
while (end > token && (*end == ' ' || *end == '\t')) *end-- = '\0';
if (strlen(token) > 0) {
char opt_arg[256];
snprintf(opt_arg, sizeof(opt_arg), "-o%s", token);
fuse_opt_add_arg(&args, opt_arg);
pdbg_logf(D_NOTICE, "Adding FUSE option: %s", token);
}
token = strtok(NULL, ",");
}
free(fuse_opts);
}
}
memset(&psync_oper, 0, sizeof(psync_oper));
psync_oper.init = psync_fs_init;