mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-02 05:52:16 +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
|
||||||
|
|
12
README.md
12
README.md
|
@ -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.
|
||||||
|
|
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