Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RUNAS_USER to control the user running resilio-sync #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -54,6 +54,16 @@ To change maxmimum file size to 50 MB add

to the docker start command

### RUNAS_USER

This variable (along with RUNAS_UID, RUNAS_GROUP and RUNAS_GID) provide a way to control which user will run Resilio Sync and own the synced files.
Useful when dealing with shared volumes.

### LOG_TO_STDOUT

The default logging uses file /var/log/rslsync.log.
By defining the LOG_TO_STDOUT variable the Resilio Sync logs are outputted to stdout.

### syncing local files

Inside the container the /data is the default sync directory, to link this to a local file system you can use the **-v** flag
22 changes: 20 additions & 2 deletions root/etc/run_once/config_rslsync
Original file line number Diff line number Diff line change
@@ -21,18 +21,36 @@ if [ -z $RSLSYNC_PATH ]; then
RSLSYNC_PATH="/data"
fi

# prepare to run as a different user

if [ -z $RUNAS_USER ]; then
USER_HOME="/root"
else
USER_HOME="/home/$RUNAS_USER"
addgroup -g $RUNAS_GID -S $RUNAS_GROUP
adduser -u $RUNAS_UID -D -S -G $RUNAS_GROUP $RUNAS_USER

chown -R $RUNAS_USER /etc/rslsync
if [ -z $LOG_TO_STDOUT ]; then
touch /var/log/rslsync.log
chown -R $RUNAS_USER /var/log/rslsync.log
fi

chown -R $RUNAS_USER $RSLSYNC_PATH
fi

# create base configuration

cat <<EOT > /etc/rslsync/rslsync.conf
{
"storage_path" : "/root",
"storage_path" : "$USER_HOME",
"listening_port" : 33333,
"use_upnp" : false,
"vendor" : "docker",
"max_file_size_for_versioning" : $RSLSYNC_SIZE,
"sync_trash_ttl" : $RSLSYNC_TRASH_TIME,
"device_name" : "$RSLSYNC_NAME",
"pid_file" : "/var/run/rslsync.pid",
"pid_file" : "$USER_HOME/rslsync.pid",
EOT
# check to see if webui should be activated

7 changes: 6 additions & 1 deletion root/etc/sv/rslsync/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/bin/sh
exec 2>&1
exec /usr/local/bin/rslsync --config /etc/rslsync/rslsync.conf --log /var/log/rslsync.log --nodaemon
source /etc/envvars
LOG_LOCATION=""
if [ -z $LOG_TO_STDOUT ]; then
LOG_LOCATION=" --log /var/log/rslsync.log "
fi
su -c "/usr/local/bin/rslsync --config /etc/rslsync/rslsync.conf $LOG_LOCATION --nodaemon" -s /bin/sh $RUNAS_USER