2019-01-19 14:07:16 +01:00
|
|
|
# You can get the latest commit using this commands:
|
|
|
|
|
# git pull
|
|
|
|
|
# git log --oneline | head -n 1 | awk '{print $1}'
|
2019-01-19 16:53:16 +01:00
|
|
|
%define gitv 58fd8a6
|
|
|
|
|
%define webd %{_var}/www
|
|
|
|
|
%define gopath $(pwd)/go
|
|
|
|
|
%define domain echoip.daniel-steiner.org
|
|
|
|
|
%define protocol https
|
|
|
|
|
%define port 443
|
|
|
|
|
|
2019-01-19 14:07:16 +01:00
|
|
|
Name: echoip
|
|
|
|
|
Version: 1.0
|
2019-01-20 13:45:54 +01:00
|
|
|
Release: 3.%{gitv}%{?dist}
|
2019-01-19 14:07:16 +01:00
|
|
|
Summary: A simple service for looking up your IP address.
|
2019-01-19 16:53:16 +01:00
|
|
|
%define debug_package %{nil}
|
2019-01-19 14:07:16 +01:00
|
|
|
|
|
|
|
|
Group: Applications/System
|
|
|
|
|
License: BSD 3-Clause license
|
|
|
|
|
URL: https://github.com/mpolden/%{name}
|
|
|
|
|
Source0: %name-%{version}.%{gitv}.tgz
|
2019-01-19 16:53:16 +01:00
|
|
|
Source1: %name.service
|
2019-01-20 13:45:54 +01:00
|
|
|
Source2: %name-index.html
|
|
|
|
|
Source3: %name.cfg
|
2019-01-19 14:07:16 +01:00
|
|
|
|
|
|
|
|
BuildRequires: golang
|
|
|
|
|
BuildRequires: go-compilers-golang-compiler
|
|
|
|
|
BuildRequires: go-srpm-macros
|
|
|
|
|
Requires: httpd-filesystem
|
2019-01-19 16:53:16 +01:00
|
|
|
Requires: geoipupdate-cron
|
|
|
|
|
Requires: GeoIP
|
2019-01-19 14:07:16 +01:00
|
|
|
|
|
|
|
|
%description
|
2019-01-20 13:45:54 +01:00
|
|
|
A simple service for looking up your IP address. This is the code that powers https://echoip.daniel-steiner.org.
|
2019-01-19 14:07:16 +01:00
|
|
|
|
|
|
|
|
%prep
|
|
|
|
|
%setup -q -n %{name}-%{version}.%{gitv}
|
|
|
|
|
|
|
|
|
|
%build
|
|
|
|
|
# save system PATH environment:
|
|
|
|
|
SAVEPATH=$PATH
|
|
|
|
|
# prepare go environment:
|
2019-01-19 16:53:16 +01:00
|
|
|
export GOPATH=%{gopath}
|
|
|
|
|
#export GOPATH=$(go env GOPATH) # it's the same like above line!
|
|
|
|
|
export PATH=$PATH:%{gopath}/bin
|
2019-01-19 14:07:16 +01:00
|
|
|
# build go project:
|
|
|
|
|
go get ./...
|
|
|
|
|
# bash -c "diff --line-format='%L' <(echo -n) <(gofmt -d -s .)"
|
|
|
|
|
# test fails with exit code 1!
|
|
|
|
|
# go test ./...
|
|
|
|
|
go install ./...
|
|
|
|
|
# restore system PATH environment:
|
|
|
|
|
export PATH=$SAVEPATH
|
|
|
|
|
|
|
|
|
|
%install
|
2019-01-19 16:53:16 +01:00
|
|
|
# modifying index.html file for required settings:
|
2019-01-20 11:32:10 +01:00
|
|
|
sed -i -e 's|.. .Host ..|%{protocol}://%{domain}|g' index.html
|
2019-01-19 16:53:16 +01:00
|
|
|
sed -i -e 's/8080/%{port}/g' index.html
|
|
|
|
|
install -d -m 0770 %{buildroot}%{_rundir}/%{name}
|
|
|
|
|
install -D -m 0775 %{gopath}/bin/echoip %{buildroot}%{_bindir}/%{name}
|
2019-01-20 11:32:10 +01:00
|
|
|
install -D -m 0644 index.html %{buildroot}%{webd}/%{name}/orig-index.html
|
|
|
|
|
install -D -m 0644 %{SOURCE2} %{buildroot}%{webd}/%{name}/index.html
|
|
|
|
|
sed -i -e 's|.. .Host ..|%{protocol}://%{domain}|g' %{buildroot}%{webd}/%{name}/index.html
|
|
|
|
|
sed -i -e 's/8080/%{port}/g' %{buildroot}%{webd}/%{name}/index.html
|
2019-01-19 16:53:16 +01:00
|
|
|
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
|
2019-01-20 13:45:54 +01:00
|
|
|
install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
|
2019-01-19 14:07:16 +01:00
|
|
|
|
2019-01-19 16:53:16 +01:00
|
|
|
%clean
|
|
|
|
|
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
|
|
|
|
|
[ "%{_builddir}" != "/" ] && [ -d "%{_builddir}" ] && rm -rf %{_builddir}/*
|
|
|
|
|
|
|
|
|
|
%pre
|
|
|
|
|
getent group %{name} > /dev/null || groupadd -r %{name}
|
|
|
|
|
getent passwd %{name} > /dev/null || \
|
|
|
|
|
useradd -m -g %{name} -s /bin/bash \
|
|
|
|
|
-c "Echo IP account" %{name}
|
|
|
|
|
|
|
|
|
|
%post
|
|
|
|
|
%if 0%{?using_systemd}
|
|
|
|
|
%if 0%{?systemd_macro_scriptlet}
|
|
|
|
|
if [ $1 -eq 1 ]; then
|
|
|
|
|
%systemd_post %{name}.service
|
|
|
|
|
firewall-cmd --permanent --add-port=8080/tcp
|
|
|
|
|
fi
|
|
|
|
|
%firewalld_reload
|
|
|
|
|
%endif
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
|
|
%preun
|
|
|
|
|
%if 0%{?using_systemd}
|
|
|
|
|
if [ $1 -eq 0 ]; then
|
|
|
|
|
systectl stop %{name}.service
|
|
|
|
|
fi
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
|
|
%postun
|
|
|
|
|
%if 0%{?using_systemd}
|
|
|
|
|
%if 0%{?systemd_macro_scriptlet}
|
|
|
|
|
if [ $1 -eq 1 ]; then
|
|
|
|
|
%systemd_postun_with_restart %{name}.service
|
|
|
|
|
firewall-cmd --permanent --delete-port=8080/tcp
|
|
|
|
|
%firewalld_reload
|
|
|
|
|
fi
|
|
|
|
|
%endif
|
|
|
|
|
%endif
|
2019-01-19 14:07:16 +01:00
|
|
|
|
|
|
|
|
%files
|
|
|
|
|
%defattr(-,root,root,-)
|
|
|
|
|
%doc README.md
|
|
|
|
|
%license LICENSE
|
2019-01-19 16:53:16 +01:00
|
|
|
%{_bindir}/%{name}
|
2019-01-20 13:45:54 +01:00
|
|
|
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
|
2019-01-19 16:53:16 +01:00
|
|
|
%dir %attr(-,%{name},%{name}) %{webd}/%{name}
|
|
|
|
|
%attr(-,%{name},%{name}) %{webd}/%{name}/index.html
|
2019-01-20 11:32:10 +01:00
|
|
|
%attr(-,%{name},%{name}) %{webd}/%{name}/orig-index.html
|
2019-01-19 16:53:16 +01:00
|
|
|
%{_unitdir}/%{name}.service
|
|
|
|
|
%dir %attr(-,%{name},%{name}) %{_rundir}/%{name}
|
2019-01-19 14:07:16 +01:00
|
|
|
|
|
|
|
|
%changelog
|
2019-01-20 13:45:54 +01:00
|
|
|
* Sun Jan 20 2019 Daniel Steiner <daniel.steiner@greenmail.ch>
|
|
|
|
|
- All options are now in sysconfig file.
|
|
|
|
|
|
|
|
|
|
* Sun Jan 20 2019 Daniel Steiner <daniel.steiner@greenmail.ch>
|
|
|
|
|
- More flexible systemd config added.
|
|
|
|
|
|
2019-01-19 14:07:16 +01:00
|
|
|
* Sat Jan 19 2019 Daniel Steiner <daniel.steiner@greenmail.ch>
|
|
|
|
|
- First build for Fedora 29 using git master commit 58fd8a6.
|
2019-01-20 13:45:54 +01:00
|
|
|
|