Compare commits

...

5 Commits

Author SHA1 Message Date
eust-w
921fc37211 🐛 Stabilize drosync automatic scheduling 2026-09-02 01:56:40 +08:00
eust-w
f7ca2755fd 📚 Add drosync Chinese user manual 2026-09-02 01:56:40 +08:00
eust-w
e19995ce53 🔒 Support headless drosync system services 2026-09-02 01:56:40 +08:00
eust-w
eaec4c2cdc 📦 Harden drosync Linux packages 2026-09-02 01:56:40 +08:00
eust-w
4e5166fe84 ✨ Add bucket-based drosync mappings 2026-09-02 01:56:39 +08:00
17 changed files with 493 additions and 23 deletions

View File

@ -13,6 +13,7 @@
## Document map
- [中文用户使用手册](用户使用手册.md)
- [Product requirements](product-requirements.md)
- [Architecture and state machines](architecture.md)
- [OpenAPI 3.1 contract](openapi.yaml)

View File

@ -12,7 +12,7 @@ Commands:
| `configure --server URL` | Persist the control-plane URL through daemon IPC. |
| `auth --server URL [--profile NAME] --access-key-id ID (--secret-file PATH \| --secret-stdin)` | Validate a scoped drosync Key/Secret, automatically register the device, and store the resulting bearer token in the OS credential store. `DROSYNC_ACCESS_KEY_ID` and `DROSYNC_SECRET` are supported for non-interactive injection. |
| `mapping list` | List local mappings. |
| `mapping add ROOT --space ID [--remote-prefix P] [--include-hidden] [--require-done]` | Add a mapping. |
| `mapping add ROOT (--bucket NAME \| --space ID) [--remote-prefix P] [--include-hidden] [--require-done]` | Add a mapping. `--bucket` resolves only within spaces visible to the current scoped credential; `--space` selects an exact administrative ID. |
| `mapping remove ID` | Remove a mapping without deleting local or remote objects. |
| `plan ID` | Scan, upload a paged manifest, wait for the asynchronous plan, and retain the resumable session without uploading bytes. |
| `sync ID [--dry-run]` | Resume a planned/crashed session or execute scan through final commit. |

View File

@ -75,6 +75,19 @@ drosync plan <mapping-id>
drosync sync <mapping-id>
```
普通用户也可以直接填写凭据允许访问的 bucket。守护进程会通过控制面把
bucket 解析为唯一的受限 Sync Space;不会在客户端保存 BOS AK/SK,也不会
绕过 Space 的 root prefix:
```bash
drosync mapping add /data/capture \
--bucket bucket-a \
--remote-prefix ubt/incoming/
```
`--bucket` 与管理员使用的 `--space` 互斥。若同一凭据可见多个指向同一
bucket 的 Space,命令会拒绝猜测,并要求管理员明确提供 `--space`。
For a strict profile, configure and authenticate with the same policy:
```bash

View File

