X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=rootsshsync;h=97d2d2f779919413058d70b1ec8282a2a468682e;hb=b857462732e15f455e41f26e3048a390d7b399c0;hp=9d9140af8ac75e39d4c1f599ddb2e8ca2c139fa6;hpb=f3e6a97425746ed185c28dcc03acf7e67a6af560;p=distro-setup diff --git a/rootsshsync b/rootsshsync index 9d9140a..97d2d2f 100755 --- a/rootsshsync +++ b/rootsshsync @@ -23,10 +23,15 @@ if test -e /q/root/.ssh; then /a/exe/lnf $dest /root else dest=/root/.ssh - mkdir -p /root/.ssh - chmod 700 /root/.ssh + mkdir -p $dest + chmod 700 $dest fi + +user_ssh_dir=$(eval echo ~${SUDO_USER:-$USER})/.ssh + +# remove broken links, or else rsync has error about them. +find $user_ssh_dir -xtype l -exec rm '{}' \; # -t times, so it won't rewrite the file every time, # -L resolve links -rsync -rtL $(eval echo ~${SUDO_USER:-$USER})/.ssh/ $dest +rsync -rtL --delete $user_ssh_dir/ $dest chown -R root:root /root/.ssh