File: copy-ssh-keys.sh

package info (click to toggle)
pglistener 4
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 224 kB
  • ctags: 132
  • sloc: python: 594; perl: 364; sh: 120; sql: 89; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
#
# Copy SSH keys from one directory to another, while changing the owner to
# root and setting the mode to 600.

src="/var/lib/pglistener/sshkeys/"
dst="/var/lib/misc/sshkeys/"

# copy files from $src to $dst
(cd "$src";
    find -maxdepth 1 -type f \
        -exec install -m644 -oroot -groot '{}' "$dst" ';')

# remove files from $dst which aren't in $src
(cd "$dst";
    find -maxdepth 1 -type f \
        '(' -exec test ! -e "$src/{}" ';' \
            -exec rm '{}' ';' \
        ')')