This repository has been archived by the owner on Oct 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphase2.sh
executable file
·233 lines (198 loc) · 4.71 KB
/
phase2.sh
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#! /bin/bash
HWTYPE=usbradio
#HWTYPE=pciradio
REPO=$(cat /etc/rc.d/acidrepo)
SSHDCONF=/etc/ssh/sshd_config
SSHDPORT=222
TMP=/tmp
INSTALLOG=/root/acid-install.log
SCRIPTLOC=/usr/local/sbin
ZSYNCVERS=zsync-0.6.1
ZSYNCSOURCEKIT=$ZSYNCVERS.tar.bz2
ASTBUILDDIR=/usr/src/astsrc
SYSSRCDIR=/usr/src
function log {
local tstamp=$(/bin/date)
echo "$tstamp:$1" >>$INSTALLOG
}
function logecho {
echo "$1"
log "$1"
}
function die {
logecho "Fatal error: $1"
exit 255
}
function promptyn
{
echo -n "$1 [y/N]? "
read ANSWER
if [ ! -z $ANSWER ]
then
if [ $ANSWER = Y ] || [ $ANSWER = y ]
then
ANSWER=Y
else
ANSWER=N
fi
else
ANSWER=N
fi
}
logecho "****** Phase 2 post install ******"
sleep 1
if [ -e $ASTBUILDDIR ]
then
rm -rf $ASTBUILDDIR
fi
mkdir -p $ASTBUILDDIR
cd $ASTBUILDDIR
logecho "Getting asterisk install script from $REPO..."
wget -q $REPO/installcd/astinstall.sh -O /etc/rc.d/astinstall.sh
if [ $? -gt 0 ]
then
die "Unable to download Asterisk install script"
else
chmod 755 /etc/rc.d/astinstall.sh
fi
logecho "Getting files.tar.gz from $REPO..."
wget -q $REPO/installcd/files.tar.gz -O $ASTBUILDDIR/files.tar.gz
if [ $? -gt 0 ]
then
die "Unable to download files.tar.gz"
fi
if [ -e /etc/rc.d/astinstall.sh ]
then
/etc/rc.d/astinstall.sh
if [ $? -gt 0 ]
then
die "Unable to install Asterisk!"
fi
else
die "exec of /etc/rc.d/astinstall.sh failed!"
fi
#Download, compile and install zsync
cd $SYSSRCDIR
logecho "Downloading zsync from $REPO"
wget -q -O /tmp/$ZSYNCSOURCEKIT $REPO/installcd/$ZSYNCSOURCEKIT
if [ $? -gt 0 ]
then
die "Unable to download $ZSYNCVERS"
fi
tar xvjf /tmp/$ZSYNCSOURCEKIT
if [ $? -gt 0 ]
then
die "Unable to unpack $ZSYNCVERS"
fi
cd $SYSSRCDIR/$ZSYNCVERS
./configure
make
if [ $? -gt 0 ]
then
die "Unable to make $ZSYNCVERS"
fi
make install
if [ $? -gt 0 ]
then
die "Unable to install $ZSYNCVERS"
fi
rm -f /tmp/$ZSYNCSOURCEKIT
logecho "Setting up config..."
rm -rf /etc/asterisk
mkdir -p /etc/asterisk
cp $ASTBUILDDIR/configs/*.conf /etc/asterisk
if [ $? -gt 0 ]
then
die "Unable to copy configs 1"
fi
cp $ASTBUILDDIR/configs/$HWTYPE/*.conf /etc/asterisk
if [ $? -gt 0 ]
then
die "Unable to copy configs 2"
fi
mv /etc/asterisk/zaptel.conf /etc
if [ $? -gt 0 ]
then
die "Unable to copy configs 3"
fi
logecho "Getting misc files..."
wget -q $REPO/installcd/acidvers -O /etc/rc.d/acidvers
if [ $? -ne 0 ]
then
die "Could set ACID version"
fi
wget -q $REPO/installcd/savenode.conf -O /etc/asterisk/savenode.conf
logecho "Getting control and helper scripts..."
wget -q $REPO/installcd/scrget.sh -O /tmp/scrget.sh
if [ $? -ne 0 ]
then
die "Download of scrget.sh failed!"
fi
chmod 750 /tmp/scrget.sh
/tmp/scrget.sh
if [ $? -ne 0 ]
then
die "Could not execute script /tmp/scrget.sh"
fi
rm -f /tmp/scrget.sh
mv -f /etc/rc.d/rc.local.orig /etc/rc.d/rc.local; sync
egrep setterm /etc/rc.d/rc.local
if [ $? -gt 0 ]
then
logecho "Installing setterms in /usr/local"
echo 'for(( i = 1; i < 7; i++))' >> /etc/rc.d/rc.local
echo 'do' >> /etc/rc.d/rc.local
echo ' setterm -blank 0 >/dev/tty$i' >> /etc/rc.d/rc.local
echo 'done' >> /etc/rc.d/rc.local
fi
egrep updatenodelist /etc/rc.d/rc.local
if [ $? -gt 0 ]
then
logecho "Installing rc.updatenodelist in /usr/local"
echo "/etc/rc.d/rc.updatenodelist &" >> /etc/rc.d/rc.local
fi
sync
logecho "Turning off unused services..."
chkconfig acpid off
chkconfig apmd off
chkconfig autofs off
chkconfig bluetooth off
chkconfig cpuspeed off
chkconfig cups off
chkconfig gpm off
chkconfig haldaemon off
chkconfig hidd off
chkconfig lvm2-monitor off
chkconfig mcstrans off
chkconfig mdmonitor off
chkconfig netfs off
chkconfig nfslock off
chkconfig pcscd off
chkconfig portmap off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig avahi-daemon off
chkconfig yum-updatesd off
echo "**************************************"
echo "* Setup for app_rpt/Centos *"
echo "**************************************"
echo
echo "You must supply a root password..."
passwd root
logecho "Password set"
logecho "Changing SSHD port number to $SSHDPORT..."
sed "s/^#Port[ \t]*[0-9]*/Port 222/" <$SSHDCONF >$TMP/sshd_config
mv -f $TMP/sshd_config $SSHDCONF || die "mv sshd_config failed"
logecho "Enabling SSHD and Asterisk to start on next boot..."
chkconfig sshd on
chkconfig iptables off
logecho "Running nodesetup.sh..."
if [ -e $SCRIPTLOC/nodesetup.sh ]
then
$SCRIPTLOC/nodesetup.sh || die "Could not modify asterisk config files!"
fi
echo "Script done. Please plug in your modified USB fob or URI now!"
sleep 10
logecho "Rebooting...."
reboot
exit