Skip to content

Instantly share code, notes, and snippets.

@monaka
Last active December 6, 2017 01:21
Show Gist options
  • Save monaka/5cb1f33e5317e29285843f158a387c9b to your computer and use it in GitHub Desktop.
Save monaka/5cb1f33e5317e29285843f158a387c9b to your computer and use it in GitHub Desktop.
[Unit]
Description=Copy CIFS mount
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=0
ExecStartPre = -/usr/bin/mkdir -p /opt/sbin
ExecStart=/bin/sh -c "rm -fr /opt/sbin && rsync -a /usr/sbin/ /opt/sbin/ && /usr/bin/docker run --rm -v /opt/sbin:/target so0k/mount.cifs_copy /target && mount --bind /opt/sbin/ /usr/sbin/"
[Install]
WantedBy = multi-user.target
@shanoor
Copy link

shanoor commented Jul 19, 2016

Thanks! However, this doesn't work on a brand new CoreOS install because rsync can't create folders recursively (error: rsync: mkdir "/opt/sbin" failed: No such file or directory). I simply added a ExecStartPre = -/usr/bin/mkdir -p /opt/sbin in [Service].

@monaka
Copy link
Author

monaka commented Sep 28, 2016

@shanoor, nice catch. I added your suggestion.

@deed02392
Copy link

Why create sbin/ in /opt/ if you're just going to rm it immediately? Just create /opt instead to resolve the rsync issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment