Repository navigation
Expand file tree
/
Copy pathtaskfile.yml
More file actions
75 lines (66 loc) · 6.42 KB
/
Copy pathtaskfile.yml
File metadata and controls
75 lines (66 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Tasks contributed by the cloud-folder Feature (namespace: cloud-folder).
# CLOUD_FOLDER_MODE, CLOUD_FOLDER_MOUNT_POINT, CLOUD_FOLDER_REMOTE_TYPE, CLOUD_FOLDER_DRIVE_TYPE,
# CLOUD_FOLDER_SITE_URL, CLOUD_FOLDER_REMOTE_PATH and CLOUD_FOLDER_SYNC_INTERVAL, from the command
# line, a .env file or the environment (in that order, as Task resolves them), override the
# Feature options for one call. Secrets (CLOUD_FOLDER_CLIENT_SECRET*) are read from the
# environment only, never put on a command line.
version: '3'
tasks:
version:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Show the cloud-folder Feature version, the mode option and the mode in use, the mount point, the state folder, and the rclone version.'
vars: &cf
CF: '{{if .CLOUD_FOLDER_MODE}}CLOUD_FOLDER_MODE={{shellQuote .CLOUD_FOLDER_MODE}} {{end}}{{if .CLOUD_FOLDER_MOUNT_POINT}}CLOUD_FOLDER_MOUNT_POINT={{shellQuote .CLOUD_FOLDER_MOUNT_POINT}} {{end}}{{if .CLOUD_FOLDER_REMOTE_TYPE}}CLOUD_FOLDER_REMOTE_TYPE={{shellQuote .CLOUD_FOLDER_REMOTE_TYPE}} {{end}}{{if .CLOUD_FOLDER_DRIVE_TYPE}}CLOUD_FOLDER_DRIVE_TYPE={{shellQuote .CLOUD_FOLDER_DRIVE_TYPE}} {{end}}{{if .CLOUD_FOLDER_SITE_URL}}CLOUD_FOLDER_SITE_URL={{shellQuote .CLOUD_FOLDER_SITE_URL}} {{end}}{{if .CLOUD_FOLDER_REMOTE_PATH}}CLOUD_FOLDER_REMOTE_PATH={{shellQuote .CLOUD_FOLDER_REMOTE_PATH}} {{end}}{{if .CLOUD_FOLDER_SYNC_INTERVAL}}CLOUD_FOLDER_SYNC_INTERVAL={{shellQuote .CLOUD_FOLDER_SYNC_INTERVAL}} {{end}}'
cmds:
- '{{.CF}}cloud-folder-setup version'
status:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Report on the cloud folder: the mode in use and why; in host mode whether the mount point is mounted, empty and writable; in sync mode the remote (configured, reachable; no token is printed), the last sync (time, result), whether a sync or the timer runs, and the files changed since the last sync; in mount mode the remote, whether FUSE is usable and why not, whether rclone is mounted, and the VFS upload queue (in progress, queued, failed) from rclone''s remote control. Exit 0 when the folder is usable (an empty folder is reported, not failed), 1 when it is missing, not mounted, not writable, has no remote, was never synced, its last sync failed, has no FUSE (mount), has failed uploads, or the mode is unknown, so a start-up check can stop. `-- --json` prints one JSON object for agents. Writes nothing into the folder.'
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup status {{.CLI_ARGS}}'
setup:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Re-run the post-start hook: hand the state volume (and in sync and mount mode the folder) to this user, mount the remote in mount mode if it is not mounted, the same report as status, and in sync mode start the timer if it is not running. Never fatal (exit 0).'
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup'
login:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Sign in for sync and mount mode, the same command in the container and (devcontainer-cli 1.16.0 or later, with the bootstrap''s cloud-folder include) on the workstation, where the launcher relays the browser into the container. Here it runs rclone authorize "onedrive" in the container with the browser not opened and prints the sign-in address; sign in in any browser, then paste the address the browser fails to open afterwards (http://localhost:53682/?code=...), or the one-line token from rclone authorize "onedrive" on a machine with a browser. Read without echo; the token goes only into the Feature volume''s rclone.conf (mode 600). Then finds the drive from siteUrl (remoteType sharepoint) or the person''s OneDrive, checks the remote answers and starts the timer. `-- --token` asks for the token only; `-- --relay` is the launcher''s (it waits for the relayed browser). CLOUD_FOLDER_LOGIN_TIMEOUT (seconds, default 600) bounds the wait. With CLOUD_FOLDER_CLIENT_ID, CLOUD_FOLDER_TENANT and CLOUD_FOLDER_CLIENT_SECRET_FILE (or CLOUD_FOLDER_CLIENT_SECRET) in the environment it uses client credentials instead, without a prompt (unverified, see the Feature NOTES). CLOUD_FOLDER_DRIVE_ID skips the drive lookup.'
interactive: true
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup login {{.CLI_ARGS}}'
sync:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Run one rclone bisync between the remote and the folder now (the first sync of a folder is a --resync on its own). `-- --resync` forces one; `-- --force` lets a sync through bisync''s delete guard (more than half of one side deleted) when the deletion is meant. Exit 0 ok, 1 failed, 7 bisync wants a --resync, 3 cannot sync here (mode, sign-in), 4 another sync runs.'
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup sync {{.CLI_ARGS}}'
start:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Sync mode: start the sync timer (one loop, every syncInterval). Mount mode: mount the remote with rclone (needs FUSE). The post-start hook does this. Idempotent: a running timer or mount is left as it is. syncInterval 0 starts no timer.'
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup start'
stop:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Sync mode: stop the sync timer; a sync that is running gets bisync''s graceful shutdown first (up to about 100 s). Mount mode: unmount, as cloud-folder:unmount does. Exit 1 when it is still finishing after CLOUD_FOLDER_STOP_WAIT seconds (default 120).'
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup stop'
unmount:
dir: '{{.USER_WORKING_DIR}}'
desc: 'Mount mode: unmount the remote once the VFS upload queue is empty, waiting up to CLOUD_FOLDER_STOP_WAIT seconds (default 120); exit 1 while uploads are pending or the queue cannot be read. `-- --force` unmounts anyway: rclone uploads what is left in the cache at the next mount.'
vars: *cf
cmds:
- '{{.CF}}cloud-folder-setup unmount {{.CLI_ARGS}}'
shutdown-check:
dir: '{{.USER_WORKING_DIR}}'
desc: 'For a repository''s shutdown:check (bootstrap/SHUTDOWN.md): exit 1 while a sync runs (after waiting up to WAIT seconds, default 60) or while files in the folder changed since the last successful sync; in mount mode while uploads are pending after waiting, or the upload queue cannot be read; exit 0 otherwise, and in host mode.'
vars:
CF: '{{if .CLOUD_FOLDER_MODE}}CLOUD_FOLDER_MODE={{shellQuote .CLOUD_FOLDER_MODE}} {{end}}{{if .CLOUD_FOLDER_MOUNT_POINT}}CLOUD_FOLDER_MOUNT_POINT={{shellQuote .CLOUD_FOLDER_MOUNT_POINT}} {{end}}'
WAIT: '{{.WAIT | default ""}}'
cmds:
- '{{.CF}}cloud-folder-setup shutdown-check {{.WAIT}}'