-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpistop.spec.in
193 lines (177 loc) · 6.16 KB
/
pistop.spec.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
%undefine _missing_build_ids_terminate_build
%global _unpackaged_files_terminate_build 1
%global debug_package %{nil}
%if %{defined _project}
# define if building on openSUSE build service
%global build_on_obs 1
%global reconfigure_mode 0
%else
%define _project local
%global build_on_obs 0
%global reconfigure_mode 0
%global _hardened_build 1
%endif
%global _prefix /usr
%global sysconfdir @sysconfdir@
%global logdir /var/log/svc
%global servicedir @servicedir@
Name: pistop
Version: @version@
Release: @release@%{?dist}
Summary: Start/Stop services on file server startup/shutdown
%if %build_on_obs == 1
License: GPL-2.0
%else
License: GPLv2
%endif
URL: https://github.com/mbhangui/%{name}
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
BuildRequires: gcc gcc-c++ make autoconf automake libtool
%if %build_on_obs == 1
%if 0%{?suse_version}
BuildRequires: -post-build-checks
#!BuildIgnore: post-build-checks
%endif
%endif
BuildRequires: libqmail-devel libqmail
Requires: user(qmaill)
Requires: group(nofiles)
Requires: daemontools ucspi-tcp coreutils util-linux rsync at
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
pistop is a package that provides two services fclient and fserver.
fclient is a svscan service that monitors the uptime of a server running
fserver service on port 5555. shutdown is detected by a socket close
fserver is a svscan service that provides a socket on port 5555 and offers
rudimentary commands.
%prep
%autosetup
%build
%configure --prefix=%{_prefix} --sysconfdir=/etc \
--libexecdir=%{_prefix}/libexec
%{__make} -s %{?_smp_mflags}
(
echo "---------------- INFORMATION ------------------------"
echo target %_target
echo target_alias %_target_alias
echo target_cpu %_target_cpu
echo target_os %_target_os
echo target_vendor %_target_vendor
echo Project %{_project}
echo Building %{name}-%{version}-%{release} Build %{_build} OS %{_os}
echo "------------------------------------------------------"
) > %{name}-rpm.info
%install
[ "%{buildroot}" != "/" ] && /bin/rm -fr %{buildroot}
%{__make} -s DESTDIR=%{buildroot} install-strip
%{__mkdir_p} %{buildroot}%{sysconfdir}
install -m 0644 %{name}-rpm.info %{buildroot}%{sysconfdir}/%{name}/%{name}-rpm.info
%files
%dir %attr(755,root,root) %{_prefix}/libexec/%{name}
%ghost %dir %attr(0755,qmaill,nofiles) %{logdir}
%ghost %attr(-,qmaill,nofiles) %{logdir}/*
%license COPYING
%attr(755,root,root) %{_prefix}/libexec/%{name}/pistopclient
%attr(755,root,root) %{_prefix}/libexec/%{name}/pistopserver
%attr(755,root,root) %{_prefix}/libexec/%{name}/pistopstart
%attr(755,root,root) %{_prefix}/libexec/%{name}/host_status
%attr(755,root,root) %{_prefix}/libexec/%{name}/backup
%attr(755,root,root) %{_prefix}/libexec/%{name}/create_service
%attr(644,root,root) %{sysconfdir}/%{name}/%{name}-release
%attr(644,root,root) %{sysconfdir}/%{name}/%{name}-rpm.info
%attr(644,root,root) %{_prefix}/share/man/man1/pistopserver.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/pistopclient.1.gz
%{_prefix}/share/doc/*
%docdir %{_prefix}/share/doc/%{name}
%pretrans
# stop fclient, fserver services before upgrade
if [ -d /run ] ; then
rundir=/run/svscan
elif [ -d /var/run ] ; then
rundir=/var/run/svscan
else
rundir=%{servicedir}
fi
for i in fclient fserver; do
if [ ! -d %{servicedir}/$i ] ; then
continue
fi
%{_prefix}/bin/svstat %{servicedir}/$i >/dev/null 2>&1
if [ $? -eq 0 ] ; then
%{__mkdir_p} ${rundir}/$i
%{_prefix}/bin/svc -d %{servicedir}/$i
touch ${rundir}/$i/.down
fi
done
%post
argv1=$1
if [ -z "$argv1" ] ; then
argv1=0
fi
# we are doing upgrade
if [ $argv1 -eq 2 ] ; then # upgrade
if [ -d /run ] ; then
rundir=/run/svscan
elif [ -d /var/run ] ; then
rundir=/var/run/svscan
else
rundir=%{servicedir}
fi
# refresh fclient, fserver services
for i in fclient fserver update; do
if [ ! -d %{servicedir}/$i ] ; then
continue
fi
# earlier installations did not have .options
if [ ! -f %{servicedir}/$i/variables/.options ] ; then
%{__mkdir_p} %{servicedir}/$i/variables
options=`grep "^#" %{servicedir}/$i/run | sed -n 2p | cut -c3-`
if [ -n "$options" ] ; then
echo $options > %{servicedir}/$i/variables/.options
fi
fi
user=`getent passwd 1000|cut -d: -f1`
grep "\--user" %{servicedir}/$i/variables/.options >/dev/null
if [ $? -ne 0 ] ; then
sed -i "s/--service_name=${i}/--service_name=${i} --user=${user}/" %{servicedir}/$i/variables/.options
fi
%{_prefix}/sbin/minisvc --servicedir=%{servicedir} --refreshsvc="%{servicedir}/$i" --silent
%{_prefix}/sbin/minisvc --servicedir=%{servicedir} --service-name=$i \
--export-variables=%{servicedir}/$i/variables/.variables --force --silent
%{_prefix}/bin/svok %{servicedir}/$i >/dev/null 2>&1
if [ $? -eq 0 -a -f ${rundir}/$i/.down ] ; then
%{__rm} -f ${rundir}/$i/.down
%{_prefix}/bin/svc -u %{servicedir}/$i
fi
done
exit 0
fi
for i in fclient fserver update; do
if [ ! -d %{servicedir}/$i ] ; then
continue
fi
%{_prefix}/sbin/minisvc --servicedir=%{servicedir} --service-name=$i \
--export-variables=%{servicedir}/$i/variables/.variables --force --silent
done
%preun
argv1=$1
if [ -z "$argv1" ] ; then
argv1=0
fi
# we are doing upgrade
if [ $argv1 -eq 1 ] ; then
exit 0
fi
if [ -d %{servicedir}/fclient ] ; then
service_name=fclient
elif [ -d %{servicedir}/fserver ] ; then
service_name=fserver
fi
echo "removing ${service_name} logs"
log_dir=%{logdir}/${service_name}
[ "$log_dir" != "/" ] && %{__rm} -fr $log_dir
echo "stopping and removing ${service_name} service"
/usr/libexec/pistop/create_service --servicedir=%{servicedir} --service_name=${service_name} --del-service
/usr/libexec/pistop/create_service --servicedir=%{servicedir} --service_name=update --del-service
/usr/libexec/pistop/create_service --servicedir=%{servicedir} --service_name=rsync --del-service
%changelog