From c2c1176f7963d9478a0d6a1064ae8711fea5406c Mon Sep 17 00:00:00 2001 From: Joel Potischman Date: Sun, 19 Dec 2021 17:32:22 -0500 Subject: [PATCH 1/2] Add startup script using environment to configure --- .env.example | 5 ++++ .gitignore | 1 + start-timemachine.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 .env.example create mode 100755 start-timemachine.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8f3888e --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +TM_IP_ADDRESS=192.168.1.100 +TM_SUBNET=192.168.1.0 +TM_GATEWAY=192.168.1.1 +TM_PASSWORD=p@55w0rd +TM_BACKUP_PATH=/path/to/backup-drive diff --git a/.gitignore b/.gitignore index 497d820..3333417 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.env *.swp multi-user/ diff --git a/start-timemachine.sh b/start-timemachine.sh new file mode 100755 index 0000000..770f530 --- /dev/null +++ b/start-timemachine.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# This script creates a macvlan network to place the docker container +# directly on the host network. This allows services to be broadcast +# so the TimeMachine host shows up in Finder without needing to run +# -net=host, which can conflict with host & introduce security issues. +# +# Step 1: Get vars from .env file +export $(grep -v '^#' .env | xargs) + +# Step 2: Create network if not already present +if ! docker network list | grep macvlan ; then \ + docker network create \ + -d macvlan \ + --subnet=$TM_SUBNET/24 \ + --gateway=$TM_GATEWAY \ + -o parent=eth0 macvlan1 +fi + +# Step 3: Create and start docker container it not already present +if ! docker ps | grep timemachine ; then \ + docker run -d --restart=always \ + --name timemachine \ + --hostname timemachine \ + --network macvlan1 \ + --ip $TM_IP_ADDRESS \ + -p 137:137/udp \ + -p 138:138/udp \ + -p 139:139 \ + -p 445:445 \ + -e ADVERTISED_HOSTNAME="TimeMachine" \ + -e CUSTOM_SMB_CONF="false" \ + -e CUSTOM_USER="false" \ + -e DEBUG_LEVEL="1" \ + -e HIDE_SHARES="no" \ + -e EXTERNAL_CONF="" \ + -e MIMIC_MODEL="TimeCapsule8,119" \ + -e TM_USERNAME="timemachine" \ + -e TM_GROUPNAME="timemachine" \ + -e TM_UID="1000" \ + -e TM_GID="1000" \ + -e PASSWORD="$TM_PASSWORD" \ + -e SET_PERMISSIONS="false" \ + -e SHARE_NAME="Backups" \ + -e SMB_INHERIT_PERMISSIONS="no" \ + -e SMB_NFS_ACES="yes" \ + -e SMB_METADATA="stream" \ + -e SMB_PORT="445" \ + -e SMB_VFS_OBJECTS="acl_xattr fruit streams_xattr" \ + -e VOLUME_SIZE_LIMIT="0" \ + -e WORKGROUP="WORKGROUP" \ + -v $TM_BACKUP_PATH:/opt/timemachine \ + -v timemachine-var-lib-samba:/var/lib/samba \ + -v timemachine-var-cache-samba:/var/cache/samba \ + -v timemachine-run-samba:/run/samba \ + mbentley/timemachine:smb +fi From 11d585e463c0d9befed6939649067d50a396d735 Mon Sep 17 00:00:00 2001 From: Joel Potischman Date: Sun, 19 Dec 2021 17:39:46 -0500 Subject: [PATCH 2/2] Fix typo in comment --- start-timemachine.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-timemachine.sh b/start-timemachine.sh index 770f530..daa3a16 100755 --- a/start-timemachine.sh +++ b/start-timemachine.sh @@ -16,7 +16,7 @@ if ! docker network list | grep macvlan ; then \ -o parent=eth0 macvlan1 fi -# Step 3: Create and start docker container it not already present +# Step 3: Create and start docker container if not already present if ! docker ps | grep timemachine ; then \ docker run -d --restart=always \ --name timemachine \