Skip to content

Commit

Permalink
Merge pull request #28 from frizop/master
Browse files Browse the repository at this point in the history
Allow UID/GID for backup user
  • Loading branch information
odarriba committed Sep 25, 2017
2 parents 044e1dd + a753e03 commit 9ef27f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ To add a user, run:
$ docker exec timemachine add-account USERNAME PASSWORD VOL_NAME VOL_ROOT [VOL_SIZE_MB]
```

Or, if you want to add a user with a specific UID/GID, use the following format

```
$ docker exec timemachine add account -i 1000 -g 1000 USERNAME PASSWORD VOL_NAME VOL_ROOT [VOL_SIZE_MB]
```

But take care that:
* `VOL_NAME` will be the name of the volume shown on your OSX as the network drive
* `VOL_ROOT` should be an absolute path, preferably a sub-path of `/timemachine` (e.g., `/timemachine/backup`), so it will be stored in the according sub-path of your external volume.
Expand Down
28 changes: 21 additions & 7 deletions bin/add-account
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
#!/bin/bash

while getopts ":i:g:e:" Option
do
case $Option in
i ) _uid=$OPTARG ;;
g ) _gid=$OPTARG ;;
esac
done
shift $(($OPTIND - 1))

if [[ $# -lt 4 ]]; then
echo "Usage: add-account USERNAME PASSWORD VOL_NAME VOL_ROOT [VOL_SIZE_MB]"
echo "Usage: add-account [ -i uid -g gid ] USERNAME PASSWORD VOL_NAME VOL_ROOT [VOL_SIZE_MB]"
exit 1
fi


# Add the user
adduser -S -H -G root $1
echo $1:$2 | chpasswd

# Create mountpoint
mkdir -p ${4}
chown -R $1:root ${4}

if [[ $_uid ]] && [[ $_gid ]]; then
addgroup -g $_gid $1
adduser -u $_uid -S -H $1
chown -R $1:$1 ${4}
else
adduser -S -H -G root $1
chown -R $1:root ${4}
fi

echo $1:$2 | chpasswd

# Add config to timemachine
echo "
Expand Down

0 comments on commit 9ef27f0

Please sign in to comment.