iankelling.org
/
git
/
distro-setup
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mostly fix mail bugs
[distro-setup]
/
rootsshsync
diff --git
a/rootsshsync
b/rootsshsync
index 592a5aafe8cc14c2c1efdc12e4215497233eefc0..e962f19295b9b1918b70cd8f3ed48f788939fbef 100755
(executable)
--- a/
rootsshsync
+++ b/
rootsshsync
@@
-16,10
+16,17
@@
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-if sudo test -e /q/root/.ssh; then
- sudo /a/exe/lnf /q/root/.ssh /root
+[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
+
+if test -e /q/root/.ssh; then
+ dest=/q/root/.ssh
+ /a/exe/lnf $dest /root
else
else
- sudo mkdir /root/.ssh
+ dest=/root/.ssh
+ mkdir -p /root/.ssh
+ chmod 700 /root/.ssh
fi
fi
-sudo cp -rL $(eval echo ~${SUDO_USER:-$USER})/.ssh/* /root/.ssh
-sudo chown -R root:root /root/.ssh
+# -t times, so it won't rewrite the file every time,
+# -L resolve links
+rsync -rtL $(eval echo ~${SUDO_USER:-$USER})/.ssh $dest
+chown -R root:root /root/.ssh