forked from onlineconf/onlineconf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonlineconf-admin.spec
129 lines (107 loc) · 3.4 KB
/
onlineconf-admin.spec
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
# Conditionally enable/disable some things in epel7 and up
%if 0%{?rhel} >= 7
%bcond_without systemd
%else
%bcond_with systemd
%endif
%bcond_with green
%define debug_package %{nil}
%define __strip /bin/true
Name: onlineconf-admin
Version: %{__version}
Release: %{__release}%{?dist}
Summary: onlineconf-admin application server
License: BSD
Group: MAILRU
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: mr-rpm-macros
BuildRequires: golang
BuildRequires: golang-bin
BuildRequires: nodejs
%if %{with systemd}
BuildRequires: systemd-devel, systemd-units
Requires: mailru-systemd-units
%else
Requires: mailru-initd-functions >= 1.11
%endif
%description
onlineconf-admin application server. Built from revision %{__revision}.
%prep
%setup -q -c -n %{name}-%{version}
%setup -T -D -n %{name}-%{version}/onlineconf/admin
sed -i 's/\(<link href="[^"]*\.css\|<script src="[^"]*\.js\)"/\1?%{version}"/' static/index.html
%build
cd go
go build -mod=vendor -o %{name} ./
cd ../js
npm run build%{?with_green:-green}
%install
[ "%{buildroot}" != "/" ] && rm -fr %{buildroot}
%{__install} -pD -m0755 go/%{name} %{buildroot}/%{_localbindir}/%{name}
%{__mkdir} -p %{buildroot}/%{_initrddir} %{buildroot}/%{_localetcdir} %{buildroot}/%{_sysconfdir}/{cron.d,nginx} %{buildroot}/usr/local/www/onlineconf
%{__install} -m 644 etc/%{name}.yaml %{buildroot}/%{_localetcdir}/%{name}.yaml
%if %{with systemd}
%{__install} -pD -m 644 etc/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%else
%{__install} -pD -m 755 etc/%{name}.init %{buildroot}%{_initrddir}/%{name}
%endif
%{__cp} -r js/build/* $RPM_BUILD_ROOT/usr/local/www/onlineconf/
%{__cp} -r static $RPM_BUILD_ROOT/usr/local/www/onlineconf/classic
%if %{with green}
sed -i '4s/#FFFFFF/#D6F3D6/; 32s/background: white; //' $RPM_BUILD_ROOT/usr/local/www/onlineconf/classic/css/main.css
%endif
%{__cp} -f etc/nginx.conf $RPM_BUILD_ROOT/etc/nginx/onlineconf.conf
%if !%{with systemd}
echo "@daily root %{_initrddir}/%{name} remove-old-logs" > %{buildroot}/%{_sysconfdir}/cron.d/%{name}
%endif
%files
%defattr(-,root,root,-)
%{_localbindir}/%{name}
%if %{with systemd}
%config %{_unitdir}/%{name}.service
%else
%{_initrddir}/%{name}
%endif
%config(noreplace) %{_localetcdir}/%{name}.yaml
%config(noreplace) %{_sysconfdir}/nginx/*
/usr/local/www/onlineconf/*
%if !%{with systemd}
%{_sysconfdir}/cron.d/%{name}
%endif
%post
%if %{with systemd}
echo "Executing systemd post-install tasks"
%if 0%{?systemd_post:1}
%systemd_post %{name}.service
%else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
%else
echo "Executing System V post-install tasks"
/sbin/chkconfig --add %{name}
/sbin/chkconfig %{name} on
%endif
%preun
%if %{with systemd}
echo "Executing systemd pre-uninstall tasks"
%if 0%{?systemd_preun:1}
%systemd_preun %{name}.service
%else
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
/bin/systemctl stop %{name}.service > /dev/null 2>&1 || :
fi
%endif
%else
echo "Executing System V pre-uninstall tasks"
if [ $1 -eq 0 ] ; then
/sbin/service %{name} stop > /dev/null
/sbin/chkconfig --del %{name}
fi
%endif
%changelog
* Wed Jan 26 2022 Sergei Fedosov <[email protected]>
- Add C7 systemd unit
* Mon Mar 19 2012 Aleksey Mashanov <[email protected]>
- initial version