Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.25 KB | None | 0 0
  1. <?php
  2.  
  3. $we_root = trim(shell_exec("whoami"));
  4. if (strcmp($we_root, "root") !== 0) {
  5. echo "Please execute this script as root! Exitting...";
  6. exit;
  7. }
  8.  
  9. /*echo "FOS: Checking for existing installations!\r";
  10. shell_exec("killall -9 ffmpeg php5-fpm php-fpm nginx nginx_fos > /dev/null");
  11. shell_exec("service php5-fpm stop > /dev/null");
  12. shell_exec("rm -rf /usr/src/FOS-Streaming/* > /dev/null");
  13. shell_exec("rm -rf /usr/src/FOS-Streaming/./.* > /dev/null");
  14. shell_exec("umount /home/fos-streaming/fos/www/streams > /dev/null");
  15. shell_exec("umount /home/fos-streaming/fos/www/cache > /dev/null");
  16. shell_exec("rm -rf /home/fos-streaming > /dev/null");
  17. shell_exec("deluser fosstreaming -q");
  18. shell_exec("delgroup fosstreaming -q");*/
  19.  
  20. function InstallSources($CodeName) {
  21. echo "FOS: Sources ($CodeName)...\n";
  22. switch ($CodeName) {
  23. case 'wheezy':
  24. shell_exec("echo 'deb http://ftp.de.debian.org/debian stable main contrib non-free' > /etc/apt/sources.list.d/fos_streaming.list");
  25. shell_exec("echo 'deb-src http://ftp.de.debian.org/debian stable main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  26. shell_exec("echo 'deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  27. shell_exec("echo 'deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  28. shell_exec("echo 'deb http://security.debian.org/ wheezy/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  29. shell_exec("echo 'deb-src http://security.debian.org/ wheezy/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  30. break;
  31.  
  32. case 'squeeze':
  33. shell_exec("echo 'deb http://archive.debian.org/debian oldstable main contrib non-free' > /etc/apt/sources.list.d/fos_streaming.list");
  34. shell_exec("echo 'deb-src http://archive.debian.org/debian oldstable main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  35. shell_exec("echo 'deb http://ftp.debian.org/debian/ squeeze-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  36. shell_exec("echo 'deb-src http://ftp.debian.org/debian/ squeeze-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  37. shell_exec("echo 'deb http://security.debian.org/ squeeze/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  38. shell_exec("echo 'deb-src http://security.debian.org/ squeeze/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  39. break;
  40.  
  41. case "jessie":
  42. shell_exec("echo 'deb http://ftp.fr.debian.org/debian testing main contrib non-free' > /etc/apt/sources.list.d/fos_streaming.list");
  43. shell_exec("echo 'deb-src http://ftp.fr.debian.org/debian testing main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  44. shell_exec("echo 'deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  45. shell_exec("echo 'deb-src http://ftp.debian.org/debian/ jessie-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  46. shell_exec("echo 'deb http://security.debian.org/ jessie/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  47. shell_exec("echo 'deb-src http://security.debian.org/ jessie/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  48. break;
  49.  
  50. case "sid":
  51. shell_exec("echo 'deb http://ftp.us.debian.org/debian unstable main contrib non-free' > /etc/apt/sources.list.d/fos_streaming.list");
  52. shell_exec("echo 'deb-src http://ftp.us.debian.org/debian unstable main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  53. shell_exec("echo 'deb http://ftp.debian.org/debian/ Sid-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  54. shell_exec("echo 'deb-src http://ftp.debian.org/debian/ Sid-updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  55. shell_exec("echo 'deb http://security.debian.org/ Sid/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  56. shell_exec("echo 'deb-src http://security.debian.org/ Sid/updates main contrib non-free' >> /etc/apt/sources.list.d/fos_streaming.list");
  57. break;
  58.  
  59. case 'trusty':
  60. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse' > /etc/apt/sources.list.d/fos_streaming.list");
  61. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  62. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  63. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  64. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  65. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  66. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  67. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  68. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  69. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  70. break;
  71.  
  72. case 'utopic':
  73. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ utopic main restricted universe multiverse' > /etc/apt/sources.list.d/fos_streaming.list");
  74. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ utopic main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  75. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ utopic-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  76. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ utopic-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  77. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ utopic-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  78. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ utopic-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  79. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ utopic-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  80. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ utopic-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  81. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ utopic-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  82. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ utopic-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  83. break;
  84.  
  85. case 'saucy':
  86. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse' > /etc/apt/sources.list.d/fos_streaming.list'");
  87. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  88. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  89. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  90. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ saucy-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  91. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  92. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  93. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  94. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  95. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  96. break;
  97.  
  98. case "wily":
  99. shell_exec("echo '###### Ubuntu Main Repos' > /etc/apt/sources.list.d/fos_streaming.list");
  100. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ wily main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  101. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ wily main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  102. shell_exec("echo '###### Ubuntu Update Repos' >> /etc/apt/sources.list.d/fos_streaming.list");
  103. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ wily-security main restricted universe multiverse ' >> /etc/apt/sources.list.d/fos_streaming.list");
  104. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ wily-updates main restricted universe multiverse ' >> /etc/apt/sources.list.d/fos_streaming.list");
  105. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ wily-proposed main restricted universe multiverse ' >> /etc/apt/sources.list.d/fos_streaming.list");
  106. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ wily-security main restricted universe multiverse ' >> /etc/apt/sources.list.d/fos_streaming.list");
  107. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ wily-updates main restricted universe multiverse ' >> /etc/apt/sources.list.d/fos_streaming.list");
  108. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ wily-proposed main restricted universe multiverse ' >> /etc/apt/sources.list.d/fos_streaming.list");
  109. shell_exec("echo '###### Ubuntu Partner Repo' >> /etc/apt/sources.list.d/fos_streaming.list");
  110. shell_exec("echo 'deb http://archive.canonical.com/ubuntu wily partner' >> /etc/apt/sources.list.d/fos_streaming.list");
  111. shell_exec("echo 'deb-src http://archive.canonical.com/ubuntu wily partner' >> /etc/apt/sources.list.d/fos_streaming.list");
  112. break;
  113.  
  114. case "vivid":
  115. shell_exec("echo '###### Ubuntu Main Repos' > /etc/apt/sources.list.d/fos_streaming.list");
  116. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ vivid main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  117. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ vivid main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  118. shell_exec("echo '###### Ubuntu Update Repos' >> /etc/apt/sources.list.d/fos_streaming.list");
  119. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ vivid-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  120. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ vivid-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  121. shell_exec("echo 'deb http://us.archive.ubuntu.com/ubuntu/ vivid-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  122. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ vivid-security main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  123. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ vivid-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  124. shell_exec("echo 'deb-src http://us.archive.ubuntu.com/ubuntu/ vivid-proposed main restricted universe multiverse' >> /etc/apt/sources.list.d/fos_streaming.list");
  125. shell_exec("echo '###### Ubuntu Partner Repo' >> /etc/apt/sources.list.d/fos_streaming.list");
  126. shell_exec("echo 'deb http://archive.canonical.com/ubuntu vivid partner' >> /etc/apt/sources.list.d/fos_streaming.list");
  127. shell_exec("echo 'deb-src http://archive.canonical.com/ubuntu vivid partner' >> /etc/apt/sources.list.d/fos_streaming.list");
  128. break;
  129.  
  130. default:
  131. return true;
  132. }
  133. return true;
  134. }
  135.  
  136. $release_info = shell_exec("lsb_release -i -s");
  137. $arch = shell_exec("uname -m");
  138. echo "Welcome \n";
  139. echo "FOS-Streaming will be installed on your system \n";
  140. echo "Please don't close this session until it's finished \n \n";
  141. echo "1. [Distribution Detection:] ";
  142. echo " [############";
  143.  
  144. if (strcmp($release_info, "Ubuntu") || strcmp($release_info, "Debian")) {
  145. echo "]PASS \n";
  146. $CodeName = trim(strtolower(shell_exec('lsb_release -c -s')));
  147. /*if (!file_exists("/etc/apt/sources.list.d/fos_streaming.list")) {
  148. InstallSources($CodeName);
  149. }*/
  150. echo "Updating newly added sources, please hold...";
  151. //shell_exec("apt-get update > /dev/null");
  152. } else {
  153. echo "]FAIL. Need Ubuntu or Debian!!! \n";
  154. exit();
  155. }
  156.  
  157. /*shell_exec("/usr/sbin/useradd -s /sbin/nologin -U -d /home/fos-streaming -m fosstreaming");
  158.  
  159. shell_exec("mkdir /home/fos-streaming/fos");
  160. shell_exec("mkdir /home/fos-streaming/fos/www");
  161.  
  162.  
  163. if (!file_exists("/usr/src/FOS-Streaming")) {
  164. shell_exec("mkdir /usr/src/FOS-Streaming");
  165. }
  166.  
  167. echo "##";*/
  168.  
  169. function GetFos() {
  170. shell_exec("rm -rf /usr/src/FOS-Streaming/*");
  171. shell_exec("git clone https://github.com/vaniusha3/IPTV-MD.git /usr/src/FOS-Streaming/ > /dev/null");
  172. shell_exec("mv /usr/src/FOS-Streaming/* /home/fos-streaming/fos/www/ > /dev/null");
  173. if (!file_exists("/usr/bin/composer.phar")) {
  174. shell_exec("wget https://getcomposer.org/installer -O /tmp/installer > /dev/null");
  175. shell_exec("/usr/bin/php /tmp/installer --quiet");
  176. shell_exec("/bin/cp /tmp/composer.phar /usr/bin/composer.phar > /dev/null");
  177. }
  178. shell_exec("chmod +x /usr/bin/composer.phar");
  179. shell_exec("/usr/bin/composer.phar install -d /home/fos-streaming/fos/www/ --quiet");
  180. }
  181.  
  182. function AddSudo() {
  183. $ffmpeg_sudo = shell_exec("cat /etc/sudoers | grep -v grep | grep -c 'ffmpeg'");
  184. if ($ffmpeg_sudo == 0) {
  185. shell_exec("echo 'fosstreaming ALL = (root) NOPASSWD: /usr/local/bin/ffmpeg' >> /etc/sudoers");
  186. shell_exec("echo 'fosstreaming ALL = (root) NOPASSWD: /usr/local/bin/ffprobe' >> /etc/sudoers");
  187. shell_exec("echo '*/2 * * * * fosstreaming /usr/bin/php /home/fos-streaming/fos/www/cron.php' >> /etc/crontab");
  188. }
  189. }
  190.  
  191. function AddRCLocal() {
  192. shell_exec("sed --in-place '/exit 0/d' /etc/rc.local");
  193. $nginx_bin = shell_exec("cat /etc/rc.local | grep -v grep | grep -c 'nginx_fos'");
  194. if ($nginx_bin == 0) {
  195. shell_exec("echo '/home/fos-streaming/fos/nginx/sbin/nginx_fos' >> /etc/rc.local");
  196. }
  197. $phpfpm_bin = shell_exec("cat /etc/rc.local | grep -v grep | grep -c 'php-fpm'");
  198. if ($phpfpm_bin == 0) {
  199. shell_exec("echo '/home/fos-streaming/fos/php/sbin/php-fpm' >> /etc/rc.local");
  200. }
  201. shell_exec("echo 'sleep 10' >> /etc/rc.local");
  202. shell_exec("echo 'exit 0' >> /etc/rc.local");
  203. }
  204.  
  205. function BuildWeb() {
  206. if (!file_exists("/home/fos-streaming/fos/www/cache")) {
  207. shell_exec("mkdir /home/fos-streaming/fos/www/cache");
  208. }
  209. if (!file_exists("/home/fos-streaming/fos/www/streams")) {
  210. shell_exec("mkdir /home/fos-streaming/fos/www/streams");
  211. }
  212.  
  213.  
  214. $fstab_streams = shell_exec("cat /etc/fstab | grep -v grep | grep -c 'fos-streaming/fos/www/streams'");
  215. if ($fstab_streams == 0) {
  216. shell_exec("echo 'tmpfs /home/fos-streaming/fos/www/streams tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=85% 0 0' >> /etc/fstab");
  217. }
  218.  
  219. $fstab_cache = shell_exec("cat /etc/fstab | grep -v grep | grep -c 'fos-streaming/fos/www/cache'");
  220. if ($fstab_cache == 0) {
  221.  
  222. shell_exec("echo 'tmpfs /home/fos-streaming/fos/www/cache tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=500M 0 0' >> /etc/fstab");
  223. }
  224. shell_exec("chown -R fosstreaming:fosstreaming /home/fos-streaming");
  225. shell_exec("/home/fos-streaming/fos/php/sbin/php-fpm");
  226. shell_exec("/home/fos-streaming/fos/nginx/sbin/nginx_fos");
  227. }
  228.  
  229. function GetFOSResources($arch) {
  230. if (stristr($arch, '64')) {
  231. $fos = "fos-streaming_unpack_x84_64.tar.gz";
  232. } else {
  233. $fos = "fos-streaming_unpack_i686.tar.gz";
  234. }
  235. shell_exec("wget http://downloads.sourceforge.net/project/iptv-md/upload/{$fos} -O /home/fos-streaming/{$fos} > /dev/null");
  236. shell_exec("tar -xzf /home/fos-streaming/{$fos} -C /home/fos-streaming/ > /dev/null");
  237. }
  238.  
  239. function GetIP() {
  240. $ip_address = explode("\n", shell_exec("/sbin/ifconfig | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"));
  241.  
  242. foreach ($ip_address as $addr) {
  243. if (strncmp("127", $addr, 3) !== 0) {
  244. $result = $addr;
  245. break;
  246. }
  247. }
  248. return $result;
  249. }
  250.  
  251. echo "]PASS \n";
  252.  
  253.  
  254. echo "4. [FOS-Panel Installation:] ";
  255. echo " [#";
  256.  
  257. $srv_ip = GetIP();
  258. GetFOSResources($arch);
  259. echo "##";
  260. GetFos();
  261. echo "#";
  262. AddSudo();
  263. echo "#";
  264. AddRCLocal();
  265. echo "#";
  266. BuildWeb();
  267. echo "##";
  268. echo "#";
  269. shell_exec("chown fosstreaming:fosstreaming /home/fos-streaming/fos/nginx/html");
  270. echo "#";
  271. echo "]PASS \n";
  272. echo "******************************************************************************************** \n";
  273. echo "FOS-Streaming installed.. \n";
  274. echo "visit management page: 'http://{$srv_ip}:8000' \n";
  275. echo "Login: \n";
  276. echo "Username: admin \n";
  277. echo "Password: admin \n";
  278. echo "IMPORTANT: After you logged in, go to settings and check your ip-address. \n";
  279. echo "******************************************************************************************** \n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement