docker-borgbackup-server/root/usr/local/bin/run.sh

45 lines
835 B
Bash
Raw Normal View History

2017-04-11 09:09:44 +00:00
#!/bin/bash
function updateIDs {
usermod -u $UID borg
groupmod -g $GID borg
usermod -g $GID borg
chown -R borg:borg /backup
}
function writeAuthKeys {
mkdir -p /home/borg/.ssh/
cd /home/borg/.ssh/
2017-04-25 21:13:26 +00:00
#Generate the authorized keys file
2017-04-25 17:06:13 +00:00
borgocli generate authorized_keys /backup/config/hosts.json > authorized_keys
2017-04-25 21:13:26 +00:00
#Create the folder structure
borgocli generate folders /backup/config/hosts.json
2017-04-11 09:09:44 +00:00
chown -R borg:borg .
chmod 700 .
chmod 700 ..
chmod 600 authorized_keys
}
2017-04-25 17:06:13 +00:00
function writeHostKeys {
#Write existing host keys to /etc/ssh
2017-04-25 18:41:28 +00:00
cd /backup/keys/
for f in ssh_host_*; do
2017-04-25 17:06:13 +00:00
cp -f $f /etc/ssh/
done
2017-04-25 21:13:26 +00:00
2017-04-25 17:06:13 +00:00
#Generate missing host keys
ssh-keygen -A
2017-04-25 21:13:26 +00:00
2017-04-25 17:06:13 +00:00
#Copy host keys to volume
2017-04-25 18:41:28 +00:00
cd /etc/ssh/
for f in ssh_host_*; do
2017-04-25 17:06:13 +00:00
cp -f $f /backup/keys/
done
}
2017-04-11 09:09:44 +00:00
updateIDs
writeAuthKeys
2017-04-25 17:06:13 +00:00
writeHostKeys
2017-05-19 14:14:17 +00:00
su-exec /bin/s6-svscan /etc/s6.d