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: 22.1 kB

HITS: 473

  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. rDownloadURL = {"main": "https://bitbucket.org/emre1393/xtreamui_mirror/downloads/main_xtreamcodes_reborn.tar.gz", "sub": "https://bitbucket.org/emre1393/xtreamui_mirror/downloads/sub_xtreamcodes_reborn.tar.gz"}
  7. rPackages = ["libcurl3", "libxslt1-dev", "libgeoip-dev", "e2fsprogs", "wget", "mcrypt", "nscd", "htop", "zip", "unzip", "mc", "libjemalloc1", "python-paramiko", "mysql-server"]
  8. rInstall = {"MAIN": "main", "LB": "sub"}
  9. rMySQLCnf = "IyBYdHJlYW0gQ29kZXMKCltjbGllbnRdCnBvcnQgICAgICAgICAgICA9IDMzMDYKCltteXNxbGRfc2FmZV0KbmljZSAgICAgICAgICAgID0gMAoKW215c3FsZF0KZGVmYXVsdC1hdXRoZW50aWNhdGlvbi1wbHVnaW49bXlzcWxfbmF0aXZlX3Bhc3N3b3JkCnVzZXIgICAgICAgICAgICA9IG15c3FsCnBvcnQgICAgICAgICAgICA9IDc5OTkKYmFzZWRpciAgICAgICAgID0gL3VzcgpkYXRhZGlyICAgICAgICAgPSAvdmFyL2xpYi9teXNxbAp0bXBkaXIgICAgICAgICAgPSAvdG1wCgpsYy1tZXNzYWdlcy1kaXIgPSAvdXNyL3NoYXJlL215c3FsCnNraXAtZXh0ZXJuYWwtbG9ja2luZwpza2lwLW5hbWUtcmVzb2x2ZT0xCgpiaW5kLWFkZHJlc3MgICAgICAgICAgICA9ICoKCmtleV9idWZmZXJfc2l6ZSA9IDEyOE0KbXlpc2FtX3NvcnRfYnVmZmVyX3NpemUgPSA0TQptYXhfYWxsb3dlZF9wYWNrZXQgICAg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lazy to prepare echo versions with escaped characters, use base64 decode/encode to read or change these.
  12. rVersions = {
  13. "16.04": "xenial",
  14. "18.04": "bionic"
  15. }
  16. class col:
  17. HEADER = '\033[95m'
  18. OKBLUE = '\033[94m'
  19. OKGREEN = '\033[92m'
  20. WARNING = '\033[93m'
  21. FAIL = '\033[91m'
  22. YELLOW = '\033[33m'
  23. ENDC = '\033[0m'
  24. BOLD = '\033[1m'
  25. UNDERLINE = '\033[4m'
  26. def generate(length=32): return ''.join(random.choice(string.ascii_letters + string.digits) for i in range(length))
  27. def getIP():
  28. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  29. s.connect(("8.8.8.8", 80))
  30. return s.getsockname()[0]
  31. def getVersion():
  32. try: return subprocess.check_output("lsb_release -d".split()).split(":")[-1].strip()
  33. except: return ""
  34. def printc(rText, rColour=col.OKBLUE, rPadding=0):
  35. print "%s ┌──────────────────────────────────────────┐ %s" % (rColour, col.ENDC)
  36. for i in range(rPadding): print "%s │ │ %s" % (rColour, col.ENDC)
  37. print "%s │ %s%s%s │ %s" % (rColour, " "*(20-(len(rText)/2)), rText, " "*(40-(20-(len(rText)/2))-len(rText)), col.ENDC)
  38. for i in range(rPadding): print "%s │ │ %s" % (rColour, col.ENDC)
  39. print "%s └──────────────────────────────────────────┘ %s" % (rColour, col.ENDC)
  40. print " "
  41. def prepare(rType="MAIN"):
  42. global rPackages
  43. if rType <> "MAIN": rPackages = rPackages[:-3]
  44. printc("Preparing Installation")
  45. for rFile in ["/var/lib/dpkg/lock-frontend", "/var/cache/apt/archives/lock", "/var/lib/dpkg/lock"]:
  46. try: os.remove(rFile)
  47. except: pass
  48. os.system("apt-get update > /dev/null")
  49. printc("Removing libcurl4 if installed")
  50. os.system("apt-get remove --auto-remove libcurl4 -y > /dev/null")
  51. for rPackage in rPackages:
  52. printc("Installing %s" % rPackage)
  53. os.system("apt-get install %s -y > /dev/null" % rPackage)
  54. printc("Installing libpng")
  55. 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")
  56. os.system("dpkg -i /tmp/libpng12.deb > /dev/null")
  57. os.system("apt-get install -y > /dev/null") # Clean up above
  58. try: os.remove("/tmp/libpng12.deb")
  59. except: pass
  60. try:
  61. subprocess.check_output("getent passwd xtreamcodes > /dev/null".split())
  62. except:
  63. # Create User
  64. printc("Creating user xtreamcodes")
  65. os.system("adduser --system --shell /bin/false --group --disabled-login xtreamcodes > /dev/null")
  66. if not os.path.exists("/home/xtreamcodes"): os.mkdir("/home/xtreamcodes")
  67. return True
  68. def install(rType="MAIN"):
  69. global rInstall, rDownloadURL
  70. printc("Downloading Software")
  71. try: rURL = rDownloadURL[rInstall[rType]]
  72. except:
  73. printc("Invalid download URL!", col.FAIL)
  74. return False
  75. os.system('wget -q -O "/tmp/xtreamcodes.tar.gz" "%s"' % rURL)
  76. if os.path.exists("/tmp/xtreamcodes.tar.gz"):
  77. printc("Installing Software")
  78. if os.path.exists("/home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb"):
  79. os.system('chattr -f -i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null')
  80. os.system('tar -zxvf "/tmp/xtreamcodes.tar.gz" -C "/home/xtreamcodes/" > /dev/null')
  81. try: os.remove("/tmp/xtreamcodes.tar.gz")
  82. except: pass
  83. return True
  84. printc("Failed to download installation file!", col.FAIL)
  85. return False
  86. def installadminpanel():
  87. rURL = "https://bitbucket.org/emre1393/xtreamui_mirror/downloads/release_22f.zip"
  88. printc("Downloading Admin Panel")
  89. os.system('wget -q -O "/tmp/update.zip" "%s"' % rURL)
  90. if os.path.exists("/tmp/update.zip"):
  91. try: is_ok = zipfile.ZipFile("/tmp/update.zip")
  92. except:
  93. printc("Invalid link or zip file is corrupted!", col.FAIL)
  94. os.remove("/tmp/update.zip")
  95. return False
  96. printc("Installing Admin Panel")
  97. os.system('unzip -o /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 && chown -R xtreamcodes:xtreamcodes /home/xtreamcodes > /dev/null')
  98. try: os.remove("/tmp/update.zip")
  99. except: pass
  100. rURL2 = "https://bitbucket.org/emre1393/xtreamui_mirror/downloads/newstuff.zip"
  101. printc("Downloading New Stuff for Admin Panel")
  102. os.system('wget -q -O "/tmp/update2.zip" "%s"' % rURL2)
  103. if os.path.exists("/tmp/update2.zip"):
  104. try: is_ok = zipfile.ZipFile("/tmp/update2.zip")
  105. except:
  106. printc("Invalid link or zip file is corrupted!", col.FAIL)
  107. os.remove("/tmp/update2.zip")
  108. return False
  109. printc("Installing New Stuff for Admin Panel")
  110. os.system('unzip -o /tmp/update2.zip -d /tmp/update2/ > /dev/null && cp -rf /tmp/update2/* /home/xtreamcodes/iptv_xtream_codes/ > /dev/null && rm -rf /tmp/update2/* > /dev/null && rm -rf /tmp/update2 > /dev/null && chown -R xtreamcodes:xtreamcodes /home/xtreamcodes/ > /dev/null > /dev/null')
  111. return True
  112. printc("Failed to download installation file!", col.FAIL)
  113. return False
  114. def mysql(rUsername, rPassword):
  115. global rMySQLCnf
  116. printc("Configuring MySQL")
  117. rCreate = True
  118. if os.path.exists("/etc/mysql/my.cnf"):
  119. if open("/etc/mysql/my.cnf", "r").read(14) == "# Xtream Codes": rCreate = False
  120. if rCreate:
  121. shutil.copy("/etc/mysql/my.cnf", "/etc/mysql/my.cnf.xc")
  122. rFile = open("/etc/mysql/my.cnf", "w")
  123. rFile.write(rMySQLCnf)
  124. rFile.close()
  125. os.system("service mysql restart > /dev/null")
  126. printc("Enter MySQL Root Password:", col.WARNING)
  127. for i in range(5):
  128. rMySQLRoot = raw_input(" ")
  129. print " "
  130. if len(rMySQLRoot) > 0: rExtra = " -p%s" % rMySQLRoot
  131. else: rExtra = ""
  132. printc("Drop existing & create database? Y/N", col.WARNING)
  133. if raw_input(" ").upper() == "Y": rDrop = True
  134. else: rDrop = False
  135. try:
  136. if rDrop:
  137. os.system('mysql -u root%s -e "DROP USER IF EXISTS \'%s\'@\'%%\'; DROP USER IF EXISTS \'%s\'@\'localhost\'; DROP USER IF EXISTS \'%s\'@\'127.0.0.1\';" > /dev/null' % (rExtra, rUsername, rUsername, rUsername))
  138. os.system('mysql -u root%s -e "DROP DATABASE IF EXISTS xtream_iptvpro; CREATE DATABASE IF NOT EXISTS xtream_iptvpro;" > /dev/null' % rExtra)
  139. os.system("mysql -u root%s xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/database.sql > /dev/null" % rExtra)
  140. 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(12), generate(20)))
  141. 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, 8080, 1000, \'%s\', \'eth0\', 0, 1, 0, \'\', 0, 0, \'{}\', 3, 0, 8880, \'low_priority\', \'\', \'low_priority\', 0, 1, \'\', 1000, 8443, \'\', \'[\"127.0.0.1\",\"\"]\', \'{}\', 0);" > /dev/null' % (rExtra, getIP(), getVersion()))
  142. 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)
  143. os.system('mysql -u root%s -e "CREATE USER \'%s\'@\'localhost\' IDENTIFIED BY \'%s\'; GRANT ALL PRIVILEGES ON xtream_iptvpro.* TO \'%s\'@\'localhost\' WITH GRANT OPTION; GRANT SELECT, PROCESS, LOCK TABLES ON *.* TO \'%s\'@\'localhost\';FLUSH PRIVILEGES;" > /dev/null' % (rExtra, rUsername, rPassword, rUsername, rUsername))
  144. os.system('mysql -u root%s -e "CREATE USER \'%s\'@\'127.0.0.1\' IDENTIFIED BY \'%s\'; GRANT ALL PRIVILEGES ON xtream_iptvpro.* TO \'%s\'@\'127.0.0.1\' WITH GRANT OPTION; GRANT SELECT, PROCESS, LOCK TABLES ON *.* TO \'%s\'@\'127.0.0.1\';FLUSH PRIVILEGES;" > /dev/null' % (rExtra, rUsername, rPassword, rUsername, rUsername))
  145. os.system('mysql -u root%s -e "GRANT SELECT, INSERT, UPDATE, DELETE ON xtream_iptvpro.* TO \'%s\'@\'%%\' IDENTIFIED BY \'%s\';FLUSH PRIVILEGES;" > /dev/null' % (rExtra, rUsername, rPassword))
  146. 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)
  147. #last one is to prevent an xc vulnerability, run "UPDATE settings SET get_real_ip_client='HTTP_CF_CONNECTING_IP' where id=1;" query if you are using cf proxy.
  148. os.system('mysql -u root%s -e "USE xtream_iptvpro; UPDATE settings SET get_real_ip_client=\'\', double_auth=\'1\', hash_lb=\'1\', mag_security=\'1\' where id=\'1\';" > /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\", \"pconnect\":\"0\"}' % (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=3G 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. os.system("mount -a")
  180. try: os.remove("/usr/bin/ffmpeg")
  181. except: pass
  182. if not os.path.exists("/home/xtreamcodes/iptv_xtream_codes/tv_archive"): os.mkdir("/home/xtreamcodes/iptv_xtream_codes/tv_archive/")
  183. os.system("ln -s /home/xtreamcodes/iptv_xtream_codes/bin/ffmpeg /usr/bin/")
  184. os.system("chown xtreamcodes:xtreamcodes -R /home/xtreamcodes > /dev/null")
  185. os.system("chmod -R 0777 /home/xtreamcodes > /dev/null")
  186. if rType == "MAIN":
  187. os.system("sudo find /home/xtreamcodes/iptv_xtream_codes/admin/ -type f -exec chmod 644 {} \;")
  188. os.system("sudo find /home/xtreamcodes/iptv_xtream_codes/admin/ -type d -exec chmod 755 {} \;")
  189. #adds domain/user/pass/id.ts url support
  190. with open('/home/xtreamcodes/iptv_xtream_codes/nginx/conf/nginx.conf', 'r') as nginx_file:
  191. nginx_replace = nginx_file.read()
  192. nginx_replace = nginx_replace.replace("rewrite ^/(.*)/(.*)/(\\d+)$ /streaming/clients_live.php?username=$1&password=$2&stream=$3&extension=ts break;", "rewrite ^/(.*)/(.*)/(\\d+)\\.(.*)$ /streaming/clients_live.php?username=$1&password=$2&stream=$3&extension=$4 break;\r\n rewrite ^/(.*)/(.*)/(\\d+)$ /streaming/clients_live.php?username=$1&password=$2&stream=$3&extension=ts break;\r\n")
  193. with open('/home/xtreamcodes/iptv_xtream_codes/nginx/conf/nginx.conf', 'w') as nginx_file:
  194. nginx_file.write(nginx_replace)
  195. os.system("wget -q https://bitbucket.org/emre1393/xtreamui_mirror/downloads/nginx -O /home/xtreamcodes/iptv_xtream_codes/nginx/sbin/nginx")
  196. os.system("wget -q https://bitbucket.org/emre1393/xtreamui_mirror/downloads/nginx_rtmp -O /home/xtreamcodes/iptv_xtream_codes/nginx_rtmp/sbin/nginx_rtmp")
  197. os.system("wget -q https://bitbucket.org/emre1393/xtreamui_mirror/downloads/pid_monitor.php -O /home/xtreamcodes/iptv_xtream_codes/crons/pid_monitor.php")
  198. os.system("sudo chmod +x /home/xtreamcodes/iptv_xtream_codes/nginx/sbin/nginx")
  199. os.system("sudo chmod +x /home/xtreamcodes/iptv_xtream_codes/nginx_rtmp/sbin/nginx_rtmp")
  200. os.system("sudo find /home/xtreamcodes/iptv_xtream_codes/wwwdir/ -type f -exec chmod 644 {} \;")
  201. os.system("sudo find /home/xtreamcodes/iptv_xtream_codes/wwwdir/ -type d -exec chmod 755 {} \;")
  202. os.system("chmod 0700 /home/xtreamcodes/iptv_xtream_codes/config > /dev/null")
  203. os.system("sed -i 's|echo \"Xtream Codes Reborn\";|header(\"Location: https://www.google.com/\");|g' /home/xtreamcodes/iptv_xtream_codes/wwwdir/index.php")
  204. os.system("wget -q https://bitbucket.org/emre1393/xtreamui_mirror/downloads/GeoLite2.mmdb -O /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb")
  205. os.system('chattr -f +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null')
  206. 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")
  207. os.system("chmod +x /home/xtreamcodes/iptv_xtream_codes/start_services.sh > /dev/null")
  208. if not "xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 xtream-codes.com" >> /etc/hosts')
  209. if not "api.xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 api.xtream-codes.com" >> /etc/hosts')
  210. if not "downloads.xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 downloads.xtream-codes.com" >> /etc/hosts')
  211. 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')
  212. def start(first=True):
  213. if first: printc("Starting Xtream Codes")
  214. else: printc("Restarting Xtream Codes")
  215. os.system("/home/xtreamcodes/iptv_xtream_codes/start_services.sh > /dev/null")
  216. if __name__ == "__main__":
  217. try: rVersion = os.popen('lsb_release -sr').read().strip()
  218. except: rVersion = None
  219. if not rVersion in rVersions:
  220. printc("Unsupported Operating System, Works only on Ubuntu Server 16 and 18")
  221. sys.exit(1)
  222. printc("Xtream UI - Installer Mirror", col.OKGREEN, 2)
  223. print "%s │ Check out the mirror repo: https://bitbucket.org/emre1393/xtreamui_mirror %s" % (col.OKGREEN, col.ENDC)
  224. print " "
  225. rType = raw_input(" Installation Type [MAIN, LB]: ")
  226. print " "
  227. if rType.upper() in ["MAIN", "LB"]:
  228. if rType.upper() == "LB":
  229. rHost = raw_input(" Main Server IP Address: ")
  230. rPassword = raw_input(" MySQL Password: ")
  231. try: rServerID = int(raw_input(" Load Balancer Server ID: "))
  232. except: rServerID = -1
  233. print " "
  234. else:
  235. rHost = "127.0.0.1"
  236. rPassword = generate()
  237. rServerID = 1
  238. rAccesscode = generate(12)
  239. rUsername = "user_iptvpro"
  240. rDatabase = "xtream_iptvpro"
  241. rPort = 7999
  242. if len(rHost) > 0 and len(rPassword) > 0 and rServerID > -1:
  243. printc("Start installation? Y/N", col.WARNING)
  244. if raw_input(" ").upper() == "Y":
  245. print " "
  246. rRet = prepare(rType.upper())
  247. if not install(rType.upper()): sys.exit(1)
  248. if rType.upper() == "MAIN":
  249. if not mysql(rUsername, rPassword): sys.exit(1)
  250. encrypt(rHost, rUsername, rPassword, rDatabase, rServerID, rPort)
  251. if rType.upper() == "MAIN":
  252. installadminpanel()
  253. os.system("sed -i 's|randomcodehere|%s|g' /home/xtreamcodes/iptv_xtream_codes/nginx/conf/admin_panel.conf" % rAccesscode)
  254. configure()
  255. start()
  256. printc("Installation completed!", col.OKGREEN, 2)
  257. if rType.upper() == "MAIN":
  258. printc("Please store your MySQL password!")
  259. printc(rPassword)
  260. printc("Admin UI Login URL is:")
  261. printc("http://%s:8080/%s" % (getIP(), rAccesscode))
  262. printc("Admin UI default login is admin/admin")
  263. else: printc("Installation cancelled", col.FAIL)
  264. else: printc("Invalid entries", col.FAIL)
  265. else: printc("Invalid installation type", col.FAIL)

comments powered by Disqus