@ -0,0 +1,254 @@
# drosync 用户使用手册
本文面向需要把 Ubuntu 本地目录持续、单向同步到 Drobodata POC 对象存储的用户和管理员。
## 1. 能做什么
`drosync` 监听一个本地目录,在文件稳定后自动上传到指定 bucket 的相对 prefix。它支持断点续传、失败重试、冲突保留、SQLite 状态恢复和 systemd 守护运行。
它不是网络盘:不会下载远端文件、删除远端对象、合并文件内容或跟随软链接。
## 2. 安全模型
客户端不保存完整 BOS AK/SK。管理员先在 POC 创建 Sync Space,再创建受限 drosync Key:
- Access Key ID 用于标识客户端;
- Secret 只在创建时显示一次;
- Scope 限制可用 Space、相对 prefix 和 `plan/create/update` 操作;
- 首次认证换取的设备 Token 保存在 `/var/lib/drosync/token`,权限必须为 `0600`。
已有 Key 的 Secret 无法再次读取。新机器应创建独立 Key,不应多人共用一个 Secret。
## 3. 安装
### 3.1 DEB 安装(推荐)
先校验:
```bash
sha256sum -c drosync_1.0.0-poc.20260901-bucket-map_amd64.deb.sha256
```
安装并启动系统服务:
```bash
sudo apt-get install -y ./drosync_1.0.0-poc.20260901-bucket-map_amd64.deb
sudo systemctl enable --now drosync.service
systemctl status drosync.service --no-pager
```
### 3.2 portable 安装
```bash
sha256sum -c drosync-1.0.0-poc.20260901-bucket-map-linux-x86_64.tar.gz.sha256
tar -xzf drosync-1.0.0-poc.20260901-bucket-map-linux-x86_64.tar.gz
cd drosync-1.0.0-poc.20260901-bucket-map
sudo apt-get update
sudo apt-get install -y ca-certificates libdbus-1-3
sudo ./install-systemd-portable.sh --enable
```
## 4. POC 管理员准备
管理员在“对象存储 / 对象同步”中完成:
1. 创建或选择 Storage Connection;
2. 创建 Sync Space,填写 bucket 和管理员限定的 root prefix;
3. 执行 capability probe;
4. 创建 drosync Key;
5. 将 Scope 限制到该 Space 和需要的相对 prefix;
6. 首次测试建议仅授权 `plan/create`,验证后再决定是否增加 `update`。
## 5. 系统服务模式配置
以下命令显式设置两个 XDG 路径,让 CLI 连接系统 daemon 的 Unix socket。
配置 POC 地址:
```bash
sudo env \
XDG_DATA_HOME=/var/lib/drosync \
XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync configure --server http://120.48.164.19
```
POC 当前为 HTTP,认证元数据不加密;只应在认可的隔离网络中使用。正式环境应使用 HTTPS 并增加 `--require-https`。
将一次性 Secret 写入 root 私有文件:
```bash
sudo install -m 0600 /dev/null /root/drosync-onetime-secret
sudo nano /root/drosync-onetime-secret
```
认证:
```bash
sudo env \
XDG_DATA_HOME=/var/lib/drosync \
XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync auth \
--server http://120.48.164.19 \
--access-key-id '<ACCESS_KEY_ID>' \
--secret-file /root/drosync-onetime-secret
```
成功后立即删除一次性 Secret:
```bash
sudo rm /root/drosync-onetime-secret
sudo stat -c '%a %U:%G %n' /var/lib/drosync/token
```
期望 Token 文件权限为 `600 drosync:drosync`。
## 6. 添加同步目录
用户可以直接填写本地目录、bucket 和相对 prefix:
```bash
sudo env \
XDG_DATA_HOME=/var/lib/drosync \
XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync mapping add /data/capture \
--bucket bucket-a \
--remote-prefix ubt/incoming/
```
系统服务启用了 `PrivateTmp=true`。不要把同步源目录配置在 `/tmp` 或
`/var/tmp`;systemd 私有临时目录会让 daemon 看不到用户 shell 创建的文件。
应使用 `/data`、`/srv`、挂载的数据盘或实际采集目录。
`--bucket` 只会在当前 Key 可见的 Space 中解析。没有匹配或存在多个匹配时命令会拒绝猜测。管理员可改用 `--space <SPACE_ID>` 精确指定。
可选参数:
- `--include-hidden`:包含隐藏文件;默认不包含;
- `--require-done`:只有存在 `{file}.done` 时才上传;
- 临时后缀 `.tmp/.part/.partial/.crdownload/.swp/.download` 始终忽略;
- 软链接、FIFO、socket 和设备文件始终忽略。
## 7. 检查和首次同步
先执行健康检查:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync doctor
```
查看映射并取得 mapping ID:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync mapping list
```
只生成计划,不上传文件:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync plan '<MAPPING_ID>'
```
确认计划后执行同步:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync sync '<MAPPING_ID>'
```
daemon 会持续监听映射目录。文件必须至少 60 秒保持大小和 mtime 不变,哈希前后 stat 也必须一致,才会进入上传。
## 8. 状态、日志和恢复
查看状态:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync --json status
```
查看日志:
```bash
sudo journalctl -u drosync.service -f
```
失败后重试:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync retry '<MAPPING_ID>'
```
SQLite 位于 `/var/lib/drosync/drosync/state.db`。不要在服务运行时复制或手工编辑数据库;备份前先停止服务,或使用 SQLite 在线备份机制。
## 9. 冲突处理
客户端不会静默覆盖并发写入:
- create 使用条件写入;
- update 使用 ETag/version 前置条件;
- 条件失败时保留原对象,并将新内容发布为 `.__conflict__<UTC>_<item>`;
- multipart ETag 只用于传输校验,不当作文件 SHA-256。
查看冲突:
```bash
sudo env XDG_DATA_HOME=/var/lib/drosync XDG_CONFIG_HOME=/var/lib/drosync/config \
drosync conflicts
```
## 10. 常见问题
### `server is not configured`
先运行 `drosync configure --server ...`,并确保 CLI 使用系统服务的两个 XDG 路径。
### `bucket ... is not available`
当前 Key 没有该 bucket 对应 Space 的 Scope,或管理员尚未创建/启用 Space。
### `bucket ... maps to multiple sync spaces`
让管理员提供准确 Space ID,然后使用 `--space <ID>`。
### 文件没有上传
检查:文件是否稳定满 60 秒、是否为临时后缀、是否为隐藏文件、是否要求 `.done`、Key 是否包含目标 prefix。
### 服务循环重启
```bash
sudo systemctl status drosync.service --no-pager
sudo journalctl -u drosync.service -n 100 --no-pager
sudo stat -c '%a %U:%G %n' /var/lib/drosync /var/lib/drosync/config /etc/drosync
```
## 11. 停止和卸载
停止自动同步:
```bash
sudo systemctl disable --now drosync.service
```
卸载 DEB:
```bash
sudo apt-get remove drosync
```
卸载不会自动删除 `/var/lib/drosync` 和 `/etc/drosync`,避免误删状态和凭据。确认不再需要后再由管理员单独清理。
## 12. 验收清单
- `drosync --json version` 显示 `linux-x86_64`;
- `systemctl is-active drosync.service` 返回 `active`;
- `drosync doctor` 通过 SQLite、IPC、凭据、控制面和 Scope 检查;
- `plan` 的对象路径全部位于授权 prefix;
- 上传后比对本地 SHA-256、远端 size/ETag/version;
- 中断上传后可续传;
- 并发覆盖测试生成冲突对象而不是覆盖原对象;
- 审计中可追溯设备、session、item、操作和目标 key。

