1.1 --- a/vcs-backup.sh Mon Apr 22 11:24:43 2019 +0200
1.2 +++ b/vcs-backup.sh Mon Apr 22 12:00:35 2019 +0200
1.3 @@ -34,7 +34,7 @@
1.4 # This is an asynchronous message-driven shell script that runs distributed across two machines and four user accounts. You have been warned :-)
1.5
1.6
1.7 -# Server-side configuration:
1.8 +# Server-side configuration: / loadServerConfigFile()
1.9 VCS_BACKUP_DATA_DIR="/mnt/data";
1.10 VCS_BACKUP_CURRENT_DIR="$VCS_BACKUP_DATA_DIR/current";
1.11 VCS_BACKUP_PUBLIC_DIR="$VCS_BACKUP_DATA_DIR/public";
1.12 @@ -46,6 +46,10 @@
1.13 VCS_BACKUP_USER="vcs-backup";
1.14 VCS_BACKUP_MANAGER="vcs-backup-manager";
1.15
1.16 +# Client-side configuration: / see loadClientConfigFile()
1.17 +VCS_BACKUP_SERVER="$VCS_BACKUP_MANAGER@localhost";
1.18 +VCS_BACKUP_SSH_COMMAND=(ssh "$VCS_BACKUP_SERVER");
1.19 +
1.20 # Installation – check and do it by hand:
1.21 # There should be already mounted Btrfs at $VCS_BACKUP_DATA_DIR
1.22 installInstructions() {
1.23 @@ -73,6 +77,8 @@
1.24 # Environment: all
1.25 # $1 = path to the config file
1.26 loadConfigFile() { if [ -f "$1" ]; then . "$1"; fi }
1.27 +loadClientConfigFile() { loadConfigFile ~/.config/vcs-backup/client.cfg; }
1.28 +loadServerConfigFile() { loadConfigFile "/etc/vcs-backup/server.cfg"; }
1.29
1.30 # Environment: server
1.31 # $1 = URL
1.32 @@ -98,7 +104,6 @@
1.33 # $4 = "clone" (optional), if present, will also clone the backup locally
1.34 vcs_backup_public_clientSubmitBackupRequest() {
1.35 if isValidTypeAndURL "$1" "$2"; then
1.36 - loadConfigFile ~/.config/vcs-backup/client.cfg
1.37 ${VCS_BACKUP_SSH_COMMAND[@]} vcs-backup.sh serverSubmitBackupRequest "$1" "$2" "$3" "$4"
1.38 if [[ "$4" == "clone" ]]; then
1.39 if [[ "$1" == "hg" ]]; then hg clone "ssh://${VCS_BACKUP_SERVER}/$VCS_BACKUP_CURRENT_DIR/$1/$(urlToRelativeDirectoryPath $2)";
1.40 @@ -115,7 +120,6 @@
1.41 # has same parameters as clientSubmitBackupRequest (see above)
1.42 vcs_backup_public_serverSubmitBackupRequest() {
1.43 if isValidTypeAndURL "$1" "$2"; then
1.44 - loadConfigFile "/etc/vcs-backup/server.cfg";
1.45 relativePath=$1/$(urlToRelativeDirectoryPath "$2");
1.46 absolutePath="$VCS_BACKUP_CONFIG_DIR/$relativePath";
1.47 # TODO: stop if directory already exists / only add public link?
1.48 @@ -200,7 +204,6 @@
1.49 # prints list of repositories in recfile format
1.50 # usage example: vcs-backup.sh clientListRepositories | relpipe-in-recfile | relpipe-out-tabular
1.51 vcs_backup_public_clientListRepositories() {
1.52 - loadConfigFile ~/.config/vcs-backup/client.cfg;
1.53 ${VCS_BACKUP_SSH_COMMAND[@]} vcs-backup.sh serverListRepositories;
1.54 }
1.55
1.56 @@ -323,6 +326,8 @@
1.57
1.58 # --- Single entry-point: --------------------------------------------------------------------------
1.59
1.60 +loadClientConfigFile;
1.61 +loadServerConfigFile;
1.62 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
1.63 PUBLIC_FUNCTION_PREFIX="vcs_backup_public_";
1.64 if type -t "$PUBLIC_FUNCTION_PREFIX$1" > /dev/null; then