Advertisement
Guest User

Darwin Streaming Server CentOS 5.5 x84_64 fixed install.sh

a guest
Jul 17th, 2010
1,251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Install script for the Darwin Streaming Server
  4. # source release
  5.  
  6.  
  7. echo;echo Installing Darwin Streaming Server;echo
  8.  
  9. INSTALL_OS=`uname`
  10.  
  11. if [ $INSTALL_OS != "SunOS" ]; then
  12. USERID=`id -u`
  13. else
  14. USERID=`/usr/xpg4/bin/id -u`
  15. fi
  16.  
  17. if [ $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.  
  73. if [ -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
  78. fi
  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.  
  104. if [ -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
  109. fi
  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
  120. if [ -x /usr/freeware/bin/perl ]; then
  121. perldef=/usr/freeware/bin/perl
  122. elif [ -x /usr/local/bin/perl ]; then
  123. perldef=/usr/local/bin/perl
  124. elif [ -x /usr/bin/perl ]; then
  125. perldef=/usr/bin/perl
  126. else
  127. perldef=""
  128. fi
  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
  134. if [ $? != "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.  
  179. else
  180. if [ "$perl" = "" ]; then
  181. perl=$perldef
  182. fi
  183. fi
  184.  
  185. if [ "$noperlpath" = "" ]; then
  186. echo "Inserting path to perl into scripts.."
  187. cd WebAdmin/
  188. $perl perlpath.pl $perl streamingadminserver.pl AdminHtml/parse_xml.cgi
  189. echo ""
  190. cd ..
  191. fi
  192.  
  193. # Add the unprivileged user qtss as the server's run user
  194. echo "Creating unprivileged user to run the server = \"qtss\"."
  195. if [ $INSTALL_OS = "Linux" ]; then
  196. /usr/sbin/groupadd qtss > /dev/null 2>&1
  197. /usr/sbin/useradd -M qtss > /dev/null 2>&1
  198. else
  199. /usr/sbin/groupadd qtss > /dev/null 2>&1
  200. /usr/sbin/useradd qtss > /dev/null 2>&1
  201. fi
  202.  
  203. ## INSTALL NEW VERSION ##
  204. if [ ! -d /usr/local/sbin ]; then
  205. echo creating "/usr/local/sbin" directory
  206. mkdir -p /usr/local/sbin
  207. fi
  208. if [ ! -d /usr/local/bin ]; then
  209. echo creating "/usr/local/bin" directory
  210. mkdir -p /usr/local/bin
  211. fi
  212.  
  213. echo copying "DarwinStreamingServer" to "/usr/local/sbin/DarwinStreamingServer"
  214. cp -f DarwinStreamingServer /usr/local/sbin/
  215.  
  216.  
  217. echo copying "PlaylistBroadcaster" to "/usr/local/bin/PlaylistBroadcaster"
  218. cd PlaylistBroadcaster.tproj/
  219. cp -f PlaylistBroadcaster /usr/local/bin/
  220. cd ..
  221.  
  222. echo copying "MP3Broadcaster" to "/usr/local/bin/MP3Broadcaster"
  223. cd MP3Broadcaster/
  224. cp -f MP3Broadcaster /usr/local/bin/
  225. cd ..
  226. echo copying "qtpasswd" to "/usr/local/bin/qtpasswd"
  227. cd qtpasswd.tproj/
  228. cp -f qtpasswd /usr/local/bin/
  229. cd ..
  230. # For now, do not copy modules as there are no supported dynamic modules
  231. # echo copying modules to "/usr/local/sbin/StreamingServerModules"
  232. if [ ! -d /usr/local/sbin/StreamingServerModules ]; then
  233. echo creating "/usr/local/sbin/StreamingServerModules" directory
  234. mkdir /usr/local/sbin/StreamingServerModules
  235. fi
  236. mkdir StreamingServerModules
  237. cd APIModules/
  238. cp -f * /usr/local/sbin/StreamingServerModules/
  239. cd ..
  240. if [ -e /usr/local/sbin/StreamingServerModules/QTSSHomeDirectoryModule ]; then
  241. echo copying "createuserstreamingdir" to "/usr/local/bin/createuserstreamingdir"
  242. cp -f createuserstreamingdir $INSTALLROOT/usr/local/bin/
  243. fi
  244.  
  245. if [ ! -d /etc/streaming ]; then
  246. echo creating "/etc/streaming" directory
  247. mkdir -p /etc/streaming
  248. fi
  249.  
  250. if [ ! -e /etc/streaming/streamingserver.xml ]; then
  251. /usr/local/sbin/DarwinStreamingServer -x
  252. fi
  253.  
  254. chmod 600 /etc/streaming/streamingserver.xml
  255. chown qtss /etc/streaming/streamingserver.xml
  256.  
  257. echo;echo copying "relayconfig.xml-Sample" to "/etc/streaming/relayconfig.xml-Sample"
  258. cp -f relayconfig.xml-Sample /etc/streaming/relayconfig.xml-Sample
  259. chmod 600 /etc/streaming/relayconfig.xml-Sample
  260. if [ -e /etc/streaming/relayconfig.xml ]; then
  261. chown qtss /etc/streaming/relayconfig.xml
  262. fi
  263.  
  264. echo;echo copying "qtusers" to "/etc/streaming/qtusers"
  265. cp -f qtusers /etc/streaming/qtusers
  266. chmod 600 /etc/streaming/qtusers
  267. chown qtss /etc/streaming/qtusers
  268.  
  269. echo;echo copying "qtgroups" to "/etc/streaming/qtgroups"
  270. cp -f qtgroups /etc/streaming/qtgroups
  271. chmod 600 /etc/streaming/qtgroups
  272. chown qtss /etc/streaming/qtgroups
  273.  
  274. #echo;echo copying "streamingadminserver.pem" to "/etc/streaming/streamingadminserver.pem"
  275. #cp -f streamingadminserver.pem /etc/streaming/streamingadminserver.pem
  276. #chmod 400 /etc/streaming/streamingadminserver.pem
  277.  
  278. if [ ! -d /var/streaming ]; then
  279. echo creating "/var/streaming" directory
  280. mkdir -p /var/streaming
  281. fi
  282.  
  283. echo copying "readme.txt" to "/var/streaming/readme.txt"
  284. cd Documentation/
  285. cp -f readme.txt /var/streaming/readme.txt
  286. cd ..
  287. echo copying "3rdPartyAcknowledgements.rtf" to "/var/streaming/3rdPartyAcknowledgements.rtf"
  288. cd Documentation/
  289. cp -f 3rdPartyAcknowledgements.rtf /var/streaming/3rdPartyAcknowledgements.rtf
  290. cd ..
  291. if [ ! -d /var/streaming/logs ]; then
  292. echo creating "/var/streaming/logs" directory
  293. mkdir -p /var/streaming/logs
  294. fi
  295.  
  296. if [ ! -d /usr/local/movies ]; then
  297. echo creating "/usr/local/movies" directory
  298. mkdir -p /usr/local/movies
  299. fi
  300.  
  301. if [ ! -d /var/streaming/playlists ]; then
  302. echo creating "/var/streaming/playlists" directory
  303. mkdir -p /var/streaming/playlists
  304. fi
  305. chmod 770 /var/streaming/playlists
  306. chmod 775 /usr/local/movies
  307.  
  308. echo copying "sample_100kbit.mov" into "/usr/local/movies/sample_100kbit.mov"
  309. cp -f sample_100kbit.mov /usr/local/movies/
  310.  
  311. echo copying "sample_300kbit.mov" into "/usr/local/movies/sample_300kbit.mov"
  312. cp -f sample_300kbit.mov /usr/local/movies/
  313.  
  314. echo copying "sample_100kbit.mp4" into "/usr/local/movies/sample_100kbit.mp4"
  315. cp -f sample_100kbit.mp4 /usr/local/movies/
  316.  
  317. echo copying "sample_300kbit.mp4" into "/usr/local/movies/sample_300kbit.mp4"
  318. cp -f sample_300kbit.mp4 /usr/local/movies/
  319.  
  320. echo copying "sample.mp3" into "/usr/local/movies/sample.mp3"
  321. cp -f sample.mp3 /usr/local/movies/
  322.  
  323. echo copying "sample_50kbit.3gp" into "/usr/local/movies/sample_50kbit.3gp"
  324. cp -f sample_50kbit.3gp /usr/local/movies/
  325.  
  326. echo copying "sample_h264_100kbit.mp4" into "/usr/local/movies/sample_h264_100kbit.mp4"
  327. cp -f sample_h264_100kbit.mp4 /usr/local/movies/
  328.  
  329. echo copying "sample_h264_300kbit.mp4" into "/usr/local/movies/sample_h264_300kbit.mp4"
  330. cp -f sample_h264_300kbit.mp4 /usr/local/movies/
  331.  
  332. echo copying "sample_h264_1mbit.mp4" into "/usr/local/movies/sample_h264_1mbit.mp4"
  333. cp -f sample_h264_1mbit.mp4 /usr/local/movies/
  334.  
  335. if [ -e StreamingLoadTool ]; then
  336. echo copying "StreamingLoadTool" to "/usr/local/bin/StreamingLoadTool"
  337. cd StreamingLoadTool/
  338. cp -f StreamingLoadTool /usr/local/bin/
  339.  
  340. echo copying "streamingloadtool.conf" to "/etc/streaming/streamingloadtool.conf"
  341. cp -f streamingloadtool.conf /etc/streaming/
  342. cd ..
  343. fi
  344.  
  345. #WebAdmin install
  346. echo copying "streamingadminserver.pl" into "/usr/local/sbin/streamingadminserver.pl"
  347. cd WebAdmin/src/
  348. cp -f streamingadminserver.pl /usr/local/sbin/streamingadminserver.pl
  349. cd ..
  350. cd ..
  351. if [ -d /var/streaming/AdminHtml/ ]; then
  352. echo removing old version of html from "/var/streaming/AdminHtml"
  353. rm -r -f /var/streaming/AdminHtml/*
  354. fi
  355.  
  356. if [ ! -d /var/streaming/ ]; then
  357. echo creating "/var/streaming/AdminHtml" directory
  358. mkdir -p /var/streaming/AdminHtml
  359.  
  360. fi
  361. echo copying Admin HTML to "/var/streaming/AdminHtml" directory
  362. cd WebAdmin/WebAdminHtml/
  363. cp -f -r * /var/streaming/AdminHtml
  364. cd ..
  365. cd ..
  366. chown -R -f qtss /var/streaming/
  367. chown -R -f qtss /etc/streaming/
  368. chown -R -f qtss /usr/local/movies/
  369.  
  370. echo;echo "Launching streamingadminserver.pl"
  371. /usr/local/sbin/streamingadminserver.pl
  372.  
  373. echo;echo Installation Complete
  374.  
  375. # Setup for DSS
  376. # Prompts for a username and password
  377. # that can be used to administer the server
  378.  
  379. echo;echo Darwin Streaming Server Setup;echo
  380.  
  381. # prompt the user to enter the admin username
  382. while [ "$username" = "" ]; do
  383. 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"
  384.  
  385. printf "Please enter a new administrator user name: "
  386. read username
  387. if [ "$username" = "" ]; then
  388. echo ""
  389. echo "Error: No username entered!"
  390. echo ""
  391. fi
  392. done
  393. echo ""
  394.  
  395. # prompt the user to enter the admin password
  396. while [ "$password" = "" ]; do
  397. 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"
  398.  
  399. printf "Please enter a new administrator Password: "
  400. stty -echo
  401. read password
  402. stty echo
  403. echo ""
  404. printf "Re-enter the new administrator password: "
  405. stty -echo
  406. read password1
  407. stty echo
  408. if [ "$password" = "" ]; then
  409. echo ""
  410. echo "Error: No password entered!"
  411. echo ""
  412. fi
  413. if [ "$password" != "$password1" ]; then
  414. echo ""
  415. echo "Error: passwords entered do not match!"
  416. echo ""
  417. password=""
  418. fi
  419.  
  420. done
  421. echo ""
  422.  
  423. # Add the new admin username to /etc/streaming/qtusers
  424. /usr/local/bin/qtpasswd -p $password $username
  425.  
  426. # Add the new admin username to /etc/streaming/qtgroups
  427. # and delete the default admin username
  428. echo admin: $username > /etc/streaming/qtgroups.tmp
  429. mv /etc/streaming/qtgroups.tmp /etc/streaming/qtgroups
  430.  
  431. # Remove the default admin username to /etc/streaming/qtusers
  432. /usr/local/bin/qtpasswd -F -d 'aGFja21l' > /dev/null
  433.  
  434. chown -R -f qtss /etc/streaming/
  435.  
  436. echo Setup Complete!
  437.  
  438. else
  439.  
  440. echo "Unable to perform install"
  441. echo "You must be logged in as root to install Darwin Streaming Server";echo
  442. exit 1
  443. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement