#!/bin/sh ## # Wilfredo Sanchez # # Set up a backup server. ## . "$(dirname "$0")/common.sh"; ## # Do The Right Thing ## # # Required directories # for directory in \ "${backup_root}" \ "${backup_home}" \ ; do if [ ! -d "${directory}" ]; then echo "Creating directory: ${directory}"; install -d -m 755 "${directory}"; fi; done; # # Ensure SSH skeleton config is OK # for directory in \ "${backup_home}" \ "${ssh_config_dir}" \ ; do sudo install -d -o root -m 755 "${directory}"; done; if [ ! -f "${authorized_keys_file}" ]; then sudo install -m 644 /dev/null "${authorized_keys_file}"; else chown root "${authorized_keys_file}"; chmod 644 "${authorized_keys_file}"; fi; # # Verify that backup user's home directory is where we expect it to be. # if ! backup_home="$(eval "cd ~"${backup_user}" 2>/dev/null && pwd -P")" || [ "${wd}/home" != "${backup_home}" ]; then error "This backup system requires a \"${backup_user}\" user with a home directory at \"${wd}/home\"."; if [ -n "${backup_home:-}" ]; then error "Incorrect home directory: ${backup_home}"; else error "No \"${backup_user}\" user found."; fi; exit 1; fi; # # Verify that any configured clients are set up correctly. # for client in $(list_clients); do # SSH keys if [ ! -f "$(ssh_client_private_key_file "${client}")" ]; then error "WARNING: Missing SSH private key file for client: ${client}"; fi; if [ ! -f "$(ssh_client_public_key_file "${client}")" ]; then error "WARNING: Missing SSH public key file for client: ${client}"; fi; if [ ! -d "$(client_backup_root "${client}")" ]; then error "WARNING: Missing backup root for client: ${client}"; fi; done;