Projects

Ticket #6: Install

File Install, 13.4 KB (added by claydawg52@…, 19 months ago)

Modified Install Script (Tested on Ubuntu 8.04)

Line 
1#!/bin/bash
2
3# Install script for the Darwin Streaming Server
4# source release
5
6
7echo;echo Installing Darwin Streaming Server;echo
8
9INSTALL_OS=`uname`
10
11if [ $INSTALL_OS != "SunOS" ]; then
12        USERID=`id -u`
13else
14        USERID=`/usr/xpg4/bin/id -u`
15fi
16
17if [ $USERID = 0 ]; then
18
19        echo Checking for and Killing currently running Darwin Streaming Server
20        if [ `uname` = "FreeBSD" ]; then
21                ps -ax | awk '/DarwinStreamingServer/ {print $1}' | xargs kill -9 
22                ps -ax | awk '/streamingadminserver.pl/ {print $1}' | xargs kill -9 
23        fi
24
25        if [ `uname` = "Linux" ]; then
26                ps ax | awk '{print $1" " $5}' | awk '/DarwinStreamingServer/ {print $1}' | xargs -r kill -9 
27                ps ax | awk '/streamingadminserver.pl/ {print $1}' | xargs -r kill -9 
28        fi
29
30        if [ `uname` = "SunOS" -o `uname` = "IRIX" -o `uname` = "IRIX64" ]; then
31                ps -aef | awk '/DarwinStreamingServer/ {print $2}' | xargs -n 2 kill -9 
32                ps -aef | awk '/streamingadminserver.pl/ {print $2}' | xargs -n 1 kill -9
33        fi
34
35## REMOVED OLD VERSION ##
36
37        echo Removing previous versions of Darwin Streaming Server
38        if [ -f /usr/local/sbin/DarwinStreamingServer ]; then
39                echo removing /usr/local/sbin/DarwinStreamingServer
40                rm -f /usr/local/sbin/DarwinStreamingServer
41        fi
42       
43        if [ -f /usr/local/bin/PlaylistBroadcaster ]; then
44                echo removing /usr/local/bin/PlaylistBroadcaster
45                rm -f /usr/local/bin/PlaylistBroadcaster
46        fi
47       
48        if [ -f /usr/local/bin/MP3Broadcaster ]; then
49                echo removing /usr/local/bin/MP3Broadcaster
50                rm -f /usr/local/bin/MP3Broadcaster
51        fi
52       
53        if [ -f /usr/local/bin/qtpasswd ]; then
54                echo removing /usr/local/bin/qtpasswd
55                rm -f /usr/local/bin/qtpasswd
56        fi
57
58        if [ -f /usr/local/sbin/streamingadminserver.pl ]; then
59                echo removing /usr/local/sbin/streamingadminserver.pl
60                rm -f /usr/local/sbin/streamingadminserver.pl
61        fi
62
63        if [ -f /usr/local/bin/streamingadminserver.pl ]; then
64                echo removing /usr/local/bin/streamingadminserver.pl
65                rm -f /usr/local/bin/streamingadminserver.pl
66        fi
67
68        if [ -f /usr/local/bin/SpamPro ]; then
69                echo removing /usr/local/bin/SpamPro
70                rm -f /usr/local/bin/SpamPro
71        fi
72
73if [ -e StreamingLoadTool ]; then
74        if [ -f /usr/local/bin/StreamingLoadTool ]; then
75                echo removing /usr/local/bin/StreamingLoadTool
76                rm -f /usr/local/bin/StreamingLoadTool
77        fi
78fi
79        echo
80       
81## BACKUP OLD CONFIG FILES ##
82        echo Backing up previous config files
83
84        if [ -f /etc/streaming/streamingserver.xml ]; then
85                echo backing up /etc/streaming/streamingserver.xml to /etc/streaming/streamingserver.xml.backup
86                mv /etc/streaming/streamingserver.xml /etc/streaming/streamingserver.xml.backup
87        fi
88
89        if [ -f /etc/streaming/streamingadminserver.pem ]; then
90                echo backing up /etc/streaming/streamingadminserver.pem to /etc/streaming/streamingadminserver.pem.backup
91                mv /etc/streaming/streamingadminserver.pem /etc/streaming/streamingadminserver.pem.backup
92        fi
93       
94        if [ -f /etc/streaming/qtusers ]; then
95                echo backing up /etc/streaming/qtusers to /etc/streaming/qtusers.backup
96                mv /etc/streaming/qtusers /etc/streaming/qtusers.backup
97        fi
98
99        if [ -f /etc/streaming/qtgroups ]; then
100                echo backing up /etc/streaming/qtgroups to /etc/streaming/qtgroups.backup
101                mv /etc/streaming/qtgroups /etc/streaming/qtgroups.backup
102        fi
103       
104if [ -e StreamingLoadTool ]; then
105        if [ -f /etc/streaming/streamingloadtool.conf ]; then
106                echo backing up /etc/streaming/streamingloadtool.conf to /etc/streaming/streamingloadtool.conf.backup
107                mv /etc/streaming/streamingloadtool.conf /etc/streaming/streamingloadtool.conf.backup
108        fi
109fi
110        if [ -f /etc/streaming/relayconfig.xml ]; then
111                echo backing up /etc/streaming/relayconfig.xml to /etc/streaming/relayconfig.xml.backup
112                mv /etc/streaming/relayconfig.xml /etc/streaming/relayconfig.xml.backup
113        fi
114
115        echo
116
117## CHANGE PERL PATH IN streamingadminserver.pl AND parse_xml.cgi ##
118
119# Look for perl in the default locations
120if [ -x /usr/freeware/bin/perl ]; then
121        perldef=/usr/freeware/bin/perl
122elif [ -x /usr/local/bin/perl ]; then
123        perldef=/usr/local/bin/perl
124elif [ -x /usr/bin/perl ]; then
125        perldef=/usr/bin/perl
126else
127        perldef=""
128fi
129
130# Test if it is really perl
131$perldef -e 'print "foobar\n"' 2>/dev/null | grep foobar >/dev/null
132
133# if it isn't really perl
134if [ $? != "0" ]; then
135        # prompt the user to enter the path to perl
136        if [ "$perl" = "" ]; then
137                if [ "$perldef" = "" ]; then
138                        printf "Full path to perl: "
139                        read perl
140                        if [ "$perl" = "" ]; then
141                                echo "ERROR: No path entered!"
142                        echo ""                               
143                        exit 4
144                fi
145        else
146                        printf "Full path to perl (default $perldef): "
147            read perl
148                if [ "$perl" = "" ]; then
149                        perl=$perldef
150            fi
151        fi
152        fi
153        echo ""
154
155        # Test perl
156        echo "Testing Perl ..."
157        if [ ! -x $perl ]; then
158                echo "ERROR: Failed to find perl at $perl"
159                echo ""
160                exit 1
161        fi
162
163        $perl -e 'print "foobar\n"' 2>/dev/null | grep foobar >/dev/null
164        if [ $? != "0" ]; then
165                echo "ERROR: Failed to run test perl script. Maybe $perl is"
166                echo "not the perl interpreter, or is not installed properly"
167                echo ""
168                exit 1
169        fi
170
171        $perl -e 'exit ($] < 5.002 ? 1 : 0)'
172        if [ $? = "1" ]; then
173                echo "ERROR: Detected old perl version. The streaming server admin requires"
174                echo "perl 5.002 or better to run"
175                echo ""
176                exit 1
177        fi
178
179else
180        if [ "$perl" = "" ]; then
181        perl=$perldef
182        fi
183fi
184
185if [ "$noperlpath" = "" ]; then
186        echo "Inserting path to perl into scripts.."
187        $perl WebAdmin/perlpath.pl $perl WebAdmin/src/streamingadminserver.pl WebAdmin/WebAdminHtml/parse_xml.cgi
188    echo ""
189fi
190
191# Add the unprivileged user qtss as the server's run user
192        echo "Creating unprivileged user to run the server = \"qtss\"."
193    if [ $INSTALL_OS = "Linux" ]; then
194        /usr/sbin/groupadd qtss > /dev/null 2>&1
195        /usr/sbin/useradd -M qtss > /dev/null 2>&1
196    else
197        /usr/sbin/groupadd qtss > /dev/null 2>&1
198        /usr/sbin/useradd qtss > /dev/null 2>&1
199    fi
200       
201## INSTALL NEW VERSION ##
202    if [ ! -d /usr/local/sbin ]; then
203            echo creating "/usr/local/sbin" directory
204            mkdir -p /usr/local/sbin
205    fi             
206    if [ ! -d /usr/local/bin ]; then
207            echo creating "/usr/local/bin" directory
208            mkdir -p /usr/local/bin
209    fi             
210
211        echo copying "DarwinStreamingServer" to "/usr/local/sbin/DarwinStreamingServer"
212        cp -f DarwinStreamingServer /usr/local/sbin/
213       
214       
215        echo copying "PlaylistBroadcaster" to "/usr/local/bin/PlaylistBroadcaster"
216        cp -f ./PlaylistBroadcaster.tproj/PlaylistBroadcaster /usr/local/bin/
217       
218        echo copying "MP3Broadcaster" to "/usr/local/bin/MP3Broadcaster"
219        cp -f ./MP3Broadcaster/MP3Broadcaster /usr/local/bin/
220       
221        echo copying "qtpasswd" to "/usr/local/bin/qtpasswd"
222        cp -f ./qtpasswd.tproj/qtpasswd /usr/local/bin/
223
224        # For now, do not copy modules as there are no supported dynamic modules
225        # echo copying modules to "/usr/local/sbin/StreamingServerModules"
226        if [ ! -d /usr/local/sbin/StreamingServerModules ]; then
227                echo creating "/usr/local/sbin/StreamingServerModules" directory
228                mkdir /usr/local/sbin/StreamingServerModules
229        fi
230        #cp -f StreamingServerModules/* /usr/local/sbin/StreamingServerModules/
231
232        if [ -e /usr/local/sbin/StreamingServerModules/QTSSHomeDirectoryModule ]; then
233                echo copying "createuserstreamingdir" to "/usr/local/bin/createuserstreamingdir"
234                cp -f createuserstreamingdir $INSTALLROOT/usr/local/bin/
235        fi
236       
237        if [ ! -d /etc/streaming ]; then
238                echo creating "/etc/streaming" directory
239                mkdir -p /etc/streaming
240        fi
241       
242        if [ ! -e /etc/streaming/streamingserver.xml ]; then
243                /usr/local/sbin/DarwinStreamingServer -x
244        fi
245       
246        chmod 600 /etc/streaming/streamingserver.xml
247        chown qtss /etc/streaming/streamingserver.xml
248       
249        echo;echo copying "relayconfig.xml-Sample" to "/etc/streaming/relayconfig.xml-Sample"
250        cp -f relayconfig.xml-Sample /etc/streaming/relayconfig.xml-Sample
251        chmod 600 /etc/streaming/relayconfig.xml-Sample
252        if [ -e /etc/streaming/relayconfig.xml ]; then
253                chown qtss /etc/streaming/relayconfig.xml
254        fi
255       
256        echo;echo copying "qtusers" to "/etc/streaming/qtusers"
257        cp -f qtusers /etc/streaming/qtusers
258        chmod 600 /etc/streaming/qtusers
259        chown qtss /etc/streaming/qtusers
260
261        echo;echo copying "qtgroups" to "/etc/streaming/qtgroups"
262        cp -f qtgroups /etc/streaming/qtgroups
263        chmod 600 /etc/streaming/qtgroups
264        chown qtss /etc/streaming/qtgroups
265
266        #echo;echo copying "streamingadminserver.pem" to "/etc/streaming/streamingadminserver.pem"
267        #cp -f streamingadminserver.pem /etc/streaming/streamingadminserver.pem
268        #chmod 400 /etc/streaming/streamingadminserver.pem
269
270        if [ ! -d /var/streaming ]; then
271                echo creating "/var/streaming" directory
272                mkdir -p /var/streaming
273        fi
274       
275        echo copying "readme.txt" to "/var/streaming/readme.txt"
276        cp -f ./Documentation/readme.txt /var/streaming/readme.txt
277       
278        echo copying "3rdPartyAcknowledgements.rtf" to "/var/streaming/3rdPartyAcknowledgements.rtf"
279        cp -f ./Documentation/3rdPartyAcknowledgements.rtf /var/streaming/3rdPartyAcknowledgements.rtf
280       
281        if [ ! -d /var/streaming/logs ]; then
282                echo creating "/var/streaming/logs" directory
283                mkdir -p /var/streaming/logs
284        fi
285       
286        if [ ! -d /usr/local/movies ]; then
287                echo creating "/usr/local/movies" directory
288                mkdir -p /usr/local/movies
289        fi
290       
291        if [ ! -d /var/streaming/playlists ]; then
292                echo creating "/var/streaming/playlists" directory
293                mkdir -p /var/streaming/playlists
294        fi
295        chmod 770 /var/streaming/playlists
296        chmod 775 /usr/local/movies
297       
298    echo copying "sample_100kbit.mov" into "/usr/local/movies/sample_100kbit.mov"
299    cp -f sample_100kbit.mov /usr/local/movies/
300
301    echo copying "sample_300kbit.mov" into "/usr/local/movies/sample_300kbit.mov"
302    cp -f sample_300kbit.mov /usr/local/movies/
303
304    echo copying "sample_100kbit.mp4" into "/usr/local/movies/sample_100kbit.mp4"
305    cp -f sample_100kbit.mp4 /usr/local/movies/
306
307    echo copying "sample_300kbit.mp4" into "/usr/local/movies/sample_300kbit.mp4"
308    cp -f sample_300kbit.mp4 /usr/local/movies/
309
310    echo copying "sample.mp3" into "/usr/local/movies/sample.mp3"
311    cp -f sample.mp3 /usr/local/movies/
312
313    echo copying "sample_50kbit.3gp" into "/usr/local/movies/sample_50kbit.3gp"
314    cp -f sample_50kbit.3gp /usr/local/movies/
315
316    echo copying "sample_h264_100kbit.mp4" into "/usr/local/movies/sample_h264_100kbit.mp4"
317    cp -f sample_h264_100kbit.mp4 /usr/local/movies/
318
319    echo copying "sample_h264_300kbit.mp4" into "/usr/local/movies/sample_h264_300kbit.mp4"
320    cp -f sample_h264_300kbit.mp4 /usr/local/movies/
321
322    echo copying "sample_h264_1mbit.mp4" into "/usr/local/movies/sample_h264_1mbit.mp4"
323    cp -f sample_h264_1mbit.mp4 /usr/local/movies/
324
325if [ -e StreamingLoadTool ]; then
326        echo copying "StreamingLoadTool" to "/usr/local/bin/StreamingLoadTool"
327        cp -f ./StreamingLoadTool/StreamingLoadTool /usr/local/bin/
328       
329        echo copying "streamingloadtool.conf" to "/etc/streaming/streamingloadtool.conf"
330        cp -f ./StreamingLoadTool/streamingloadtool.conf /etc/streaming/
331fi
332       
333        #WebAdmin install
334        echo copying "streamingadminserver.pl" into "/usr/local/sbin/streamingadminserver.pl"
335        cp -f ./WebAdmin/src/streamingadminserver.pl /usr/local/sbin/streamingadminserver.pl
336       
337        if [ -d /var/streaming/AdminHtml/ ]; then
338            echo removing old version of html from "/var/streaming/AdminHtml"
339            rm -r -f /var/streaming/AdminHtml
340        fi   
341       
342        if [ ! -d /var/streaming/ ]; then
343                echo creating "/var/streaming/AdminHtml" directory
344                mkdir -p /var/streaming/
345        fi
346        echo copying Admin HTML to "/var/streaming/AdminHtml" directory
347        cp -f -r WebAdmin/WebAdminHtml /var/streaming/AdminHtml
348       
349
350        chown -R -f qtss /var/streaming/
351        chown -R -f qtss /etc/streaming/
352        chown -R -f qtss /usr/local/movies/
353
354        echo;echo "Launching streamingadminserver.pl"
355        /usr/local/sbin/streamingadminserver.pl
356       
357        echo;echo Installation Complete
358
359        # Setup for DSS
360        # Prompts for a username and password
361        # that can be used to administer the server
362       
363        echo;echo Darwin Streaming Server Setup;echo
364       
365        # prompt the user to enter the admin username
366        while [ "$username" = "" ]; do
367                printf "In order to administer the Darwin Streaming Server you must create an administrator user [Note: The administrator user name cannot contain spaces, or single or double quote characters, and cannot be more than 255 characters long].\n"
368               
369                printf "Please enter a new administrator user name: "
370                read username
371                if [ "$username" = "" ]; then
372                        echo ""
373                        echo "Error: No username entered!"
374                        echo ""
375                fi
376        done
377        echo ""
378       
379        # prompt the user to enter the admin password
380        while [ "$password" = "" ]; do
381                printf "\nYou must also enter a password for the administrator user [Note: The administrator password cannot contain spaces, or quotes, either single or double, and cannot be more than 80 characters long].\n"
382
383                printf "Please enter a new administrator Password: "
384                stty -echo
385                read password
386                stty echo
387                echo ""
388                printf "Re-enter the new administrator password: "
389                stty -echo
390                read password1
391                stty echo
392                if [ "$password" = "" ]; then
393                        echo ""
394                        echo "Error: No password entered!"
395                        echo ""
396                fi
397                if [ "$password" != "$password1" ]; then
398                        echo ""
399                        echo "Error: passwords entered do not match!"
400                        echo ""
401                        password=""
402                fi
403       
404        done
405        echo ""
406       
407        # Add the new admin username to /etc/streaming/qtusers
408        /usr/local/bin/qtpasswd -p $password $username
409       
410        # Add the new admin username to /etc/streaming/qtgroups
411        # and delete the default admin username
412        echo admin: $username > /etc/streaming/qtgroups.tmp
413        mv /etc/streaming/qtgroups.tmp /etc/streaming/qtgroups
414       
415        # Remove the default admin username to /etc/streaming/qtusers
416        /usr/local/bin/qtpasswd -F -d 'aGFja21l' > /dev/null
417               
418        chown -R -f qtss /etc/streaming/
419       
420        echo Setup Complete!
421       
422else
423
424        echo "Unable to perform install"
425        echo "You must be logged in as root to install Darwin Streaming Server";echo
426        exit 1
427fi