-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathissabel-firstboot.spec
More file actions
173 lines (148 loc) · 4.95 KB
/
issabel-firstboot.spec
File metadata and controls
173 lines (148 loc) · 4.95 KB
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
%define modname firstboot
%if 0%{?rhel} == 7
%define dist .el7
%endif
Summary: Issabel First Boot Setup
Name: issabel-firstboot
Version: 5.0.0
Release: 1
License: GPL
Group: Applications/System
Source0: issabel-%{modname}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{modname}-%{version}-root
BuildArch: noarch
#%if 0%{?el7}
#Requires: mysql, mysql-server, dialog
#%else
Requires: mariadb, mariadb-server, dialog
#%endif
Requires: sed, grep
Requires: coreutils
Requires: cracklib
Requires: issabel-config_helpers
Requires(post): chkconfig, /bin/cp
Obsoletes: elastix-firstboot
Provides: elastix-firstboot
# commands: /bin/chvt
Requires: kbd
Requires: /usr/sbin/saslpasswd2
%description
This module contains (or should contain) utilities and configurations that
cannot be prepared at install time from the ISO image, and are therefore
delayed until the first boot of the newly installed system. The main aim of
this script is to wait until all RPMS are able to either prepare their
databases on their own, or delegate this task to this package.
%prep
%setup -n %{name}-%{version}
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/init.d/
mkdir -p $RPM_BUILD_ROOT/var/spool/issabel-mysqldbscripts/
mkdir -p $RPM_BUILD_ROOT/usr/share/issabel-firstboot/
mkdir -p $RPM_BUILD_ROOT/usr/bin/
mkdir -p $RPM_BUILD_ROOT/usr/sbin/
mkdir -p $RPM_BUILD_ROOT/usr/local/sbin/
cp issabel-firstboot $RPM_BUILD_ROOT/etc/init.d/
cp change-passwords issabel-admin-passwords $RPM_BUILD_ROOT/usr/bin/
cp issabel-patreon $RPM_BUILD_ROOT/usr/bin/
cp generate_self_signed.sh $RPM_BUILD_ROOT/usr/local/sbin
mv compat-dbscripts/ $RPM_BUILD_ROOT/usr/share/issabel-firstboot/
%post
if [ -d /etc/systemd ] ; then
cat > /usr/lib/systemd/system/issabel-firstboot.service <<'ISSABELFIRSTBOOT'
[Unit]
Description=issabel-firstboot.service
After=getty@tty2.service
After=mariadb.service
After=asterisk.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c "dmesg -D && chvt 2 && /usr/bin/issabel-admin-passwords --init && chvt 1 && dmesg -E"
#ExecStartPre=-/bin/bash -c "chvt 2 && /usr/src/geoip_install.sh && chvt 1"
ExecReload=/bin/kill -HUP $MAINPID
RemainAfterExit=no
WorkingDirectory=/
Environment=TERM=linux
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty2
TTYReset=yes
TTYVHangup=yes
[Install]
WantedBy=default.target
ISSABELFIRSTBOOT
systemctl enable issabel-firstboot.service
cat > /usr/lib/systemd/system/amportal-reload.service <<'AMPORTALRELOAD'
[Unit]
Description=amportal-reload.service
After=asterisk.service
[Service]
Type=oneshot
ExecStart=/usr/sbin/amportal a r
RemainAfterExit=no
WorkingDirectory=/
[Install]
WantedBy=default.target
AMPORTALRELOAD
systemctl enable amportal-reload.service
else
chkconfig --del issabel-firstboot
chkconfig --add issabel-firstboot
chkconfig --level 2345 issabel-firstboot on
fi
# The following scripts are placed in the spool directory if the corresponding
# database does not exist. This is only temporary and should be removed when the
# corresponding package does this by itself.
if [ ! -d /var/lib/mysql/asteriskcdrdb ] ; then
cp /usr/share/issabel-firstboot/compat-dbscripts/02-asteriskuser-password.sql /var/spool/issabel-mysqldbscripts/
fi
# If installing, the system might have mysql running (upgrading from a RC).
# The default password is written to the configuration file.
if [ $1 -eq 1 ] ; then
if [ -e /var/lib/mysql/mysql ] ; then
if [ ! -e /etc/issabel.conf ] ; then
echo "Installing in active system - creating empty /etc/issabel.conf"
touch /etc/issabel.conf
#echo "mysqlrootpwd=iSsAbEl.2o17" >> /etc/issabel.conf
fi
if [ -f /etc/issabel.conf ] ; then
grep 'cyrususerpwd' /etc/issabel.conf &> /dev/null
res=$?
if [ $res != 0 ] ; then
echo "cyrususerpwd=issabel" >> /etc/issabel.conf
fi
fi
fi
fi
# If updating, and there is no /etc/issabel.conf , a default file is generated with
# legacy password so new modules continue to work.
if [ $1 -eq 2 ] ; then
if [ ! -e /etc/issabel.conf ] ; then
echo "Updating in active system - creating empty /etc/issabel.conf"
touch /etc/issabel.conf
#echo "mysqlrootpwd=iSsAbEl.2o17" >> /etc/issabel.conf
fi
if [ -f /etc/issabel.conf ] ; then
grep 'cyrususerpwd' /etc/issabel.conf &> /dev/null
res=$?
if [ $res != 0 ] ; then
echo "cyrususerpwd=issabel" >> /etc/issabel.conf
fi
fi
fi
# If updating, ensure issabel-firstboot now runs at shutdown
if [ $1 -eq 2 ] ; then
touch /var/lock/subsys/issabel-firstboot
fi
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%attr(755, root, root) /etc/init.d/*
%dir %{_localstatedir}/spool/issabel-mysqldbscripts/
/usr/share/issabel-firstboot/compat-dbscripts/02-asteriskuser-password.sql
/usr/bin/change-passwords
/usr/bin/issabel-admin-passwords
/usr/bin/issabel-patreon
%attr(755, root, root) /usr/local/sbin/generate_self_signed.sh
%changelog