View File

@ -79,8 +79,10 @@ enum MappingSubcommand {
List,
Add {
local_root: PathBuf,
#[arg(long)]
space: String,
#[arg(long, required_unless_present = "bucket", conflicts_with = "bucket")]
space: Option<String>,
#[arg(long, required_unless_present = "space", conflicts_with = "space")]
bucket: Option<String>,
#[arg(long)]
remote_prefix: Option<String>,
#[arg(long)]
@ -291,6 +293,7 @@ async fn execute(app: &App) -> Result<Value> {
MappingSubcommand::Add {
local_root,
space,
bucket,
remote_prefix,
include_hidden,
require_done,
@ -298,7 +301,13 @@ async fn execute(app: &App) -> Result<Value> {
let canonical = local_root
.canonicalize()
.with_context(|| format!("invalid mapping root {}", local_root.display()))?;
let mut mapping = Mapping::new(canonical, space.clone());
let mut mapping = match (space.as_ref(), bucket.as_ref()) {
(Some(space), None) => Mapping::new(canonical, space.trim().to_owned()),
(None, Some(bucket)) => {
Mapping::for_bucket(canonical, bucket.trim().to_owned())
}
_ => return Err(anyhow!("exactly one of --space or --bucket is required")),
};
mapping.remote_prefix = remote_prefix.clone().unwrap_or_default();
mapping.include_hidden = *include_hidden;
mapping.require_done_marker = *require_done;

View File

@ -40,6 +40,8 @@ pub struct Mapping {
pub local_root: PathBuf,
pub sync_space_id: String,
#[serde(default)]
pub bucket: String,
#[serde(default)]
pub remote_prefix: String,
#[serde(default)]
pub include_hidden: bool,
@ -54,11 +56,19 @@ impl Mapping {
id: Uuid::new_v4().to_string(),
local_root,
sync_space_id,
bucket: String::new(),
remote_prefix: String::new(),
include_hidden: false,
require_done_marker: false,
}
}
#[must_use]
pub fn for_bucket(local_root: PathBuf, bucket: String) -> Self {
let mut mapping = Self::new(local_root, String::new());
mapping.bucket = bucket;
mapping
}
}
#[derive(Debug, Clone)]
@ -369,4 +379,12 @@ mod tests {
"nested/good.bin"
);
}
#[test]
fn bucket_mapping_defers_space_resolution_to_the_authenticated_daemon() {
let mapping =
Mapping::for_bucket(Path::new("/mapping").to_path_buf(), "bucket-a".to_owned());
assert_eq!(mapping.bucket, "bucket-a");
assert!(mapping.sync_space_id.is_empty());
}
}

View File

@ -126,6 +126,43 @@ fn apply_remote_prefix(mapping: &Mapping, manifest: &mut ManifestItem) {
}
}
fn resolve_bucket_space(capabilities: &Value, bucket: &str) -> Result<(String, String)> {
let requested = bucket.trim();
if requested.is_empty() {
return Err(anyhow!("bucket must not be empty"));
}
let spaces = capabilities
.get("spaces")
.and_then(Value::as_array)
.ok_or_else(|| anyhow!("control plane did not return scoped sync spaces"))?;
let matches = spaces
.iter()
.filter(|space| space.get("bucket").and_then(Value::as_str) == Some(requested))
.filter_map(|space| {
let id = space.get("id")?.as_str()?.trim();
(!id.is_empty()).then(|| {
(
id.to_owned(),
space
.get("rootPrefix")
.and_then(Value::as_str)
.unwrap_or_default()
.to_owned(),
)
})
})
.collect::<Vec<_>>();
match matches.as_slice() {
[item] => Ok(item.clone()),
[] => Err(anyhow!(
"bucket {requested} is not available to this credential; ask an administrator to create or grant a sync space"
)),
_ => Err(anyhow!(
"bucket {requested} maps to multiple sync spaces; use --space with the intended space id"
)),
}
}
fn normalize_journal(mut journal: SyncJournal) -> SyncJournal {
if journal.file_count == 0 && !journal.files.is_empty() {
journal.file_count = u64::try_from(journal.files.len()).unwrap_or(u64::MAX);
@ -813,12 +850,31 @@ async fn dispatch(state: &mut StateStore, request: IpcRequest) -> IpcResponse {
.mappings()
.map(|items| serde_json::to_value(items).expect("serializable mappings"))
.map_err(Into::into),
"mapping.add" => serde_json::from_value::<Mapping>(request.arguments)
.map_err(Into::into)
.and_then(|mapping| {
state.put_mapping(&mapping)?;
Ok(serde_json::to_value(mapping).expect("serializable mapping"))
}),
"mapping.add" => match serde_json::from_value::<Mapping>(request.arguments) {
Ok(mut mapping) => {
let resolved = if mapping.sync_space_id.trim().is_empty() {
match load_transfer_client(state) {
Ok(client) => match client.capabilities().await {
Ok(capabilities) => {
resolve_bucket_space(&capabilities, &mapping.bucket)
}
Err(error) => Err(error.into()),
},
Err(error) => Err(error),
}
} else {
Ok((mapping.sync_space_id.clone(), String::new()))
};
resolved.and_then(|(space_id, space_root_prefix)| {
mapping.sync_space_id = space_id;
state.put_mapping(&mapping)?;
let mut value = serde_json::to_value(mapping).expect("serializable mapping");
value["spaceRootPrefix"] = Value::String(space_root_prefix);
Ok(value)
})
}
Err(error) => Err(error.into()),
},
"mapping.remove" => {
let id = request
.arguments
@ -1087,7 +1143,9 @@ async fn handle_update(state: &mut StateStore, arguments: &Value) -> Result<Valu
async fn run_scheduler(state_db: PathBuf, transfer_gate: std::sync::Arc<Semaphore>) -> Result<()> {
let (event_sender, mut event_receiver) = tokio::sync::mpsc::unbounded_channel();
let mut watcher = notify::recommended_watcher(move |event: notify::Result<notify::Event>| {
if let Ok(event) = event {
if let Ok(event) = event
&& event_triggers_sync(event.kind)
{
let _ = event_sender.send(event.paths);
}
})?;
@ -1107,8 +1165,19 @@ async fn run_scheduler(state_db: PathBuf, transfer_gate: std::sync::Arc<Semaphor
let current = state.mappings()?.into_iter().map(|mapping| (mapping.id.clone(), mapping)).collect::<BTreeMap<_, _>>();
for (id, mapping) in &current {
if !mappings.contains_key(id) {
watcher.watch(&mapping.local_root, RecursiveMode::Recursive)?;
dirty.insert(id.clone(), std::time::Instant::now());
match watcher.watch(&mapping.local_root, RecursiveMode::Recursive) {
Ok(()) => {
dirty.insert(id.clone(), std::time::Instant::now());
}
Err(error) => {
tracing::error!(
mapping_id = %id,
local_root = %mapping.local_root.display(),
error = %error,
"failed to watch mapping; scheduler will retry on refresh"
);
}
}
}
}
for (id, mapping) in &mappings {
@ -1165,6 +1234,24 @@ async fn run_scheduler(state_db: PathBuf, transfer_gate: std::sync::Arc<Semaphor
}
}
fn event_triggers_sync(kind: notify::EventKind) -> bool {
matches!(
kind,
notify::EventKind::Create(_) | notify::EventKind::Modify(_) | notify::EventKind::Remove(_)
)
}
fn spawn_scheduler(state_db: PathBuf, transfer_gate: std::sync::Arc<Semaphore>) {
tokio::spawn(async move {
loop {
if let Err(error) = run_scheduler(state_db.clone(), transfer_gate.clone()).await {
tracing::error!(error = %error, "drosync scheduler stopped; restarting");
tokio::time::sleep(Duration::from_secs(5)).await;
}
}
});
}
const fn drosync_protocol_version() -> &'static str {
"v1"
}
@ -1186,7 +1273,7 @@ pub async fn run(paths: &Paths) -> Result<()> {
let state = StateStore::open(&paths.state_db)?;
state.set_meta("data_dir", &paths.data_dir.to_string_lossy())?;
let transfer_gate = std::sync::Arc::new(Semaphore::new(1));
tokio::spawn(run_scheduler(paths.state_db.clone(), transfer_gate.clone()));
spawn_scheduler(paths.state_db.clone(), transfer_gate.clone());
loop {
let (stream, _) = listener.accept().await?;
let state_db = paths.state_db.clone();
@ -1244,7 +1331,7 @@ async fn run_windows_pipe(paths: &Paths, pipe_name: &str) -> Result<()> {
let state = StateStore::open(&paths.state_db)?;
state.set_meta("data_dir", &paths.data_dir.to_string_lossy())?;
let transfer_gate = std::sync::Arc::new(Semaphore::new(1));
tokio::spawn(run_scheduler(paths.state_db.clone(), transfer_gate.clone()));
spawn_scheduler(paths.state_db.clone(), transfer_gate.clone());
let mut first_instance = true;
loop {
let mut options = ServerOptions::new();
@ -1355,7 +1442,12 @@ pub fn default_log_path(data_dir: &Path) -> PathBuf {
#[cfg(test)]
mod tests {
use super::{MULTIPART_MAX_PART, multipart_part_size};
use super::{
MULTIPART_MAX_PART, event_triggers_sync, multipart_part_size, resolve_bucket_space,
};
use notify::EventKind;
use notify::event::{AccessKind, CreateKind, ModifyKind, RemoveKind};
use serde_json::json;
#[test]
fn one_tib_object_fits_bos_multipart_limits() {
@ -1377,4 +1469,36 @@ mod tests {
assert!(multipart_part_size(size) <= MULTIPART_MAX_PART);
}
}
#[test]
fn bucket_resolves_only_when_scoped_space_is_unique() {
let capabilities = json!({"spaces": [
{"id": "space-a", "bucket": "bucket-a", "rootPrefix": "tenant/ubt"},
{"id": "space-b", "bucket": "bucket-b", "rootPrefix": ""}
]});
assert_eq!(
resolve_bucket_space(&capabilities, " bucket-a ").unwrap(),
("space-a".to_owned(), "tenant/ubt".to_owned())
);
}
#[test]
fn bucket_resolution_fails_closed_for_missing_or_ambiguous_space() {
let capabilities = json!({"spaces": [
{"id": "space-a", "bucket": "bucket-a"},
{"id": "space-b", "bucket": "bucket-a"}
]});
assert!(resolve_bucket_space(&capabilities, "bucket-a").is_err());
assert!(resolve_bucket_space(&capabilities, "bucket-missing").is_err());
assert!(resolve_bucket_space(&capabilities, " ").is_err());
}
#[test]
fn watcher_ignores_reads_but_tracks_content_changes() {
assert!(!event_triggers_sync(EventKind::Access(AccessKind::Any)));
assert!(!event_triggers_sync(EventKind::Other));
assert!(event_triggers_sync(EventKind::Create(CreateKind::Any)));
assert!(event_triggers_sync(EventKind::Modify(ModifyKind::Any)));
assert!(event_triggers_sync(EventKind::Remove(RemoveKind::Any)));
}
}

View File

@ -172,8 +172,19 @@ fn configured_headless_secret_file() -> Result<PathBuf, PlatformError> {
headless_secret_file_path(value.as_deref())
}
#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
fn configured_runtime_secret_file() -> Option<PathBuf> {
std::env::var("DROSYNC_SECRET_FILE").ok().and_then(|value| {
let trimmed = value.trim();
(!trimmed.is_empty()).then(|| PathBuf::from(trimmed))
})
}
#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
pub fn save_credential(profile: &str, token: &str) -> Result<(), PlatformError> {
if let Some(path) = configured_runtime_secret_file() {
return write_headless_secret(&path, token);
}
keyring::Entry::new("drosync", profile)?.set_password(token)?;
Ok(())
}
@ -185,6 +196,9 @@ pub fn save_credential(_profile: &str, token: &str) -> Result<(), PlatformError>
#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
pub fn load_credential(profile: &str) -> Result<String, PlatformError> {
if let Some(path) = configured_runtime_secret_file() {
return read_headless_secret(&path);
}
Ok(keyring::Entry::new("drosync", profile)?.get_password()?)
}
@ -209,6 +223,9 @@ pub fn load_runtime_credential(profile: &str) -> Result<String, PlatformError> {
#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
pub fn delete_credential(profile: &str) -> Result<(), PlatformError> {
if let Some(path) = configured_runtime_secret_file() {
return delete_headless_secret(&path);
}
keyring::Entry::new("drosync", profile)?.delete_credential()?;
Ok(())
}

View File

@ -74,9 +74,12 @@ build_linux_preview() {
exit 1
}
prepare_update_key linux-x86_64
build_workspace
DROSYNC_OUTPUT_DIR="$OUTPUT_DIR" DROSYNC_VERSION="$VERSION" "$ROOT_DIR/packaging/linux/build-deb.sh"
DROSYNC_OUTPUT_DIR="$OUTPUT_DIR" DROSYNC_VERSION="$VERSION" "$ROOT_DIR/packaging/linux/build-portable.sh"
cargo build --locked --manifest-path "$ROOT_DIR/Cargo.toml" --release \
-p drosync-cli -p drosync-daemon
DROSYNC_OUTPUT_DIR="$OUTPUT_DIR" DROSYNC_VERSION="$VERSION" DROSYNC_INCLUDE_GUI=0 \
"$ROOT_DIR/packaging/linux/build-deb.sh"
DROSYNC_OUTPUT_DIR="$OUTPUT_DIR" DROSYNC_VERSION="$VERSION" DROSYNC_INCLUDE_GUI=0 \
"$ROOT_DIR/packaging/linux/build-portable.sh"
}
build_linux_arm64_preview() {

View File

@ -11,6 +11,14 @@ as root:
sudo ./install-systemd-portable.sh --enable
```
The portable binaries require Ubuntu's `libdbus-1-3` runtime package for the
OS credential-store integration. Install it before running the installer:
```bash
sudo apt-get update
sudo apt-get install -y ca-certificates libdbus-1-3
```
The installer uses `/opt/drosync` by default, creates the restricted `drosync`
system account and `/var/lib/drosync`, writes `/etc/systemd/system/drosync.service`,
and does not store access credentials. Configure credentials through the CLI or

View File

@ -62,6 +62,10 @@ cp "$ROOT_DIR/packaging/linux/drosync.service" "$PACKAGE_ROOT/lib/systemd/system
cp "$ROOT_DIR/packaging/linux/drosync-user.service" "$PACKAGE_ROOT/usr/lib/systemd/user/drosync.service"
mkdir -p "$OUTPUT_DIR"
dpkg-deb --root-owner-group --build "$PACKAGE_ROOT" "$OUTPUT_DIR/drosync_${VERSION}_${ARCH}.deb"
(
cd "$OUTPUT_DIR"
sha256sum "drosync_${VERSION}_${ARCH}.deb" >"drosync_${VERSION}_${ARCH}.deb.sha256"
)
if [[ -n "${DROSYNC_DEB_SIGN_KEY:-}" ]]; then
dpkg-sig --sign builder -k "$DROSYNC_DEB_SIGN_KEY" "$OUTPUT_DIR/drosync_${VERSION}_${ARCH}.deb"
fi

View File

@ -56,7 +56,10 @@ chmod 0755 "$PACKAGE_ROOT/install-systemd-portable.sh" "$PACKAGE_ROOT/uninstall-
ARCHIVE="$OUTPUT_DIR/drosync-${VERSION}-${PLATFORM_KEY}.tar.gz"
tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \
-C "$STAGE" -czf "$ARCHIVE" "$PACKAGE_NAME"
sha256sum "$ARCHIVE" >"$ARCHIVE.sha256"
(
cd "$OUTPUT_DIR"
sha256sum "$(basename "$ARCHIVE")" >"$(basename "$ARCHIVE").sha256"
)
if [[ -n "${DROSYNC_GPG_SIGN_KEY:-}" ]]; then
gpg --batch --yes --local-user "$DROSYNC_GPG_SIGN_KEY" --detach-sign --armor "$ARCHIVE"
fi

View File

@ -4,7 +4,7 @@ Section: utils
Priority: optional
Architecture: amd64
Maintainer: D-Robotics <support@example.invalid>
Depends: ca-certificates, debsig-verify, libsecret-1-0
Depends: ca-certificates, debsig-verify, libdbus-1-3, libsecret-1-0
Description: Secure one-way local-to-BOS synchronization client
drosync provides a CLI, daemon, crash recovery, and signed updates. Some
packages additionally include an optional tray GUI.

View File

@ -8,4 +8,10 @@ if ! getent passwd drosync >/dev/null 2>&1; then
adduser --system --ingroup drosync --home /var/lib/drosync --no-create-home drosync
fi
install -d -o drosync -g drosync -m 0700 /var/lib/drosync
install -d -o drosync -g drosync -m 0700 /var/lib/drosync/config
install -d -o root -g root -m 0755 /etc/drosync
if [ ! -e /etc/drosync/environment ]; then
printf '%s\n' 'DROSYNC_SECRET_FILE=/var/lib/drosync/token' >/etc/drosync/environment
chmod 0644 /etc/drosync/environment
fi
systemctl daemon-reload

View File

@ -12,7 +12,7 @@ User=drosync
Group=drosync
Environment=HOME=/var/lib/drosync
Environment=XDG_DATA_HOME=/var/lib/drosync
Environment=XDG_CONFIG_HOME=/etc/drosync
Environment=XDG_CONFIG_HOME=/var/lib/drosync/config
EnvironmentFile=-/etc/drosync/environment
NoNewPrivileges=true
PrivateTmp=true

View File

@ -12,7 +12,7 @@ User=drosync
Group=drosync
Environment=HOME=/var/lib/drosync
Environment=XDG_DATA_HOME=/var/lib/drosync
Environment=XDG_CONFIG_HOME=/etc/drosync
Environment=XDG_CONFIG_HOME=/var/lib/drosync/config
EnvironmentFile=-/etc/drosync/environment
NoNewPrivileges=true
PrivateTmp=true

View File

@ -48,6 +48,11 @@ for binary in drosync drosync-daemon; do
}
done
if ! ldconfig -p 2>/dev/null | grep -Fq 'libdbus-1.so.3'; then
echo "missing runtime dependency libdbus-1.so.3; install it with: apt-get install libdbus-1-3" >&2
exit 1
fi
if ! getent group drosync >/dev/null 2>&1; then
groupadd --system drosync
fi
@ -55,7 +60,12 @@ if ! getent passwd drosync >/dev/null 2>&1; then
useradd --system --gid drosync --home-dir /var/lib/drosync --no-create-home --shell /usr/sbin/nologin drosync
fi
install -d -o drosync -g drosync -m 0700 /var/lib/drosync
install -d -o drosync -g drosync -m 0700 /var/lib/drosync/config
install -d -m 0755 /etc/drosync "$INSTALL_ROOT"
if [[ ! -e /etc/drosync/environment ]]; then
printf '%s\n' 'DROSYNC_SECRET_FILE=/var/lib/drosync/token' >/etc/drosync/environment
chmod 0644 /etc/drosync/environment
fi
install -m 0755 "$SOURCE_DIR/drosync" "$INSTALL_ROOT/drosync"
install -m 0755 "$SOURCE_DIR/drosync-daemon" "$INSTALL_ROOT/drosync-daemon"
if [[ -f "$SOURCE_DIR/drosync-gui" ]]; then