This repository has been archived by the owner on Mar 2, 2019. It is now read-only.
/
tollgate.spec
185 lines (141 loc) · 6.81 KB
/
tollgate.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
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
#%global eggpath $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/site-packages/
Name: tollgate
Version: 3.0.0
Release: 1%{?dist}
Summary: Django based captive internet portal
BuildArch: noarch
Group: System Environment/Daemons
License: AGPL3
URL: https://github.com/micolous/tollgate
#This doesn't play nice ...... need to distrib the zip inside the SRPM
Source: %{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: httpd, python-setuptools, python-setuptools-devel
Requires: python, Django, httpd, kmod-xtables-addons, python-daemon, dbus-python, python-IPy, python-lxml, python-progressbar, python-simplejson, Django-south, nmap, mod_wsgi, python-pip, tollgate-selinux, configparser_plus, pygobject2, pytz, mod_ssl, djangorestframework
%package selinux
BuildArch: noarch
BuildRequires: selinux-policy
Requires: selinux-policy, policycoreutils
Summary: SELinux policies for tollgate captive internet portal
%package repo
BuildArch: noarch
#Requires:
Summary: Tollgate repository information.
%description
This is a captive portal system for Linux, designed for operating LAN parties. A lot of the concepts in the software are specific to how a LAN party operates, however you could use it for a sharehouse if you wanted, or something else.
%description selinux
SELinux policies for the Tollgate captive internet portal.
%description repo
Tollgate repository information and verification keys.
%prep
#Alternately, it will be micolous-tollgate-*.zip
%setup -q -n %{name}
%build
#python setup.py build
cd ./platform/fedora/selinux/
make -f /usr/share/selinux/devel/Makefile
%install
#PREP the build root.
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/tollgate/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pki/rpm-gpg/
mkdir -p $RPM_BUILD_ROOT%{_prefix}/share/doc/
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system/
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/wfc
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/wpad
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/static
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/source
#mkdir -p $RPM_BUILD_ROOT/usr/lib/python2.7/site-packages/
#mkdir -p %{eggpath}
#Main package
%{__python} setup.py install --root $RPM_BUILD_ROOT
cp -r ./docs $RPM_BUILD_ROOT%{_prefix}/share/doc/tollgate
#cp ./docs/example/dbus/system.d/tollgate.conf $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d/
cp ./docs/example/fedora/dbus/tollgate.conf $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d/
cp ./docs/example/tollgate/backend.ini $RPM_BUILD_ROOT%{_sysconfdir}/tollgate/
cp ./docs/example/fedora/httpd/tollgate.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/
cp ./www/wfc/index.html $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/wfc/
cp ./www/wpad/wpad.dat $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/wpad/
cp ./www/wpad/wpad.da $RPM_BUILD_ROOT%{_localstatedir}/www/tollgate/wpad/
cp ./platform/fedora/systemd/tollgate-backend.service $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system/
cp ./platform/fedora/systemd/tollgate-captivity.service $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system/
cp ./platform/fedora/sysconfig/tollgate $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/
mv $RPM_BUILD_ROOT%{_bindir}/tollgate_backend $RPM_BUILD_ROOT%{_sbindir}/
mv $RPM_BUILD_ROOT%{_bindir}/tollgate_captivity $RPM_BUILD_ROOT%{_sbindir}/
#SELinux
mkdir -p $RPM_BUILD_ROOT%{_prefix}/share/selinux/targeted/
cp ./platform/fedora/selinux/tollgate.pp $RPM_BUILD_ROOT%{_prefix}/share/selinux/targeted/
#Repo
cp ./platform/fedora/rpm/tollgate.repo $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d/
cp ./platform/fedora/rpm/RPM-GPG-KEY-tollgate-repository $RPM_BUILD_ROOT%{_sysconfdir}/pki/rpm-gpg/
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
#%doc
#%attr(0644,root,root) %{_sysconfdir}/dbus-1/system.d/tollgate.conf
#%attr(0644,root,root) %{_sysconfdir}/sysconfig/tollgate
#%attr(0644,root,root) %{_sysconfdir}/tollgate/
#%attr(0644,root,root) %{_sysconfdir}/httpd/conf.d/tollgate.conf
%config %{_sysconfdir}/dbus-1/system.d/tollgate.conf
%config(noreplace) %{_sysconfdir}/sysconfig/tollgate
%config(noreplace) %{_sysconfdir}/tollgate/*
%config(noreplace) %{_sysconfdir}/httpd/conf.d/tollgate.conf
%attr(0644,root,root) %{_localstatedir}/www/tollgate/wpad/wpad.dat
%attr(0755,root,root) %{_localstatedir}/www/tollgate/wpad/wpad.da
%attr(0644,root,root) %{_localstatedir}/www/tollgate/wfc/index.html
%attr(0644,root,root) %{_prefix}/share/doc/tollgate
%docdir %{_prefix}/share/doc/tollgate
%{python_sitelib}/*
%attr(0644,root,root) %{_prefix}/lib/systemd/system/tollgate-backend.service
%attr(0644,root,root) %{_prefix}/lib/systemd/system/tollgate-captivity.service
%attr(0755,root,root) %{_sbindir}/tollgate_backend
%attr(0755,root,root) %{_sbindir}/tollgate_captivity
%files selinux
%attr(0644,root,root) %{_prefix}/share/selinux/targeted/tollgate.pp
%files repo
%config %{_sysconfdir}/yum.repos.d/tollgate.repo
%config %{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-tollgate-repository
%post
systemctl --system daemon-reload
systemctl reload dbus.service
#We need to create the django project for the site to use.
if [ ! -d /var/www/tollgate/tollgate_site ]; then
cd /var/www/tollgate
django-admin startproject tollgate_site
cd tollgate_site
mv settings.py settings.orig.py
sed -e "s/^DEBUG \= True/from os.path import *\nPROJECT_PATH = realpath(dirname(__file__))\n\nDEBUG \= False/" -e "s/^STATIC_ROOT \= '.*'/STATIC_ROOT \= '\/var\/www\/tollgate\/static\/'/" -e "s/# 'django\.contrib\.admin',/'django.contrib.admin',/" -e "s/# 'django\.contrib\.admindocs',/# 'django.contrib.admindocs',\n\t'django.contrib.humanize',\n\t'south',\n\t'tollgate.api',\n\t'tollgate.frontend',\n\t'tollgate.scripts',/" settings.orig.py > settings.py
cat >> settings.py << EOF
AUTH_PROFILE_MODULE = 'frontend.userprofile'
LAN_SUBNET='10.4.0.0/24'
LAN_IFACE='laniface'
#In MB
DEFAULT_QUOTA_AMOUNT=150
RESET_EXCUSE_REQUIRED=True
RESET_PURCHASE=False
ONLY_CONSOLE=False
RESTRICTED_CALLS_KEY=''
LOGIN_URL='/login/'
LOGOUT_URL='/logout/'
EOF
sed -e "s/^os.environ\['DJANGO_SETTINGS_MODULE'\].*/os.environ['DJANGO_SETTINGS_MODULE'] = 'tollgate_site.settings'/" /usr/lib/python2.7/site-packages/tollgate/tollgate.wsgi > tollgate.wsgi
chmod +x tollgate.wsgi
mv urls.py urls.orig.py
sed -e "s/# url(r'\^admin\/', include(admin.site.urls)),/# url(r'^admin\/', include(admin.site.urls)),\n\t(r'^', include('tollgate.urls')),/" urls.orig.py > urls.py
fi
%post selinux
semodule -i %{_prefix}/share/selinux/targeted/tollgate.pp
%preun
rm -rf /var/www/tollgate/tollgate_site
%postun
systemctl --system daemon-reload
systemctl reload dbus.service
%postun selinux
semodule -r tollgate
%changelog