Summary: Dummy package to fix systemd initscripts configs
Name: vzdummy-systemd-suse
Group: Applications/System
Vendor: Parallels
License: GPL
Version: 42.3
Release: 1
Autoreq: 0
BuildRoot: %_tmppath/%name-root
BuildArch: noarch

%description
Dummy package to fix systemd initscripts configs

%setup

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/systemd/system/default.target.wants
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/reboot.target.wants

cat >> $RPM_BUILD_ROOT/usr/lib/systemd/system/vzfifo.service << EOL
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=Tell that Container is started
ConditionPathExists=/proc/vz
ConditionPathExists=!/proc/bc
After=multi-user.target quotaon.service

[Service]
Type=forking
ExecStart=/bin/touch /.vzfifo
TimeoutSec=0
RemainAfterExit=no
SysVStartPriority=99
EOL

ln -s /usr/lib/systemd/system/vzfifo.service \
	$RPM_BUILD_ROOT/etc/systemd/system/default.target.wants/vzfifo.service

cat >> $RPM_BUILD_ROOT/usr/lib/systemd/system/vzreboot.service << EOL
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=Tell that Container is rebooted
ConditionPathExists=/proc/vz
ConditionPathExists=!/proc/bc
Before=reboot.service
DefaultDependencies=no

[Service]
Type=forking
ExecStart=/bin/touch /reboot
TimeoutSec=0
RemainAfterExit=no
EOL

ln -s /usr/lib/systemd/system/vzreboot.service \
	$RPM_BUILD_ROOT/usr/lib/systemd/system/reboot.target.wants/vzreboot.service

%triggerin -- systemd
SULOGIN="/usr/lib/systemd/system/console-shell.service"

if [ -f $SULOGIN ]; then
	grep "^ConditionPathExists=\!\/proc\/vz$" -q $SULOGIN && exit 0
	cp -af $SULOGIN $SULOGIN.pre_parallels
	cat $SULOGIN | sed "/^Before=/a \ConditionPathExists=\!\/proc\/vz" \
	> $SULOGIN.pre_parallels 2>/dev/null && mv -f $SULOGIN.pre_parallels $SULOGIN
fi

%files
%attr(0644, root, root) /usr/lib/systemd/system/vzfifo.service
%attr(0644, root, root) /usr/lib/systemd/system/vzreboot.service
/etc/systemd/system/default.target.wants/vzfifo.service
/usr/lib/systemd/system/reboot.target.wants/vzreboot.service

%changelog
* Sat Dec 21 2013 Konstantin Volckov <wolf@parallels.com> 13.2-1
- created
