summaryrefslogtreecommitdiff
path: root/uhub/uhub.spec
blob: 12f41ba2f7df3da46d1a5781af88aab4f4e4a0ae (plain)
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
%define uhub_user       uhub
%define uhub_group      %{uhub_user}
%define uhub_confdir    %{_sysconfdir}/uhub
%define uhub_pluginsdir %{_libdir}/uhub
%define uhub_homedir    %{_localstatedir}/lib/uhub
%define uhub_logdir     %{_localstatedir}/log/uhub
%define sslcert		%{_sysconfdir}/pki/tls/certs/uhub.crt
%define sslkey		%{_sysconfdir}/pki/tls/private/uhub.key

Name:             uhub
Version:          0.5.0
Release:          1%{?dist}
Summary:          Advanced Direct Connect hub daemon
Group:            System Environment/Daemons
License:	  GPLv3
URL:              https://www.uhub.org
Packager:         Christoph J. Thompson <cjsthompson@gmail.com>
BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}
BuildRequires:    cmake,openssl-devel,systemd-devel,sqlite-devel
Requires(pre):    shadow-utils
Requires(post):   systemd,openssl
Requires(preun):  systemd
Requires(postun): systemd
Source0:          http://www.extatic.org/downloads/uhub/%{name}-%{version}-src.tar.bz2
Patch0:           0001-Install-man-pages.patch
Patch1:           0002-Add-a-default-MOTD-file-which-was-missing.patch
Patch2:           0003-Most-unices-including-most-Linux-distro-have-logrota.patch
Patch3:           0004-Conditionally-install-systemd-support-files.patch
Patch4:           0005-Also-install-users.conf.patch

%description
uhub is a high performance peer-to-peer hub for the ADC network.
Its low memory footprint allows it to handle several thousand users on
high-end servers, or a small private hub on embedded hardware.

Key features:
- High performance and low memory usage
- IPv4 and IPv6 support
- Experimental SSL support (optional)
- Advanced access control support
- Easy configuration
- plugin support
 - mod_welcome  - MOTD\RULES messages
 - mod_auth_sipmle - auth with sqlite DB
 - mod_logging - log hub activity

%prep
%autosetup -p1

%build
%{__cmake} \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
        -DINSTALL_LIB_DIR=%{_libdir} \
        -DSYSTEMD_SUPPORT=yes \
	-DSSL_SUPPORT=yes \
	-DUSE_OPENSSL=yes
%{__make} %{?_smp_mflags}

%install
%{__rm} -rf %{buildroot}
%{__make} install DESTDIR="%{buildroot}"
%{__install} -d -p -m 0755 %{buildroot}%{uhub_logdir}
%{__install} -d -p -m 0755 %{buildroot}%{uhub_homedir}
sed -i 's|/var/log/uhub.log|/var/log/uhub/uhub.log|g' %{buildroot}%{uhubconfdir}/plugins.conf
cat >> %{buildroot}%{_tmpfilesdir}/%{name}.conf <<EOF
d /var/lib/uhub 0750 uhub uhub
d /var/log/uhub 0750 uhub uhub
EOF

%clean
%{__rm} -rf %{buildroot}

%pre
%{_sbindir}/groupadd -r %{uhub_group} 2>/dev/null || :
%{_sbindir}/useradd -r -g %{uhub_group} -c "Uhub user" -s /bin/nologin -d %{uhub_homedir} %{uhub_user} 2>/dev/null || :

%post
%tmpfiles_create %{name}.conf
%systemd_post %{name}.service

if [ ! -f /etc/uhub/users.db ]; then
  %{_bindir}/uhub-passwd /etc/uhub/users.db create 2> /dev/null
fi

umask 077

if [ -f %{sslkey} -o -f %{sslcert} ]; then
  exit 0
fi

%{_bindir}/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > %{sslkey} 2> /dev/null

FQDN=`hostname`

if [ "x${FQDN}" = "x" ]; then
  FQDN=localhost.localdomain
fi

cat << EOF | %{_bindir}/openssl req -new -key %{sslkey} \
 -x509 -days 365 -set_serial $RANDOM -extensions v3_req \
 -out %{sslcert} 2>/dev/null
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
${FQDN}
root@${FQDN}
EOF

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service

%files
%defattr(-,root,root,0755)
%doc AUTHORS ChangeLog README
%{_bindir}/uhub
%{_bindir}/uhub-passwd
%{_mandir}/man1/*.1*
%{_unitdir}/%{name}.service
%{_tmpfilesdir}/%{name}.conf
%config(noreplace) %{uhub_confdir}/%{name}.conf
%config(noreplace) %{uhub_confdir}/plugins.conf
%config(noreplace) %{uhub_confdir}/users.conf
%config(noreplace) %{uhub_confdir}/rules.txt
%config(noreplace) %{uhub_confdir}/motd.txt
%config(noreplace) %{_sysconfdir}/logrotate.d/uhub
%dir %{uhub_confdir}
%dir %{uhub_pluginsdir}
%dir %{uhub_logdir}
%dir %{uhub_homedir}
%{uhub_pluginsdir}/mod_auth_simple.so
%{uhub_pluginsdir}/mod_auth_sqlite.so
%{uhub_pluginsdir}/mod_chat_history.so
%{uhub_pluginsdir}/mod_chat_history_sqlite.so
%{uhub_pluginsdir}/mod_chat_only.so
%{uhub_pluginsdir}/mod_example.so
%{uhub_pluginsdir}/mod_logging.so
%{uhub_pluginsdir}/mod_no_guest_downloads.so
%{uhub_pluginsdir}/mod_topic.so
%{uhub_pluginsdir}/mod_welcome.so

%changelog
* Sat Dec 13 2014 Christoph J. Thompson <cjsthompson-at-gmail.com> 0.5.0-1
- Initial spec.