From 24f37007436f7f91c42ff4c38e049991e418235b Mon Sep 17 00:00:00 2001 From: Marcel Wiget Date: Sat, 31 Dec 2016 16:04:33 +0100 Subject: [PATCH 1/2] Use uid_t instead of __uid_t Set variable type to uid_t. Required to compile on Alpine Linux (and possibly others) --- pCloudCC/lib/pclsync/pcompat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pCloudCC/lib/pclsync/pcompat.c b/pCloudCC/lib/pclsync/pcompat.c index 41cc8a36..fefbd311 100644 --- a/pCloudCC/lib/pclsync/pcompat.c +++ b/pCloudCC/lib/pclsync/pcompat.c @@ -127,7 +127,7 @@ int psync_user_is_admin(){ return 1; return 0; #else - __uid_t uid; + uid_t uid; if ((uid = geteuid()) == 0) { debug(D_NOTICE, "Root effective user detected! Uid is %d", uid); return 1; From ab4acc3638bd6bdbde3ea3deda45a3b7b8cf3763 Mon Sep 17 00:00:00 2001 From: Marcel Wiget Date: Mon, 2 Jan 2017 14:33:29 +0100 Subject: [PATCH 2/2] pcloud docker container --- docker/Dockerfile | 12 ++++++ docker/README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..40305895 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:latest + +RUN apk add --no-cache boost zlib fuse tini + +RUN apk add --no-cache --virtual build-dependencies cmake \ + boost g++ make fuse-dev zlib-dev boost-dev git && \ + git clone https://github.com/mwiget/console-client.git && \ + cd console-client && cmake pCloudCC && \ + make && make install && \ + apk del build-dependencies && cd .. && rm -rf console-client + +ENTRYPOINT ["/sbin/tini", "/usr/local/bin/pcloudcc"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..995350a7 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,102 @@ +## pCloud Docker Container + +The Dockerfile downloads and builds the simple linux client for pCloud cloud storage into a tiny +alpine Linux container. + +### Build instruction + +``` +docker build -f Dockerfile -t pcloud . +``` + +Use 'docker images' to show the created container image: + +``` +core@m1 ~/pcloud $ docker images +REPOSITORY TAG IMAGE ID CREATED SIZE +pcloud latest c1a2d69d3699 About a minute ago 19.02 MB +``` + +### Usage + +The container requires privileged mode in order to expose the Fuse based file system to the host. +The default path of the mount point within the container is /root/pCloudDrive with supporting +files in /root/.pcloud (which contains e.g. the saved password). In order to gain persistency +between reboots and container restarts, the /root directory must be exposed and shared with the host. +This is done via the docker run '-v' option combined with ':shared'. + +Because the pcloudcc client doesn't offer a command line option to set the password or read from a file, the container must be launched once in interactive mode to set and save the password. + +Launch the pcloud container with your pcloud username and options to set and save the password. +Once the message 'status is READY' is shown, you can stop the container with Ctrl-C (to relaunch it later as a daemon). + +``` +/usr/bin/docker run --name pcloud -ti --rm --privileged -v /pCloud:/root:shared pcloud -u -p -s +pCloud console client v.2.0.1 +Please, enter password + +sh: lsb_release: not found +Down: Everything Downloaded| Up: Everything Uploaded, status is LOGIN_REQUIRED +logging in +Down: Everything Downloaded| Up: Everything Uploaded, status is CONNECTING +Down: Everything Downloaded| Up: Everything Uploaded, status is SCANNING +event1073741824 +event1073741825 +Down: Everything Downloaded| Up: Everything Uploaded, status is READY +^C +``` + +This initial run created the directory /pCloud on the host with the .pcloud pCloudDriver directories, though the latter is empty without a running container: + +``` +$ ls -la /pCloud/ +total 16 +drwxr-xr-x 4 root root 4096 Jan 2 13:53 . +drwxr-xr-x 26 root root 4096 Jan 2 13:53 .. +drwxr-xr-x 3 root root 4096 Jan 2 13:53 .pcloud +drwxr-xr-x 2 root root 4096 Jan 2 13:53 pCloudDrive +``` + +Launch the container as daemon: + +``` +docker run --name pcloud -d --privileged -v /pCloud:/root:shared pcloud -u +``` + +Verify the content of pCloudDrive: + +``` +$ ls /pCloud/pCloudDrive/ +Crypto Folder My Pictures Screenshots pCloud Sync +My Music My Videos Shared pCloud Help +``` + +### Systemd + +Once an initial password has been set, the container can be managed automatically via systemd using the following service file: + +``` +$ cat /etc/systemd/system/pcloud.service +[Unit] +Description=pCloud +After=docker.service +Requires=docker.service + +[Service] +TimeoutStartSec=0 +ExecStartPre=-/usr/bin/docker kill pcloud +ExecStartPre=-/usr/bin/docker rm pcloud +ExecStart=/usr/bin/docker run --name pcloud -i --rm --privileged -v /pCloud:/root:shared pcloud -u + +[Install] +WantedBy=multi-user.target +``` + +Enable and run the pcloud service with + +``` +sudo systemctl enable /etc/systemd/system/pcloud.service +sudo systemctl start pcloud.service +``` + +