Package is now woring fine, including systemd service configration
This commit is contained in:
@@ -3,27 +3,35 @@
|
|||||||
# git log --oneline | head -n 1 | awk '{print $1}'
|
# git log --oneline | head -n 1 | awk '{print $1}'
|
||||||
%define gitv 58fd8a6
|
%define gitv 58fd8a6
|
||||||
%define webd %{_var}/www
|
%define webd %{_var}/www
|
||||||
|
%define gopath $(pwd)/go
|
||||||
|
%define domain echoip.daniel-steiner.org
|
||||||
|
%define protocol https
|
||||||
|
%define port 443
|
||||||
|
|
||||||
Name: echoip
|
Name: echoip
|
||||||
Version: 1.0
|
Version: 1.0
|
||||||
Release: 1.%{gitv}%{?dist}
|
Release: 1.%{gitv}%{?dist}
|
||||||
Summary: A simple service for looking up your IP address.
|
Summary: A simple service for looking up your IP address.
|
||||||
|
%define debug_package %{nil}
|
||||||
|
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
License: BSD 3-Clause license
|
License: BSD 3-Clause license
|
||||||
URL: https://github.com/mpolden/%{name}
|
URL: https://github.com/mpolden/%{name}
|
||||||
Source0: %name-%{version}.%{gitv}.tgz
|
Source0: %name-%{version}.%{gitv}.tgz
|
||||||
|
Source1: %name.service
|
||||||
|
|
||||||
BuildRequires: golang
|
BuildRequires: golang
|
||||||
BuildRequires: go-compilers-golang-compiler
|
BuildRequires: go-compilers-golang-compiler
|
||||||
BuildRequires: go-srpm-macros
|
BuildRequires: go-srpm-macros
|
||||||
Requires: httpd >=2.4.0
|
BuildRequires: httpd-filesystem
|
||||||
|
Requires: httpd >= 2.4.0
|
||||||
Requires: httpd-filesystem
|
Requires: httpd-filesystem
|
||||||
|
Requires: geoipupdate-cron
|
||||||
|
Requires: GeoIP
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A simple service for looking up your IP address. This is the code that powers https://ifconfig.co.
|
A simple service for looking up your IP address. This is the code that powers https://ifconfig.co.
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}.%{gitv}
|
%setup -q -n %{name}-%{version}.%{gitv}
|
||||||
|
|
||||||
@@ -31,9 +39,9 @@ A simple service for looking up your IP address. This is the code that powers ht
|
|||||||
# save system PATH environment:
|
# save system PATH environment:
|
||||||
SAVEPATH=$PATH
|
SAVEPATH=$PATH
|
||||||
# prepare go environment:
|
# prepare go environment:
|
||||||
export GOPATH=$(pwd)/go
|
export GOPATH=%{gopath}
|
||||||
export GOPATH=$(go env GOPATH)
|
#export GOPATH=$(go env GOPATH) # it's the same like above line!
|
||||||
export PATH=$PATH:$(go env GOPATH)/bin
|
export PATH=$PATH:%{gopath}/bin
|
||||||
# build go project:
|
# build go project:
|
||||||
go get ./...
|
go get ./...
|
||||||
# bash -c "diff --line-format='%L' <(echo -n) <(gofmt -d -s .)"
|
# bash -c "diff --line-format='%L' <(echo -n) <(gofmt -d -s .)"
|
||||||
@@ -44,17 +52,64 @@ go install ./...
|
|||||||
export PATH=$SAVEPATH
|
export PATH=$SAVEPATH
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%__install -d go/bin/echoip %{buildroot}%{_bindir}%{name}
|
# modifying index.html file for required settings:
|
||||||
%__install -d /go/src/github.com/mpolden/echoip/index.html %{buildroot}%{_webd}%{name}/index.html
|
sed -i -e 's/.. .Host ../%{domain}/g' index.html
|
||||||
|
sed -i -e 's/http /%{protocol} /g' index.html
|
||||||
|
sed -i -e 's/8080/%{port}/g' index.html
|
||||||
|
sed -i -e 's/height="350"/height="600"/g' index.html
|
||||||
|
install -d -m 0770 %{buildroot}%{_rundir}/%{name}
|
||||||
|
install -D -m 0775 %{gopath}/bin/echoip %{buildroot}%{_bindir}/%{name}
|
||||||
|
install -D -m 0644 index.html %{buildroot}%{webd}/%{name}/index.html
|
||||||
|
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
|
||||||
|
|
||||||
|
%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
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
%doc README.md
|
%doc README.md
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%{_bindir}%{name}
|
%{_bindir}/%{name}
|
||||||
%{_webd}%{name}/index.html
|
%dir %attr(-,%{name},%{name}) %{webd}/%{name}
|
||||||
|
%attr(-,%{name},%{name}) %{webd}/%{name}/index.html
|
||||||
|
%{_unitdir}/%{name}.service
|
||||||
|
%dir %attr(-,%{name},%{name}) %{_rundir}/%{name}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Sat Jan 19 2019 Daniel Steiner <daniel.steiner@greenmail.ch>
|
* Sat Jan 19 2019 Daniel Steiner <daniel.steiner@greenmail.ch>
|
||||||
|
|||||||
Reference in New Issue
Block a user