fix clone socket path and user v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 19 Apr 2019 23:25:19 +0200
branchv_0
changeset 55e5d4c937739
parent 4 1539711d8657
child 6 308978165cc3
fix clone socket path and user
systemd/vcs-backup-clone.service
vcs-backup.sh
     1.1 --- a/systemd/vcs-backup-clone.service	Fri Apr 19 18:56:46 2019 +0200
     1.2 +++ b/systemd/vcs-backup-clone.service	Fri Apr 19 23:25:19 2019 +0200
     1.3 @@ -3,6 +3,7 @@
     1.4  After = network.target
     1.5  
     1.6  [Service]
     1.7 +User=vcs-backup
     1.8  ExecStart = /usr/local/bin/vcs-backup.sh serverStartCloneService
     1.9  
    1.10  [Install]
     2.1 --- a/vcs-backup.sh	Fri Apr 19 18:56:46 2019 +0200
     2.2 +++ b/vcs-backup.sh	Fri Apr 19 23:25:19 2019 +0200
     2.3 @@ -24,7 +24,7 @@
     2.4  VCS_BACKUP_CONFIG_DIR="$VCS_BACKUP_DATA_DIR/config";
     2.5  VCS_BACKUP_SNAPSHOT_DIR="$VCS_BACKUP_DATA_DIR/snapshot";
     2.6  VCS_BACKUP_SUBVOLUME_SOCKET="/run/vcs-backup-subvolume";
     2.7 -VCS_BACKUP_CLONE_SOCKET="/run/vcs-backup-clone";
     2.8 +VCS_BACKUP_CLONE_SOCKET="/run/vcs-backup-clone/socket";
     2.9  VCS_BACKUP_CLONE_CALLBACK_SOCKET="clone-callback";
    2.10  VCS_BACKUP_USER="vcs-backup";
    2.11  VCS_BACKUP_MANAGER="vcs-backup-manager";
    2.12 @@ -39,7 +39,9 @@
    2.13  mkdir "$VCS_BACKUP_CURRENT_DIR";
    2.14  mkdir "$VCS_BACKUP_CONFIG_DIR";
    2.15  mkdir "$VCS_BACKUP_SNAPSHOT_DIR";
    2.16 +mkdir "$(dirname VCS_BACKUP_CLONE_SOCKET)"
    2.17  
    2.18 +chown "${VCS_BACKUP_USER}:${VCS_BACKUP_USER}" "$(dirname VCS_BACKUP_CLONE_SOCKET)"
    2.19  chown "${VCS_BACKUP_USER}:${VCS_BACKUP_USER}" "$VCS_BACKUP_CURRENT_DIR"
    2.20  chown "${VCS_BACKUP_MANAGER}:${VCS_BACKUP_MANAGER}" "$VCS_BACKUP_CONFIG_DIR"
    2.21  }
    2.22 @@ -54,7 +56,7 @@
    2.23  
    2.24  # Environment: all
    2.25  # $1 = path to the config file
    2.26 -loadConfigFile() { if [ -f "$1" ]; then . "$1"; else echo "Missing config file: $1" >&2; exit 1; fi }
    2.27 +loadConfigFile() { if [ -f "$1" ]; then . "$1"; fi }
    2.28  
    2.29  # Environment: server
    2.30  # $1 = URL
    2.31 @@ -83,6 +85,7 @@
    2.32  }
    2.33  
    2.34  # Environment: server
    2.35 +# User: $VCS_BACKUP_MANAGER
    2.36  # has same parameters as clientSubmitBackupRequest (see above)
    2.37  vcs_backup_public_serverSubmitBackupRequest() {
    2.38  	if isValidTypeAndURL "$1" "$2"; then
    2.39 @@ -113,6 +116,7 @@
    2.40  }
    2.41  
    2.42  # Environment: server
    2.43 +# User: root
    2.44  # Should be started as a systemd/init service.
    2.45  # - reads messages from from the subvolume socket – message contains the relative directory path
    2.46  # - creates a subvolume for given repository + necesary parent directories
    2.47 @@ -128,6 +132,7 @@
    2.48  }
    2.49  
    2.50  # Environment: server
    2.51 +# User: $VCS_BACKUP_USER
    2.52  # should be started as a systemd/init service
    2.53  vcs_backup_public_serverStartCloneService() {
    2.54  	socat -u "unix-recv:${VCS_BACKUP_CLONE_SOCKET},mode=700" - | while read d; do