mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-15 20:26:53 +02:00
Docker buildfiles for onedrive service (#262)
* Separate install options for binary (make install.noservice) only and binary * Docker build files and usage documentation
This commit is contained in:
parent
b10e641fe9
commit
026809d4d1
11
Makefile
11
Makefile
|
@ -31,13 +31,18 @@ all: onedrive onedrive.service onedrive.1
|
||||||
clean:
|
clean:
|
||||||
rm -f onedrive onedrive.o onedrive.service onedrive@.service onedrive.1
|
rm -f onedrive onedrive.o onedrive.service onedrive@.service onedrive.1
|
||||||
|
|
||||||
install: all
|
onedrive: version $(SOURCES)
|
||||||
|
$(DC) $(DFLAGS) $(SOURCES)
|
||||||
|
|
||||||
|
install.noservice: onedrive onedrive.1
|
||||||
mkdir -p $(DESTDIR)/var/log/onedrive
|
mkdir -p $(DESTDIR)/var/log/onedrive
|
||||||
chown root.users $(DESTDIR)/var/log/onedrive
|
chown root.users $(DESTDIR)/var/log/onedrive
|
||||||
chmod 0775 $(DESTDIR)/var/log/onedrive
|
chmod 0775 $(DESTDIR)/var/log/onedrive
|
||||||
install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive
|
install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive
|
||||||
install -D onedrive.1 $(DESTDIR)$(MANDIR)/onedrive.1
|
install -D onedrive.1 $(DESTDIR)$(MANDIR)/onedrive.1
|
||||||
install -D -m 644 logrotate/onedrive.logrotate $(DESTDIR)/etc/logrotate.d/onedrive
|
install -D -m 644 logrotate/onedrive.logrotate $(DESTDIR)/etc/logrotate.d/onedrive
|
||||||
|
|
||||||
|
install: all install.noservice
|
||||||
for i in $(DOCFILES) ; do install -D -m 644 $$i $(DESTDIR)$(DOCDIR)/$$i ; done
|
for i in $(DOCFILES) ; do install -D -m 644 $$i $(DESTDIR)$(DOCDIR)/$$i ; done
|
||||||
ifeq ($(RHEL),1)
|
ifeq ($(RHEL),1)
|
||||||
mkdir -p $(DESTDIR)/usr/lib/systemd/system/
|
mkdir -p $(DESTDIR)/usr/lib/systemd/system/
|
||||||
|
@ -54,9 +59,7 @@ else
|
||||||
chmod 0755 $(DESTDIR)/usr/lib/systemd/system/
|
chmod 0755 $(DESTDIR)/usr/lib/systemd/system/
|
||||||
install -D -m 644 onedrive@.service $(DESTDIR)/usr/lib/systemd/system/
|
install -D -m 644 onedrive@.service $(DESTDIR)/usr/lib/systemd/system/
|
||||||
endif
|
endif
|
||||||
|
install -D -m 644 onedrive.service $(DESTDIR)/usr/lib/systemd/user/onedrive.service
|
||||||
onedrive: version $(SOURCES)
|
|
||||||
$(DC) $(DFLAGS) $(SOURCES)
|
|
||||||
|
|
||||||
onedrive.service:
|
onedrive.service:
|
||||||
sed "s|@PREFIX@|$(PREFIX)|g" systemd.units/onedrive.service.in > onedrive.service
|
sed "s|@PREFIX@|$(PREFIX)|g" systemd.units/onedrive.service.in > onedrive.service
|
||||||
|
|
24
README.md
24
README.md
|
@ -57,7 +57,7 @@ wget http://ftp.us.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.1+20180714-
|
||||||
sudo dpkg -i ./*.deb
|
sudo dpkg -i ./*.deb
|
||||||
```
|
```
|
||||||
|
|
||||||
### Dependencies: Fedora < Version 18 / CentOS / RHEL
|
### Dependencies: Fedora < Version 18 / CentOS / RHEL
|
||||||
```
|
```
|
||||||
sudo yum groupinstall 'Development Tools'
|
sudo yum groupinstall 'Development Tools'
|
||||||
sudo yum install libcurl-devel
|
sudo yum install libcurl-devel
|
||||||
|
@ -65,7 +65,7 @@ sudo yum install sqlite-devel
|
||||||
curl -fsS https://dlang.org/install.sh | bash -s dmd
|
curl -fsS https://dlang.org/install.sh | bash -s dmd
|
||||||
```
|
```
|
||||||
|
|
||||||
### Dependencies: Fedora > Version 18
|
### Dependencies: Fedora > Version 18
|
||||||
```
|
```
|
||||||
sudo dnf groupinstall 'Development Tools'
|
sudo dnf groupinstall 'Development Tools'
|
||||||
sudo dnf install libcurl-devel
|
sudo dnf install libcurl-devel
|
||||||
|
@ -151,6 +151,18 @@ make DC=~/ldc2-1.11.0-linux-aarch64/bin/ldmd2
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Docker onedrive monitor
|
||||||
|
```
|
||||||
|
# Update onedriveDir with correct existing OneDrive directory path
|
||||||
|
onedriveDir="${HOME}/OneDrive"
|
||||||
|
|
||||||
|
firstRun='-d'
|
||||||
|
docker pull driveone/onedrive
|
||||||
|
docker inspect onedrive_conf > /dev/null || { docker volume create onedrive_conf; firstRun='-it'; }
|
||||||
|
docker inspect onedrive > /dev/null && docker rm -f onedrive
|
||||||
|
docker run $firstRun --restart unless-stopped --name onedrive -v onedrive_conf:/onedrive/conf -v "${onedriveDir}:/onedrive/data" driveone/onedrive
|
||||||
|
```
|
||||||
|
|
||||||
## Using the client
|
## Using the client
|
||||||
### Upgrading from 'skilion' client
|
### Upgrading from 'skilion' client
|
||||||
The 'skilion' version contains a significant number of defect's in how the local sync state is managed. When upgrading from the 'skilion' version to this version, it is advisable to stop any service / onedrive process from running and then remove any `items.sqlite3` file from your configuration directory (`~/.config/onedrive/`) as this will force the creation of a new local cache file.
|
The 'skilion' version contains a significant number of defect's in how the local sync state is managed. When upgrading from the 'skilion' version to this version, it is advisable to stop any service / onedrive process from running and then remove any `items.sqlite3` file from your configuration directory (`~/.config/onedrive/`) as this will force the creation of a new local cache file.
|
||||||
|
@ -189,7 +201,7 @@ onedrive --synchronize --download-only
|
||||||
### Performing a 'one-way' upload sync
|
### Performing a 'one-way' upload sync
|
||||||
In some cases it may be desirable to 'upload only' to OneDrive. To do this use the following command:
|
In some cases it may be desirable to 'upload only' to OneDrive. To do this use the following command:
|
||||||
```
|
```
|
||||||
onedrive --synchronize --upload-only
|
onedrive --synchronize --upload-only
|
||||||
```
|
```
|
||||||
|
|
||||||
### Increasing logging level
|
### Increasing logging level
|
||||||
|
@ -263,14 +275,14 @@ rm -f ~/.config/onedrive/refresh_token
|
||||||
```
|
```
|
||||||
|
|
||||||
## Additional Configuration
|
## Additional Configuration
|
||||||
Additional configuration is optional.
|
Additional configuration is optional.
|
||||||
If you want to change the defaults, you can copy and edit the included config file into your `~/.config/onedrive` directory:
|
If you want to change the defaults, you can copy and edit the included config file into your `~/.config/onedrive` directory:
|
||||||
```sh
|
```sh
|
||||||
mkdir -p ~/.config/onedrive
|
mkdir -p ~/.config/onedrive
|
||||||
cp ./config ~/.config/onedrive/config
|
cp ./config ~/.config/onedrive/config
|
||||||
nano ~/.config/onedrive/config
|
nano ~/.config/onedrive/config
|
||||||
```
|
```
|
||||||
This file does not get created by default, and should only be created if you want to change the 'default' operational parameters.
|
This file does not get created by default, and should only be created if you want to change the 'default' operational parameters.
|
||||||
|
|
||||||
Available options:
|
Available options:
|
||||||
* `sync_dir`: directory where the files will be synced
|
* `sync_dir`: directory where the files will be synced
|
||||||
|
@ -371,7 +383,7 @@ In some cases it is desirable to run the OneDrive client as a service, but not r
|
||||||
|
|
||||||
1. As the user, who will be running the service, run the application in standalone mode, authorize the application for use & validate that the synchronization is working as expected:
|
1. As the user, who will be running the service, run the application in standalone mode, authorize the application for use & validate that the synchronization is working as expected:
|
||||||
```
|
```
|
||||||
onedrive --synchronize --verbose
|
onedrive --synchronize --verbose
|
||||||
```
|
```
|
||||||
2. Once the application is validated and working for your user, as the 'root' user, where <username> is your username from step 1 above.
|
2. Once the application is validated and working for your user, as the 'root' user, where <username> is your username from step 1 above.
|
||||||
```
|
```
|
||||||
|
|
25
docker/Dockerfile
Normal file
25
docker/Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
FROM centos
|
||||||
|
ENV GOSU_VERSION=1.11
|
||||||
|
|
||||||
|
RUN yum install -y make git gcc libcurl-devel sqlite-devel && \
|
||||||
|
rm -rf /var/cache/yum/ && \
|
||||||
|
curl -fsS https://dlang.org/install.sh | bash -s dmd && \
|
||||||
|
# gosu installation
|
||||||
|
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
|
||||||
|
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \
|
||||||
|
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc" \
|
||||||
|
&& gpg --verify /usr/local/bin/gosu.asc \
|
||||||
|
&& rm /usr/local/bin/gosu.asc \
|
||||||
|
&& rm -r /root/.gnupg/ \
|
||||||
|
&& chmod +x /usr/local/bin/gosu \
|
||||||
|
&& gosu nobody true
|
||||||
|
RUN mkdir -p /onedrive/conf /onedrive/data
|
||||||
|
ADD onedrive /usr/src/onedrive
|
||||||
|
RUN . /root/dlang/dmd-2.083.0/activate && \
|
||||||
|
cd /usr/src/onedrive && \
|
||||||
|
make install.noservice && \
|
||||||
|
make clean
|
||||||
|
ADD entrypoint.sh /entrypoint.sh
|
||||||
|
VOLUME ["/onedrive/conf"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
55
docker/README.md
Normal file
55
docker/README.md
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# onedrive docker image
|
||||||
|
|
||||||
|
Thats right folks onedrive is now dockerized ;)
|
||||||
|
|
||||||
|
This container offers simple monitoring-mode service for 'Free Client for OneDrive on Linux'.
|
||||||
|
|
||||||
|
## Usage instructions
|
||||||
|
```
|
||||||
|
docker pull driveone/onedrive
|
||||||
|
```
|
||||||
|
NOTE:
|
||||||
|
> SELinux context needs to be configured or disabled for Docker, to be able to write to OneDrive host directory.
|
||||||
|
|
||||||
|
|
||||||
|
1. Run or update onedrive container
|
||||||
|
```
|
||||||
|
# Update onedriveDir with correct existing OneDrive directory path
|
||||||
|
onedriveDir="${HOME}/OneDrive"
|
||||||
|
|
||||||
|
firstRun='-d'
|
||||||
|
docker pull driveone/onedrive
|
||||||
|
docker inspect onedrive_conf > /dev/null || { docker volume create onedrive_conf; firstRun='-it'; }
|
||||||
|
docker inspect onedrive > /dev/null && docker rm -f onedrive
|
||||||
|
docker run $firstRun --restart unless-stopped --name onedrive -v onedrive_conf:/onedrive/conf -v "${onedriveDir}:/onedrive/data" driveone/onedrive
|
||||||
|
```
|
||||||
|
|
||||||
|
## Poweruser section
|
||||||
|
1. Check if monitor service is running
|
||||||
|
```
|
||||||
|
docker ps -f name=onedrive
|
||||||
|
```
|
||||||
|
2. Show monitor run logs
|
||||||
|
```
|
||||||
|
docker logs onedrive
|
||||||
|
```
|
||||||
|
3. Stop running monitor
|
||||||
|
```
|
||||||
|
docker stop onedrive
|
||||||
|
```
|
||||||
|
4. Resume monitor
|
||||||
|
```
|
||||||
|
docker start onedrive
|
||||||
|
```
|
||||||
|
5. Unregister onedrive monitor
|
||||||
|
```
|
||||||
|
docker rm -f onedrive
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build instructions
|
||||||
|
```
|
||||||
|
cd docker
|
||||||
|
git clone https://github.com/abraunegg/onedrive
|
||||||
|
docker build . -t driveone/onedrive
|
||||||
|
```
|
||||||
|
|
26
docker/entrypoint.sh
Executable file
26
docker/entrypoint.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash -eu
|
||||||
|
|
||||||
|
set +H -xeuo pipefail
|
||||||
|
|
||||||
|
ONEDRIVE_UID=$(stat /onedrive/data -c '%u')
|
||||||
|
ONEDRIVE_GID=$(stat /onedrive/data -c '%g')
|
||||||
|
|
||||||
|
# Create new group using target GID
|
||||||
|
if ! odgroup="$(getent group $ONEDRIVE_GID)"; then
|
||||||
|
odgroup='onedrive'
|
||||||
|
groupadd "${odgroup}" -g $ONEDRIVE_GID
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create new user using target UID
|
||||||
|
if ! oduser="$(getent passwd $ONEDRIVE_UID)"; then
|
||||||
|
oduser='onedrive'
|
||||||
|
useradd "${oduser}" -u $ONEDRIVE_UID -g $ONEDRIVE_GID
|
||||||
|
else
|
||||||
|
oduser="${oduser%%:*}"
|
||||||
|
odgroup="${odgroup%%:*}"
|
||||||
|
usermod -g "${odgroup}" "${oduser}"
|
||||||
|
grep -qv root <( groups "${oduser}" ) || { echo 'ROOT level priviledges prohibited!'; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown "${oduser}:${odgroup}" /onedrive/ /onedrive/conf
|
||||||
|
exec gosu "${oduser}" /usr/local/bin/onedrive --monitor --verbose --confdir /onedrive/conf --syncdir /onedrive/data
|
Loading…
Reference in a new issue