Blame tests/p_rsync/10-rsync-test.sh

Christoph Galuschka dc5f9b
#!/bin/sh
Christoph Galuschka dc5f9b
# Author: Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka dc5f9b
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka dc5f9b
Christoph Galuschka 0973c7
t_Log "Running $0 - rsyncd can rsync from/to local machine."
Christoph Galuschka dc5f9b
Christoph Galuschka 0973c7
# create settings to run test
Christoph Galuschka dc5f9b
Athmane Madjoudj 9710ec
PATH2FILE='/var/tmp/rsync'
Athmane Madjoudj 9710ec
mkdir -p $PATH2FILE
Christoph Galuschka 0973c7
FILE='rsync-test'
Christoph Galuschka 0973c7
cat > $PATH2FILE/$FILE <
Christoph Galuschka dc5f9b
Testing rsync
Christoph Galuschka dc5f9b
EOF
Christoph Galuschka dc5f9b
260e24
# Creating rsyncd config file
Christoph Galuschka 0973c7
cat > /etc/rsyncd.conf <
Christoph Galuschka 0973c7
gid = root
Christoph Galuschka 0973c7
uid = root
Christoph Galuschka 0973c7
read only = true
Christoph Galuschka 0973c7
use chroot = true
Christoph Galuschka 0973c7
log file = /var/log/rsyncd.log
Christoph Galuschka 0973c7
pid file = /var/run/rsyncd.pid
Christoph Galuschka 0973c7
hosts allow = 127.0.0.1
Christoph Galuschka 0973c7
[centos-test]
Christoph Galuschka 0973c7
 path = $PATH2FILE
Christoph Galuschka 0973c7
 list = yes
Christoph Galuschka 0973c7
 exclude = *
Christoph Galuschka 0973c7
 include = $FILE
Christoph Galuschka 0973c7
EOF
Christoph Galuschka 0973c7
5c7a59
if [ "$centos_ver" = "7" ] || [ "$centos_ver" = "8" ]; then
260e24
 systemctl start rsyncd.service
260e24
else
260e24
 t_ServiceControl xinetd restart
260e24
fi
Athmane Madjoudj 9710ec
Athmane Madjoudj 9710ec
# Fix SELinux
Athmane Madjoudj 4bf70d
chcon -R -t public_content_t $PATH2FILE
Athmane Madjoudj 9710ec
Christoph Galuschka 0973c7
# Trying to rsync
Christoph Galuschka 0973c7
rsync --recursive --verbose --include=$FILE --exclude=* rsync://127.0.0.1/centos-test /var/log/
Christoph Galuschka 0973c7
Christoph Galuschka 0973c7
t_CheckExitStatus $?
Christoph Galuschka dc5f9b
260e24
#reverting changes
Christoph Galuschka 0973c7
/bin/rm $PATH2FILE/$FILE
Christoph Galuschka 0973c7
/bin/rm /var/log/$FILE
Christoph Galuschka 0973c7
260e24
if [ "$centos_ver" = "7" ] ; then
260e24
 systemctl start rsyncd.service
260e24
else
260e24
 /bin/rm /etc/rsyncd.conf
260e24
 t_ServiceControl xinetd restart
260e24
fi