This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
doraemon.spec
182 lines (156 loc) · 5.68 KB
/
doraemon.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
Summary: Helps client to join domain and maintain itself
Name: doraemon
Version: 2.0.4
Release: 1.ns6
URL: https://github.com/bglug-it/doraemon/
License: GPLv2+
Packager: Paolo Asperti <[email protected]>
Group: System Environment/Daemons
BuildRoot: %{_tmppath}/%{name}-root
BuildRequires: nethserver-devtools > 1.0.1
BuildRequires: hunspell-en
Requires: httpd, php, sudo, php-xml, php-mcrypt
Requires: nethserver-base, nethserver-php
Requires: net-tools
Requires: upstart
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
%description
Helps client on a domain network to get information for its maintenance.
%prep
%setup
%build
%{makedocs}
perl createlinks.pl
%install
rm -Rf $RPM_BUILD_ROOT
(cd root ; find . -depth -print | cpio -dump %{buildroot})
rm -f %{name}-%{version}-%{release}-filelist
%{genfilelist} %{buildroot} > %{name}-%{version}-%{release}-filelist
mkdir -p %{buildroot}%{_localstatedir}/log/doraemon
mkdir -p %{buildroot}%{_localstatedir}/cache/doraemon
%pre
#if [ "$1" = 1 ]; then
# #installation
#fi
if [ "$1" = 2 ]; then
#upgrade
/sbin/service %{name} stop >/dev/null 2>&1 || :
/sbin/stop %{name} >/dev/null 2>&1 || :
DATABASE=/var/lib/doraemon/doraemon.db
INI=/etc/doraemon.ini
if [ -f $INI ]; then
DATABASE=$(awk -F "=" '/Database/ {print $2}' $INI)
PORT=$(awk -F "=" '/Port/ {print $2}' $INI)
BASE=$(awk -F "=" '/Base/ {print $2}' $INI)
ROLE=$(awk -F "=" '/Role/ {print $2}' $INI)
DIGITS=$(awk -F "=" '/Digits/ {print $2}' $INI)
DOMAIN=$(awk -F "=" '/Domain/ {print $2}' $INI)
MGMTKEY=$(awk -F "=" '/MgmtKey/ {print $2}' $INI)
VAULTPASSFILE=$(awk -F "=" '/VaultPassFile/ {print $2}' $INI)
rm $INI
/sbin/e-smith/db configuration set %{name} service \
status enabled \
TCPPort $PORT \
access private \
DefaultRole $ROLE \
DomainFile $DOMAIN \
ManagementKeyFile $MGMTKEY \
NamingBase $BASE \
NamingDigits $DIGITS \
VaultPassFile $VAULTPASSFILE
else
/sbin/e-smith/db configuration set %{name} service \
status enabled \
TCPPort 3000 \
access private \
DefaultRole client \
DomainFile /etc/domain.yml \
ManagementKeyFile /home/amgmt/.ssh/id_rsa.pub \
NamingBase lab \
NamingDigits 2 \
VaultPassFile /home/amgmt/.ansible/vault.txt
fi
if [ -f $DATABASE ]; then
sqlite3 -separator " " $DATABASE \
"select * from client" | while read id hostname mac role; do
/sbin/e-smith/db hosts set $hostname local \
MacAddress $mac Role $role
done
rm $DATABASE
fi
fi
%post
/etc/e-smith/events/actions/initialize-default-databases
[ -e /usr/sbin/doraemon ] && [ ! -L /usr/sbin/doraemon ] && rm /usr/sbin/doraemon
[ ! -L /usr/sbin/doraemon ] && ln -s httpd /usr/sbin/doraemon
if [ "$1" = 1 ]; then
#installation
/sbin/e-smith/db configuration set %{name} service status enabled TCPPort 3000 access private DefaultRole client DomainFile /etc/domain.yml ManagementKeyFile /home/amgmt/.ssh/id_rsa.pub NamingBase lab NamingDigits 2 VaultPassFile /home/amgmt/.ansible/vault.txt
/sbin/e-smith/expand-template /etc/sudoers
/sbin/e-smith/expand-template /etc/httpd/doraemon/httpd.conf
/sbin/start %{name} >/dev/null 2>&1 || :
/sbin/e-smith/signal-event runlevel-adjust
/sbin/e-smith/signal-event firewall-adjust
fi
if [ "$1" = 2 ]; then
#upgrade
# TODO: this won't be needed in the next version
/sbin/e-smith/expand-template /etc/sudoers
/sbin/e-smith/expand-template /etc/httpd/doraemon/httpd.conf
/sbin/start %{name} >/dev/null 2>&1 || :
/sbin/e-smith/signal-event runlevel-adjust
/sbin/e-smith/signal-event firewall-adjust
fi
%preun
#if [ "$1" = 1 ]; then
# #upgrade
#fi
if [ "$1" = 0 ]; then
#uninstallation
/sbin/stop %{name} >/dev/null 2>&1 || :
fi
%postun
#if [ "$1" = 1 ]; then
# #upgrade
#fi
if [ "$1" = 0 ]; then
#uninstallation
/sbin/e-smith/db configuration delete %{name}
/sbin/e-smith/expand-template /etc/sudoers
/sbin/e-smith/signal-event runlevel-adjust
/sbin/e-smith/signal-event firewall-adjust
fi
%clean
rm -rf %{buildroot}
%files -f %{name}-%{version}-%{release}-filelist
%defattr(0644,root,root,755)
%doc README.md LICENSE.txt
%attr(0644,srvmgr,srvmgr) %ghost %{_localstatedir}/log/doraemon/access_log
%attr(0644,srvmgr,srvmgr) %ghost %{_localstatedir}/log/doraemon/error_log
%changelog
* Sun Jun 17 2018 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 2.0.4-1
- FIX: Doraemon doesn't start after installation
* Sun Jun 17 2018 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 2.0.3-1
- FIX: whatsmyhostname correctly parse role variable
- Minor aesthetic syntax fixes
* Sun Oct 8 2017 Paolo Asperti <[email protected]> - 2.0.2-1
- FIX: bug in WOL
- FIX: small language typos
* Wed Nov 9 2016 Paolo Asperti <[email protected]> - 2.0.1-1
- PHP porting
- Added a basic UI
* Tue Oct 27 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.1-2.ns6
- Packing corrections to rpm to fix upgrading issue
* Tue Oct 27 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.1-1.ns6
- Packing new minor correction on how packages are extracted from db
* Mon Sep 11 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.0-1.ns6
- Packing new version with ansible dynamic inventory support, epoptes server role support.
* Mon Sep 07 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.1.1-1.ns6
- Packing new version with correct roles.
* Sun Sep 06 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.1.0-1.ns6
- Packing new version with new functionalities.
* Wed Jul 15 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.0.0-2.ns6
- Added logrotate file.
* Mon Jul 13 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.0.0-1.ns6
- Unique binary for both ansiblehelper and mac2hostname.