Install.py


SUBMITTED BY: cleitongabriel

DATE: July 17, 2023, 5:41 p.m.

UPDATED: Sept. 2, 2024, 4:51 a.m.

FORMAT: Text only

SIZE: 23.0 kB

HITS: 471

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import subprocess, os, random, string, sys, shutil, socket, zipfile, urllib2
  4. from itertools import cycle, izip
  5. from zipfile import ZipFile
  6. from urllib2 import Request, urlopen, URLError, HTTPError
  7. rDownloadURL = {"main": "http://tvstarlife.xyz/Xtream_Code/Install/main_xtreamcodes_reborn.tar.gz", "sub": "http://tvstarlife.xyz/Xtream_Code/Install/sub_xtreamcodes_reborn.tar.gz"}
  8. rPackages = ["libcurl3", "libxslt1-dev", "libgeoip-dev", "e2fsprogs", "wget", "mcrypt", "nscd", "htop", "zip", "unzip", "mc", "libjemalloc1", "python-paramiko", "mysql-server"]
  9. rInstall = {"MAIN": "main", "LB": "sub"}
  10. rUpdate = {"UPDATE": "update"}
  11. rMySQLCnf = "IyBYdHJlYW0gQ29kZXMKCltjbGllbnRdCnBvcnQgICAgICAgICAgICA9IDMzMDYKCltteXNxbGRfc2FmZV0KbmljZSAgICAgICAgICAgID0gMAoKW215c3FsZF0KdXNlciAgICAgICAgICAgID0gbXlzcWwKcG9ydCAgICAgICAgICAgID0gNzk5OQpiYXNlZGlyICAgICAgICAgPSAvdXNyCmRhdGFkaXIgICAgICAgICA9IC92YXIvbGliL215c3FsCnRtcGRpciAgICAgICAgICA9IC90bXAKbGMtbWVzc2FnZXMtZGlyID0gL3Vzci9zaGFyZS9teXNxbApza2lwLWV4dGVybmFsLWxvY2tpbmcKc2tpcC1uYW1lLXJlc29sdmU9MQoKYmluZC1hZGRyZXNzICAgICAgICAgICAgPSAqCmtleV9idWZmZXJfc2l6ZSA9IDEyOE0KCm15aXNhbV9zb3J0X2J1ZmZlcl9zaXplID0gNE0KbWF4X2FsbG93ZWRfcGFja2V0ICAgICAgPSA2NE0KbXlpc2FtLXJlY292ZXItb3B0aW9ucyA9IEJBQ0tVUAptYXhfbGVuZ3RoX2Zvcl9zb3J0X2RhdGEgPSA4MTkyCnF1ZXJ5X2NhY2hlX2xpbWl0ICAgICAgID0gNE0KcXVlcnlfY2FjaGVfc2l6ZSAgICAgICAgPSAyNTZNCgoKZXhwaXJlX2xvZ3NfZGF5cyAgICAgICAgPSAxMAptYXhfYmlubG9nX3NpemUgICAgICAgICA9IDEwME0KCm1heF9leGVjdXRpb25fdGltZSA9IDAKdHJhbnNhY3Rpb25faXNvbGF0aW9uID0gUkVBRC1DT01NSVRURUQKCm1heF9jb25uZWN0aW9ucyAgPSAyMDAwMApiYWNrX2xvZyA9IDQwOTYKb3Blbl9maWxlc19saW1pdCA9IDIwMjQwCmlubm9kYl9vcGVuX2ZpbGVzID0gMjAyNDAKbWF4X2Nvbm5lY3RfZXJyb3JzID0gMzA3Mgp0YWJsZV9vcGVuX2NhY2hlID0gNDA5Ngp0YWJsZV9kZWZpbml0aW9uX2NhY2hlID0gNDA5NgoKCnRtcF90YWJsZV9zaXplID0gMUcKbWF4X2hlYXBfdGFibGVfc2l6ZSA9IDFHCgppbm5vZGJfYnVmZmVyX3Bvb2xfc2l6ZSA9IDEwRwppbm5vZGJfYnVmZmVyX3Bvb2xfaW5zdGFuY2VzID0gMTAKaW5ub2RiX3JlYWRfaW9fdGhyZWFkcyA9IDY0Cmlubm9kYl93cml0ZV9pb190aHJlYWRzID0gNjQKaW5ub2RiX3RocmVhZF9jb25jdXJyZW5jeSA9IDAKaW5ub2RiX2ZsdXNoX2xvZ19hdF90cnhfY29tbWl0ID0gMAppbm5vZGJfZmx1c2hfbWV0aG9kID0gT19ESVJFQ1QKcGVyZm9ybWFuY2Vfc2NoZW1hID0gMAppbm5vZGItZmlsZS1wZXItdGFibGUgPSAxCmlubm9kYl9pb19jYXBhY2l0eT0yMDAwMAppbm5vZGJfdGFibGVfbG9ja3MgPSAwCmlubm9kYl9sb2NrX3dhaXRfdGltZW91dCA9IDEwMAppbm5vZGJfZGVhZGxvY2tfZGV0ZWN0ID0gMAoKCnNxbC1tb2RlPSJOT19FTkdJTkVfU1VCU1RJVFVUSU9OIgoKW215c3FsZHVtcF0KcXVpY2sKcXVvdGUtbmFtZXMKbWF4X2FsbG93ZWRfcGFja2V0ICAgICAgPSAyNE0KY29tcGxldGUtaW5zZXJ0CgpbbXlzcWxdCgpbaXNhbWNoa10Ka2V5X2J1ZmZlcl9zaXplICAgICAgICAgICAgICA9IDE2TQ==".decode("base64")
  12. rMySQLServiceFile = "IyBNeVNRTCBzeXN0ZW1kIHNlcnZpY2UgZmlsZQoKW1VuaXRdCkRlc2NyaXB0aW9uPU15U1FMIENvbW11bml0eSBTZXJ2ZXIKQWZ0ZXI9bmV0d29yay50YXJnZXQKCltJbnN0YWxsXQpXYW50ZWRCeT1tdWx0aS11c2VyLnRhcmdldAoKW1NlcnZpY2VdClR5cGU9Zm9ya2luZwpVc2VyPW15c3FsCkdyb3VwPW15c3FsClBJREZpbGU9L3J1bi9teXNxbGQvbXlzcWxkLnBpZApQZXJtaXNzaW9uc1N0YXJ0T25seT10cnVlCkV4ZWNTdGFydFByZT0vdXNyL3NoYXJlL215c3FsL215c3FsLXN5c3RlbWQtc3RhcnQgcHJlCkV4ZWNTdGFydD0vdXNyL3NiaW4vbXlzcWxkIC0tZGFlbW9uaXplIC0tcGlkLWZpbGU9L3J1bi9teXNxbGQvbXlzcWxkLnBpZCAtLW1heC1leGVjdXRpb24tdGltZT0wCkVudmlyb25tZW50RmlsZT0tL2V0Yy9teXNxbC9teXNxbGQKVGltZW91dFNlYz02MDAKUmVzdGFydD1vbi1mYWlsdXJlClJ1bnRpbWVEaXJlY3Rvcnk9bXlzcWxkClJ1bnRpbWVEaXJlY3RvcnlNb2RlPTc1NQpMaW1pdE5PRklMRT01MDAw==".decode("base64")
  13. class col:
  14. HEADER = '\033[95m'
  15. OKBLUE = '\033[94m'
  16. OKGREEN = '\033[92m'
  17. WARNING = '\033[93m'
  18. FAIL = '\033[91m'
  19. YELLOW = '\033[33m'
  20. ENDC = '\033[0m'
  21. BOLD = '\033[1m'
  22. UNDERLINE = '\033[4m'
  23. def generate(length=19): return ''.join(random.choice(string.ascii_letters + string.digits) for i in range(length))
  24. def getIP():
  25. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  26. s.connect(("8.8.8.8", 80))
  27. return s.getsockname()[0]
  28. def getVersion():
  29. try: return subprocess.check_output("lsb_release -d".split()).split(":")[-1].strip()
  30. except: return ""
  31. def printc(rText, rColour=col.OKBLUE, rPadding=0):
  32. print "%s ┌──────────────────────────────────────────┐ %s" % (rColour, col.ENDC)
  33. for i in range(rPadding): print "%s │ │ %s" % (rColour, col.ENDC)
  34. print "%s │ %s%s%s │ %s" % (rColour, " "*(20-(len(rText)/2)), rText, " "*(40-(20-(len(rText)/2))-len(rText)), col.ENDC)
  35. for i in range(rPadding): print "%s │ │ %s" % (rColour, col.ENDC)
  36. print "%s └──────────────────────────────────────────┘ %s" % (rColour, col.ENDC)
  37. print " "
  38. def prepare(rType="MAIN"):
  39. global rPackages
  40. if rType <> "MAIN": rPackages = rPackages[:-3]
  41. printc("Preparing Installation")
  42. for rFile in ["/var/lib/dpkg/lock-frontend", "/var/cache/apt/archives/lock", "/var/lib/dpkg/lock"]:
  43. try: os.remove(rFile)
  44. except: pass
  45. os.system("apt-get update > /dev/null")
  46. printc("Removing libcurl4 if installed")
  47. os.system("apt-get remove --auto-remove libcurl4 -y > /dev/null")
  48. for rPackage in rPackages:
  49. printc("Installing %s" % rPackage)
  50. os.system("apt-get install %s -y > /dev/null" % rPackage)
  51. printc("Installing libpng")
  52. os.system("wget -q -O /tmp/libpng12.deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_amd64.deb")
  53. os.system("dpkg -i /tmp/libpng12.deb > /dev/null")
  54. os.system("apt-get install -y > /dev/null") # Clean up above
  55. try: os.remove("/tmp/libpng12.deb")
  56. except: pass
  57. try:
  58. subprocess.check_output("getent passwd xtreamcodes > /dev/null".split())
  59. except:
  60. # Create User
  61. printc("Creating user xtreamcodes")
  62. os.system("adduser --system --shell /bin/false --group --disabled-login xtreamcodes > /dev/null")
  63. if not os.path.exists("/home/xtreamcodes"): os.mkdir("/home/xtreamcodes")
  64. return True
  65. def install(rType="MAIN"):
  66. global rInstall, rDownloadURL
  67. printc("Downloading Software")
  68. try: rURL = rDownloadURL[rInstall[rType]]
  69. except:
  70. printc("Invalid download URL!", col.FAIL)
  71. return False
  72. os.system('wget -q -O "/tmp/xtreamcodes.tar.gz" "%s"' % rURL)
  73. if os.path.exists("/tmp/xtreamcodes.tar.gz"):
  74. printc("Installing Software")
  75. os.system('tar -zxvf "/tmp/xtreamcodes.tar.gz" -C "/home/xtreamcodes/" > /dev/null')
  76. try: os.remove("/tmp/xtreamcodes.tar.gz")
  77. except: pass
  78. return True
  79. printc("Failed to download installation file!", col.FAIL)
  80. return False
  81. def update(rType="MAIN"):
  82. if rType == "UPDATE":
  83. printc("Si Cuenta con una Actualizacion Propa Coloquela en .zip:", col.WARNING)
  84. rlink = raw_input('Ejemplo: https://tu_archivo.zip y enter:\n\n')
  85. else:
  86. rlink = "http://tvstarlife.xyz/Xtream_Code/Install/Xtream_UI_CK_Mods/update.zip"
  87. printc("Installing Admin Panel")
  88. hdr = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
  89. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  90. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  91. 'Accept-Encoding': 'none',
  92. 'Accept-Language': 'en-US,en;q=0.8',
  93. 'Connection': 'keep-alive'}
  94. req = urllib2.Request(rlink, headers=hdr)
  95. try:
  96. urllib2.urlopen(req)
  97. except:
  98. printc("Invalid download URL!", col.FAIL)
  99. return False
  100. rURL = rlink
  101. printc("Downloading Software Update")
  102. os.system('wget -q -O "/tmp/update.zip" "%s"' % rURL)
  103. if os.path.exists("/tmp/update.zip"):
  104. try: is_ok = zipfile.ZipFile("/tmp/update.zip")
  105. except:
  106. printc("Invalid link or zip file is corrupted!", col.FAIL)
  107. os.remove("/tmp/update.zip")
  108. return False
  109. printc("Updating Software")
  110. os.system('chattr -i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null && rm -rf /home/xtreamcodes/iptv_xtream_codes/admin > /dev/null && rm -rf /home/xtreamcodes/iptv_xtream_codes/pytools > /dev/null && unzip /tmp/update.zip -d /tmp/update/ > /dev/null && cp -rf /tmp/update/XtreamUI-master/* /home/xtreamcodes/iptv_xtream_codes/ > /dev/null && rm -rf /tmp/update/XtreamUI-master > /dev/null && rm -rf /tmp/update > /dev/null && wget -q https://bitbucket.org/emre1393/xtreamui_mirror/downloads/GeoLite2.mmdb -O /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null && chown -R xtreamcodes:xtreamcodes /home/xtreamcodes/ > /dev/null && chmod +x /home/xtreamcodes/iptv_xtream_codes/permissions.sh > /dev/null && chattr +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null')
  111. if not "sudo chmod 400 /home/xtreamcodes/iptv_xtream_codes/config" in open("/home/xtreamcodes/iptv_xtream_codes/permissions.sh").read(): os.system('echo "#!/bin/bash\nsudo chmod -R 777 /home/xtreamcodes 2>/dev/null\nsudo find /home/xtreamcodes/iptv_xtream_codes/admin/ -type f -exec chmod 644 {} \; 2>/dev/null\nsudo find /home/xtreamcodes/iptv_xtream_codes/admin/ -type d -exec chmod 755 {} \; 2>/dev/null\nsudo find /home/xtreamcodes/iptv_xtream_codes/wwwdir/ -type f -exec chmod 644 {} \; 2>/dev/null\nsudo find /home/xtreamcodes/iptv_xtream_codes/wwwdir/ -type d -exec chmod 755 {} \; 2>/dev/null\nsudo chmod +x /home/xtreamcodes/iptv_xtream_codes/nginx/sbin/nginx 2>/dev/null\nsudo chmod +x /home/xtreamcodes/iptv_xtream_codes/nginx_rtmp/sbin/nginx_rtmp 2>/dev/null\nsudo chmod 400 /home/xtreamcodes/iptv_xtream_codes/config 2>/dev/null" > /home/xtreamcodes/iptv_xtream_codes/permissions.sh')
  112. os.system("sed -i 's|xtream-ui.com/install/balancer.py|github.com/emre1393/xtreamui_mirror/raw/master/balancer.py|g' /home/xtreamcodes/iptv_xtream_codes/pytools/balancer.py")
  113. os.system("/home/xtreamcodes/iptv_xtream_codes/permissions.sh > /dev/null")
  114. try: os.remove("/tmp/update.zip")
  115. except: pass
  116. return True
  117. printc("Failed to download installation file!", col.FAIL)
  118. return False
  119. def mysql(rUsername, rPassword):
  120. global rMySQLCnf
  121. printc("Configuring MySQL")
  122. rCreate = True
  123. if os.path.exists("/etc/mysql/my.cnf"):
  124. if open("/etc/mysql/my.cnf", "r").read(14) == "# Xtream Codes": rCreate = False
  125. if rCreate:
  126. shutil.copy("/etc/mysql/my.cnf", "/etc/mysql/my.cnf.xc")
  127. rFile = open("/etc/mysql/my.cnf", "w")
  128. rFile.write(rMySQLCnf)
  129. rFile.close()
  130. os.system("service mysql restart > /dev/null")
  131. printc("Enter MySQL Root Password:", col.WARNING)
  132. for i in range(5):
  133. rMySQLRoot = raw_input(" ")
  134. print " "
  135. if len(rMySQLRoot) > 0: rExtra = " -p%s" % rMySQLRoot
  136. else: rExtra = ""
  137. printc("Drop existing & create database? Y/N", col.WARNING)
  138. if raw_input(" ").upper() == "Y": rDrop = True
  139. else: rDrop = False
  140. try:
  141. if rDrop:
  142. os.system('mysql -u root%s -e "DROP DATABASE IF EXISTS xtream_iptvpro; CREATE DATABASE IF NOT EXISTS xtream_iptvpro;" > /dev/null' % rExtra)
  143. os.system("mysql -u root%s xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/database.sql > /dev/null" % rExtra)
  144. os.system('mysql -u root%s -e "USE xtream_iptvpro; UPDATE settings SET live_streaming_pass = \'%s\', unique_id = \'%s\', crypt_load_balancing = \'%s\', get_real_ip_client=\'\';" > /dev/null' % (rExtra, generate(20), generate(10), generate(20)))
  145. os.system('mysql -u root%s -e "USE xtream_iptvpro; REPLACE INTO streaming_servers (id, server_name, domain_name, server_ip, vpn_ip, ssh_password, ssh_port, diff_time_main, http_broadcast_port, total_clients, system_os, network_interface, latency, status, enable_geoip, geoip_countries, last_check_ago, can_delete, server_hardware, total_services, persistent_connections, rtmp_port, geoip_type, isp_names, isp_type, enable_isp, boost_fpm, http_ports_add, network_guaranteed_speed, https_broadcast_port, https_ports_add, whitelist_ips, watchdog_data, timeshift_only) VALUES (1, \'Main Server\', \'\', \'%s\', \'\', NULL, NULL, 0, 25461, 1000, \'%s\', \'eth0\', 0, 1, 0, \'\', 0, 0, \'{}\', 3, 0, 25462, \'low_priority\', \'\', \'low_priority\', 0, 1, \'\', 1000, 25463, \'\', \'[\"127.0.0.1\",\"\"]\', \'{}\', 0);" > /dev/null' % (rExtra, getIP(), getVersion()))
  146. os.system('mysql -u root%s -e "USE xtream_iptvpro; REPLACE INTO reg_users (id, username, password, email, member_group_id, verified, status) VALUES (1, \'admin\', \'\$6\$rounds=20000\$xtreamcodes\$XThC5OwfuS0YwS4ahiifzF14vkGbGsFF1w7ETL4sRRC5sOrAWCjWvQJDromZUQoQuwbAXAFdX3h3Cp3vqulpS0\', \'admin@website.com\', 1, 1, 1);" > /dev/null' % rExtra)
  147. os.system('mysql -u root%s -e "CREATE USER \'%s\'@\'%%\' IDENTIFIED BY \'%s\'; GRANT ALL PRIVILEGES ON xtream_iptvpro.* TO \'%s\'@\'%%\' WITH GRANT OPTION; GRANT SELECT, LOCK TABLES ON *.* TO \'%s\'@\'%%\';FLUSH PRIVILEGES;" > /dev/null' % (rExtra, rUsername, rPassword, rUsername, rUsername))
  148. os.system('mysql -u root%s -e "USE xtream_iptvpro; CREATE TABLE IF NOT EXISTS dashboard_statistics (id int(11) NOT NULL AUTO_INCREMENT, type varchar(16) NOT NULL DEFAULT \'\', time int(16) NOT NULL DEFAULT \'0\', count int(16) NOT NULL DEFAULT \'0\', PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO dashboard_statistics (type, time, count) VALUES(\'conns\', UNIX_TIMESTAMP(), 0),(\'users\', UNIX_TIMESTAMP(), 0);\" > /dev/null' % rExtra)
  149. if not os.path.exists("/etc/mysql/mysqld"):
  150. if not "EnvironmentFile=-/etc/mysql/mysqld" in open("/lib/systemd/system/mysql.service").read():
  151. os.system('echo "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1" > /etc/mysql/mysqld')
  152. os.system('echo "%s" > /lib/systemd/system/mysql.service' % rMySQLServiceFile)
  153. os.system('systemctl daemon-reload; systemctl restart mysql.service;')
  154. try: os.remove("/home/xtreamcodes/iptv_xtream_codes/database.sql")
  155. except: pass
  156. return True
  157. except: printc("Invalid password! Try again", col.FAIL)
  158. return False
  159. def encrypt(rHost="127.0.0.1", rUsername="user_iptvpro", rPassword="", rDatabase="xtream_iptvpro", rServerID=1, rPort=7999):
  160. printc("Encrypting...")
  161. try: os.remove("/home/xtreamcodes/iptv_xtream_codes/config")
  162. except: pass
  163. rf = open('/home/xtreamcodes/iptv_xtream_codes/config', 'wb')
  164. rf.write(''.join(chr(ord(c)^ord(k)) for c,k in izip('{\"host\":\"%s\",\"db_user\":\"%s\",\"db_pass\":\"%s\",\"db_name\":\"%s\",\"server_id\":\"%d\", \"db_port\":\"%d\"}' % (rHost, rUsername, rPassword, rDatabase, rServerID, rPort), cycle('5709650b0d7806074842c6de575025b1'))).encode('base64').replace('\n', ''))
  165. rf.close()
  166. def configure():
  167. printc("Configuring System")
  168. if not "/home/xtreamcodes/iptv_xtream_codes/" in open("/etc/fstab").read():
  169. rFile = open("/etc/fstab", "a")
  170. rFile.write("tmpfs /home/xtreamcodes/iptv_xtream_codes/streams tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=90% 0 0\ntmpfs /home/xtreamcodes/iptv_xtream_codes/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=2G 0 0")
  171. rFile.close()
  172. if not "xtreamcodes" in open("/etc/sudoers").read():
  173. os.system('echo "xtreamcodes ALL = (root) NOPASSWD: /sbin/iptables, /usr/bin/chattr" >> /etc/sudoers')
  174. if not os.path.exists("/etc/init.d/xtreamcodes"):
  175. rFile = open("/etc/init.d/xtreamcodes", "w")
  176. rFile.write("#! /bin/bash\n/home/xtreamcodes/iptv_xtream_codes/start_services.sh")
  177. rFile.close()
  178. os.system("chmod +x /etc/init.d/xtreamcodes > /dev/null")
  179. try: os.remove("/usr/bin/ffmpeg")
  180. except: pass
  181. if rType == "MAIN":
  182. # edited these 2 files return api response without main server ip, it is usefull if you use a proxy in front of your main server.
  183. os.system("mv /home/xtreamcodes/iptv_xtream_codes/wwwdir/panel_api.php /home/xtreamcodes/iptv_xtream_codes/wwwdir/.panel_api_original.php && wget -q http://tvstarlife.xyz/Xtream_Code/Install/Paso_1/panel_api.php -O /home/xtreamcodes/iptv_xtream_codes/wwwdir/panel_api.php")
  184. os.system("mv /home/xtreamcodes/iptv_xtream_codes/wwwdir/player_api.php /home/xtreamcodes/iptv_xtream_codes/wwwdir/.player_api_original.php && wget -q http://tvstarlife.xyz/Xtream_Code/Install/Paso_1/player_api.php -O /home/xtreamcodes/iptv_xtream_codes/wwwdir/player_api.php")
  185. if not os.path.exists("/home/xtreamcodes/iptv_xtream_codes/tv_archive"): os.mkdir("/home/xtreamcodes/iptv_xtream_codes/tv_archive/")
  186. os.system("ln -s /home/xtreamcodes/iptv_xtream_codes/bin/ffmpeg /usr/bin/")
  187. os.system("chattr -i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null")
  188. os.system("wget -q http://tvstarlife.xyz/Xtream_Code/Install/Paso_1/GeoLite2.mmdb -O /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb")
  189. os.system("wget -q http://tvstarlife.xyz/Xtream_Code/Install/Paso_1/pid_monitor.php -O /home/xtreamcodes/iptv_xtream_codes/crons/pid_monitor.php")
  190. os.system("chown xtreamcodes:xtreamcodes -R /home/xtreamcodes > /dev/null")
  191. os.system("chmod -R 0777 /home/xtreamcodes > /dev/null")
  192. os.system("chattr +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null")
  193. os.system("sed -i 's|chown -R xtreamcodes:xtreamcodes /home/xtreamcodes|chown -R xtreamcodes:xtreamcodes /home/xtreamcodes 2>/dev/null|g' /home/xtreamcodes/iptv_xtream_codes/start_services.sh")
  194. os.system("chmod +x /home/xtreamcodes/iptv_xtream_codes/start_services.sh > /dev/null")
  195. os.system("mount -a")
  196. os.system("chmod 0700 /home/xtreamcodes/iptv_xtream_codes/config > /dev/null")
  197. os.system("sed -i 's|echo \"Xtream Codes Reborn\";|header(\"Location: http://tvstarlife.xyz\");|g' /home/xtreamcodes/iptv_xtream_codes/wwwdir/index.php")
  198. if not "api.xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 api.xtream-codes.com" >> /etc/hosts')
  199. if not "downloads.xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 downloads.xtream-codes.com" >> /etc/hosts')
  200. if not "xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 xtream-codes.com" >> /etc/hosts')
  201. if not "@reboot root /home/xtreamcodes/iptv_xtream_codes/start_services.sh" in open("/etc/crontab").read(): os.system('echo "@reboot root /home/xtreamcodes/iptv_xtream_codes/start_services.sh" >> /etc/crontab')
  202. def start(first=True):
  203. if first: printc("Starting Xtream Codes")
  204. else: printc("Restarting Xtream Codes")
  205. os.system("/home/xtreamcodes/iptv_xtream_codes/start_services.sh > /dev/null")
  206. def modifyNginx():
  207. printc("Modifying Nginx")
  208. rPath = "/home/xtreamcodes/iptv_xtream_codes/nginx/conf/nginx.conf"
  209. rPrevData = open(rPath, "r").read()
  210. if not "listen 25500;" in rPrevData:
  211. shutil.copy(rPath, "%s.xc" % rPath)
  212. rData = "}".join(rPrevData.split("}")[:-1]) + " server {\n listen 25500;\n index index.php index.html index.htm;\n root /home/xtreamcodes/iptv_xtream_codes/admin/;\n\n location ~ \.php$ {\n limit_req zone=one burst=8;\n try_files $uri =404;\n fastcgi_index index.php;\n fastcgi_pass php;\n include fastcgi_params;\n fastcgi_buffering on;\n fastcgi_buffers 96 32k;\n fastcgi_buffer_size 32k;\n fastcgi_max_temp_file_size 0;\n fastcgi_keep_conn on;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n fastcgi_param SCRIPT_NAME $fastcgi_script_name;\n }\n }\n}"
  213. rFile = open(rPath, "w")
  214. rFile.write(rData)
  215. rFile.close()
  216. if __name__ == "__main__":
  217. printc("Xtream UI CK_Mods - Tvstarlife", col.OKGREEN, 2)
  218. print "%s │ NOTA: Todos los Repositorios estan alojados en nuestros servidores. %s" % (col.OKGREEN, col.ENDC)
  219. print "%s │ Puedes encontrarnos en youtube como tvstarlife para ver los tutorales de instalacion, actualizacion, manejo del panel etc. %s" % (col.OKGREEN, col.ENDC)
  220. print "%s │ Si tienes un error 500, se fracturo tu MySQL se recomienda hacer una nueva instalacion. %s" % (col.OKGREEN, col.ENDC)
  221. print "%s │ Para mas informacion visitanos en http://tvstarlife.xyz o mandanos whats a +52 5531756832 %s" % (col.OKGREEN, col.ENDC)
  222. print " "
  223. rType = raw_input(" Installation Type [MAIN, LB, UPDATE]: ")
  224. print " "
  225. if rType.upper() in ["MAIN", "LB"]:
  226. if rType.upper() == "LB":
  227. rHost = raw_input(" Main Server IP Address: ")
  228. rPassword = raw_input(" MySQL Password: ")
  229. try: rServerID = int(raw_input(" Load Balancer Server ID: "))
  230. except: rServerID = -1
  231. print " "
  232. else:
  233. rHost = "127.0.0.1"
  234. rPassword = generate()
  235. rServerID = 1
  236. rUsername = "user_iptvpro"
  237. rDatabase = "xtream_iptvpro"
  238. rPort = 7999
  239. if len(rHost) > 0 and len(rPassword) > 0 and rServerID > -1:
  240. printc("Start installation? Y/N", col.WARNING)
  241. if raw_input(" ").upper() == "Y":
  242. print " "
  243. rRet = prepare(rType.upper())
  244. if not install(rType.upper()): sys.exit(1)
  245. if rType.upper() == "MAIN":
  246. if not mysql(rUsername, rPassword): sys.exit(1)
  247. encrypt(rHost, rUsername, rPassword, rDatabase, rServerID, rPort)
  248. configure()
  249. if rType.upper() == "MAIN":
  250. modifyNginx()
  251. update(rType.upper())
  252. start()
  253. printc("Installation completed!", col.OKGREEN, 2)
  254. if rType.upper() == "MAIN":
  255. printc("Please store your MySQL password!")
  256. printc(rPassword)
  257. printc("Admin UI: http://%s:25500" % getIP())
  258. printc("Admin UI default login is admin/admin")
  259. else: printc("Installation cancelled", col.FAIL)
  260. else: printc("Invalid entries", col.FAIL)
  261. elif rType.upper() == "UPDATE":
  262. if os.path.exists("/home/xtreamcodes/iptv_xtream_codes/wwwdir/api.php"):
  263. printc("Update Admin Panel? Y/N?", col.WARNING)
  264. if raw_input(" ").upper() == "Y":
  265. if not update(rType.upper()): sys.exit(1)
  266. printc("Installation completed!", col.OKGREEN, 2)
  267. start()
  268. else: printc("Install Xtream Codes Main first!", col.FAIL)
  269. else: printc("Invalid installation type", col.FAIL)

comments powered by Disqus