File bitcoind-status.spec of Package bitcoind-status
#
# spec file for package bitcoind-status
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: bitcoind-status
Version: 20201228
Release: 0
Summary: Web application to display status and information from the bitcoin node daemon
License: Apache-2.0
Group: Productivity/Networking/Web/Servers
URL: https://github.com/craigwatson/%{name}
Source0: %{name}-%{version}.tar.xz
Source1: %{name}-rpmlintrc
BuildArch: noarch
BuildRequires: apache2
PreReq: permissions
Requires: apache2
%if 0%{?suse_version} && ( 0%{?suse_version} > 1500 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1500 && 0%{?sle_version} && 0%{?sle_version} >= 150500 ) )
Requires: apache2-mod_php8
%else
%if 0%{?suse_version} && 0%{?is_opensuse} && 0%{?suse_version} == 1500 && 0%{?sle_version} && 0%{?sle_version} <= 150400
Requires: apache2-mod_php7
%else
Requires: apache2-mod_php5
%endif
%endif
Requires: crontabs
Requires: curl
%define apache_serverroot /srv/www/htdocs
%define apache_user wwwrun
%define apache_group www
%description
This is a small PHP application designed to display status and information from the bitcoin node daemon.
%prep
%setup -q
%{__cp} php/config.sample.php php/config.php
%{__sed} -ri 's#(\s*\x27geo_cache_file\x27\s*\=>\s*\x27)([^\x27]+)(\x27,\s*)#\1%{_localstatedir}/lib/%{name}/bitcoind_geolocation.cache\3#g' php/config.php
%{__sed} -ri 's#(\s*\x27cache_file\x27\s*\=>\s*\x27)([^\x27]+)(\x27,\s*)#\1%{_localstatedir}/lib/%{name}/bitcoind_status.cache\3#g' php/config.php
%{__sed} -ri 's#(\s*\x27stats_file\x27\s*\=>\s*\x27)([^\x27]+)(\x27,\s*)#\1%{_localstatedir}/lib/%{name}/bitcoind_status.data\3#g' php/config.php
%{__sed} -ri 's#(\s*\x27peercount_file\x27\s*\=>\s*\x27)([^\x27]+)(\x27,\s*)#\1%{_localstatedir}/lib/%{name}/bitcoind_peer.data\3#g' php/config.php
%build
%install
%{__install} -d -m 0755 %{buildroot}%{apache_serverroot}/%{name}/php
%{__install} -m 0644 -p -t %{buildroot}%{apache_serverroot}/%{name} *.php
%{__cp} -a -t %{buildroot}%{apache_serverroot}/%{name} css html img js
%{__install} -m 0644 -p -t %{buildroot}%{apache_serverroot}/%{name}/php php/config.php php/easybitcoin.php php/functions.php
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/cron.d
echo -e "#\n# crontab for bitcoind-status\n#\n\n#*/15 * * * * %{apache_user} %{_bindir}/curl -Ssk http://localhost/%{name}/stats.php > /dev/null\n#*/15 * * * * %{apache_user} %{_bindir}/curl -Ssk http://localhost/%{name}/peercount.php > /dev/null" > %{buildroot}%{_sysconfdir}/cron.d/%{name}
%{__install} -d -m 0755 %{buildroot}%{_localstatedir}/lib/%{name}
%check
%verifyscript
%verify_permissions -e %{_sysconfdir}/cron.d
%post
%set_permissions %{_sysconfdir}/cron.d
%files
%defattr(640,root,%{apache_group},750)
%dir %{apache_serverroot}/%{name}
%dir %attr(750,%{apache_user},%{apache_group}) %{_localstatedir}/lib/%{name}
%{apache_serverroot}/%{name}/*.php
%{apache_serverroot}/%{name}/css
%{apache_serverroot}/%{name}/html
%{apache_serverroot}/%{name}/img
%{apache_serverroot}/%{name}/js
%dir %{apache_serverroot}/%{name}/php
%config(noreplace) %{apache_serverroot}/%{name}/php/config.php
%{apache_serverroot}/%{name}/php/easybitcoin.php
%{apache_serverroot}/%{name}/php/functions.php
%defattr(644,root,root,755)
%dir %{_sysconfdir}/cron.d
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%doc README.md
%license LICENSE
%changelog