File init-trigger-from-obs.sh of Package serviced
set -ex
make -C /opt/openqa-trigger-from-obs install_apparmor
sed -i "s,/opt/openqa-trigger-from-obs/script/rsync.sh {,/opt/openqa-trigger-from-obs/script/rsync.sh flags=(attach_disconnected) {," /etc/apparmor.d/opt.openqa-trigger-from-obs.script.rsync.sh
sed -i "/\/usr\/bin\/rsync mrix,/a \/var\/lib\/docker\/** r," /etc/apparmor.d/opt.openqa-trigger-from-obs.script.rsync.sh
echo " /var/lib/docker/** r," >> /etc/apparmor.d/local/opt.openqa-trigger-from-obs.script.rsync.sh
# setup ObsRsync plugin
printf '[obs_rsync]\nhome=/opt/openqa-trigger-from-obs' >> /etc/openqa/openqa.ini
gawk -i inplace '1;/plugins =/{print "plugins = ObsRsync"}' /etc/openqa/openqa.ini
# mock OBS backend host and rsync modules
echo "$dbuser:$dbuser" >> /etc/rsyncd.secrets
chmod 400 /etc/rsyncd.secrets
printf "\n[openqa]\npath = /mockOBS\nauth users = $dbuser\nsecrets file = /etc/rsyncd.secrets\nhosts allow = 127.0.0.1" >> /etc/rsyncd.conf
bash /opt/init.sh