mirror of
https://github.com/xoceunder/Xtream-UI-install.git
synced 2026-10-25 01:02:19 +02:00
Update install.py
This commit is contained in:
+25
-24
@@ -139,12 +139,13 @@ def prepare(rType="MAIN"):
|
||||
os.system("apt-get -y full-upgrade > /dev/null 2>&1")
|
||||
if rType == "MAIN":
|
||||
os.system("sudo apt-get -yq install software-properties-common > /dev/null 2>&1")
|
||||
os.system("curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version='mariadb-11.5' > /dev/null 2>&1")
|
||||
printc("Adding repo: Ubuntu %s" % getCodename())
|
||||
os.system("apt-get update > /dev/null 2>&1")
|
||||
for rPackage in rRemove:
|
||||
if is_installed(rPackage):
|
||||
printc("Removing %s" % rPackage)
|
||||
os.system("sudo DEBIAN_FRONTEND=noninteractive apt-get remove %s > /dev/null" % rPackage)
|
||||
os.system("sudo DEBIAN_FRONTEND=noninteractive apt-get remove %s >/dev/null 2>&1" % rPackage)
|
||||
for rPackage in rPackages:
|
||||
if not is_installed(rPackage):
|
||||
printc("Installing %s" % rPackage)
|
||||
@@ -152,14 +153,14 @@ def prepare(rType="MAIN"):
|
||||
if not is_installed("libssl1.1"):
|
||||
printc("Installing libssl1.1")
|
||||
subprocess.run("wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb > /dev/null 2>&1 && sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb > /dev/null 2>&1 && rm -rf libssl1.1_1.1.0g-2ubuntu4_amd64.deb > /dev/null 2>&1", shell=True)
|
||||
os.system("apt-get install -f -y > /dev/null") # Clean up above
|
||||
os.system("systemctl start mariadb > /dev/null")
|
||||
os.system("apt-get install -f -y >/dev/null 2>&1") # Clean up above
|
||||
os.system("systemctl start mariadb >/dev/null 2>&1")
|
||||
try:
|
||||
subprocess.check_output("getent passwd xtreamcodes > /dev/null".split())
|
||||
subprocess.check_output("getent passwd xtreamcodes >/dev/null 2>&1".split())
|
||||
except:
|
||||
# Create User
|
||||
printc("Creating user xtreamcodes")
|
||||
os.system("adduser --system --shell /bin/false --group --disabled-login xtreamcodes > /dev/null")
|
||||
os.system("adduser --system --shell /bin/false --group --disabled-login xtreamcodes >/dev/null 2>&1")
|
||||
if not os.path.exists("/home/xtreamcodes"): os.mkdir("/home/xtreamcodes")
|
||||
return True
|
||||
|
||||
@@ -173,7 +174,7 @@ def install(rType="MAIN"):
|
||||
os.system('wget -q -O "/tmp/xtreamcodes.zip" "%s"' % rURL)
|
||||
if os.path.exists("/tmp/xtreamcodes.zip"):
|
||||
printc("Installing Software")
|
||||
os.system('unzip -o "/tmp/xtreamcodes.zip" -d "/home/xtreamcodes/" > /dev/null')
|
||||
os.system('unzip -o "/tmp/xtreamcodes.zip" -d "/home/xtreamcodes/" >/dev/null 2>&1')
|
||||
if not os.path.exists("/home/xtreamcodes/iptv_xtream_codes/xtreamcodes"):
|
||||
os.system("wget -q https://github.com/xoceunder/Xtream-UI-install/raw/main/xtreamcodes -O /home/xtreamcodes/iptv_xtream_codes/xtreamcodes")
|
||||
os.system("sudo chmod +x /home/xtreamcodes/iptv_xtream_codes/xtreamcodes")
|
||||
@@ -206,9 +207,9 @@ def update(rType="MAIN"):
|
||||
os.remove("/tmp/update.zip")
|
||||
return False
|
||||
printc("Updating Software")
|
||||
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 && 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')
|
||||
os.system('chattr -i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb >/dev/null 2>&1 && rm -rf /home/xtreamcodes/iptv_xtream_codes/admin >/dev/null 2>&1 && rm -rf /home/xtreamcodes/iptv_xtream_codes/pytools >/dev/null 2>&1 && unzip /tmp/update.zip -d /tmp/update/ >/dev/null 2>&1 && cp -rf /tmp/update/XtreamUI-master/* /home/xtreamcodes/iptv_xtream_codes/ >/dev/null 2>&1 && rm -rf /tmp/update/XtreamUI-master >/dev/null 2>&1 && rm -rf /tmp/update >/dev/null 2>&1 && chown -R xtreamcodes:xtreamcodes /home/xtreamcodes/ >/dev/null 2>&1 && chmod +x /home/xtreamcodes/iptv_xtream_codes/permissions.sh >/dev/null 2>&1 && chattr +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb >/dev/null 2>&1')
|
||||
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')
|
||||
os.system("/home/xtreamcodes/iptv_xtream_codes/permissions.sh > /dev/null")
|
||||
os.system("/home/xtreamcodes/iptv_xtream_codes/permissions.sh >/dev/null 2>&1")
|
||||
try: os.remove("/tmp/update.zip")
|
||||
except: pass
|
||||
return True
|
||||
@@ -227,7 +228,7 @@ def mysql(rUsername, rPassword, ssh_pwd):
|
||||
rFile = open("/etc/mysql/my.cnf", "wb")
|
||||
rFile.write(rMySQLCnf)
|
||||
rFile.close()
|
||||
os.system("systemctl restart mariadb > /dev/null")
|
||||
os.system("systemctl restart mariadb >/dev/null 2>&1")
|
||||
#printc("Enter MySQL Root Password:", col.BRIGHT_RED)
|
||||
for i in range(5):
|
||||
rMySQLRoot = "" #raw_input(" ")
|
||||
@@ -237,14 +238,14 @@ def mysql(rUsername, rPassword, ssh_pwd):
|
||||
rDrop = True
|
||||
try:
|
||||
if rDrop:
|
||||
os.system('mariadb -u root%s -e "DROP DATABASE IF EXISTS xtream_iptvpro; CREATE DATABASE IF NOT EXISTS xtream_iptvpro;" > /dev/null' % rExtra)
|
||||
os.system('mariadb -u root%s -e "USE xtream_iptvpro; DROP USER IF EXISTS \'%s\'@\'%%\';" > /dev/null' % (rExtra, rUsername))
|
||||
os.system("mariadb -u root%s xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/database.sql > /dev/null" % rExtra)
|
||||
os.system('mariadb -u root%s -e "USE xtream_iptvpro; UPDATE settings SET live_streaming_pass = \'%s\', unique_id = \'%s\', crypt_load_balancing = \'%s\';" > /dev/null' % (rExtra, generate(20), generate(10), generate(20)))
|
||||
os.system('mariadb -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\', \'\', \'%s\', \'22\', 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(), encoded_ssh, getVersion()))
|
||||
os.system('mariadb -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)
|
||||
os.system('mariadb -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))
|
||||
os.system('mariadb -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)
|
||||
os.system('mariadb -u root%s -e "DROP DATABASE IF EXISTS xtream_iptvpro; CREATE DATABASE IF NOT EXISTS xtream_iptvpro;" >/dev/null 2>&1' % rExtra)
|
||||
os.system('mariadb -u root%s -e "USE xtream_iptvpro; DROP USER IF EXISTS \'%s\'@\'%%\';" >/dev/null 2>&1' % (rExtra, rUsername))
|
||||
os.system("mariadb -u root%s xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/database.sql >/dev/null 2>&1" % rExtra)
|
||||
os.system('mariadb -u root%s -e "USE xtream_iptvpro; UPDATE settings SET live_streaming_pass = \'%s\', unique_id = \'%s\', crypt_load_balancing = \'%s\';" >/dev/null 2>&1' % (rExtra, generate(20), generate(10), generate(20)))
|
||||
os.system('mariadb -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\', \'\', \'%s\', \'22\', 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 2>&1' % (rExtra, getIP(), encoded_ssh, getVersion()))
|
||||
os.system('mariadb -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 2>&1' % rExtra)
|
||||
os.system('mariadb -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 2>&1' % (rExtra, rUsername, rPassword, rUsername, rUsername))
|
||||
os.system('mariadb -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 2>&1' % rExtra)
|
||||
try: os.remove("/home/xtreamcodes/iptv_xtream_codes/database.sql")
|
||||
except: pass
|
||||
return True
|
||||
@@ -324,14 +325,14 @@ def configure():
|
||||
os.system("ln -s /home/xtreamcodes/iptv_xtream_codes/bin/ffmpeg /usr/bin/")
|
||||
if not os.path.exists("/home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb"): os.system("wget -q https://bitbucket.org/xoceunder/xtream-ui-install/raw/main/GeoLite2.mmdb -O /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb")
|
||||
if not os.path.exists("/home/xtreamcodes/iptv_xtream_codes/crons/pid_monitor.php"): os.system("wget -q https://bitbucket.org/xoceunder/xtream-ui-install/raw/main/pid_monitor.php -O /home/xtreamcodes/iptv_xtream_codes/crons/pid_monitor.php")
|
||||
os.system("chown xtreamcodes:xtreamcodes -R /home/xtreamcodes > /dev/null")
|
||||
os.system("chmod -R 0777 /home/xtreamcodes > /dev/null")
|
||||
os.system("chattr -ai /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null")
|
||||
os.system("sudo chmod 0777 /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb > /dev/null")
|
||||
os.system("chown xtreamcodes:xtreamcodes -R /home/xtreamcodes >/dev/null 2>&1")
|
||||
os.system("chmod -R 0777 /home/xtreamcodes >/dev/null 2>&1")
|
||||
os.system("chattr -ai /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb >/dev/null 2>&1")
|
||||
os.system("sudo chmod 0777 /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb >/dev/null 2>&1")
|
||||
if os.path.exists("/home/xtreamcodes/iptv_xtream_codes/start_services.sh"):
|
||||
os.remove("/home/xtreamcodes/iptv_xtream_codes/start_services.sh")
|
||||
os.system("sudo mount -a >/dev/null 2>&1")
|
||||
os.system("chmod 0700 /home/xtreamcodes/iptv_xtream_codes/config > /dev/null")
|
||||
os.system("chmod 0700 /home/xtreamcodes/iptv_xtream_codes/config >/dev/null 2>&1")
|
||||
os.system("sed -i 's|echo \"Xtream Codes Reborn\";|header(\"Location: https://www.google.com/\");|g' /home/xtreamcodes/iptv_xtream_codes/wwwdir/index.php")
|
||||
if not "api.xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 api.xtream-codes.com" >> /etc/hosts')
|
||||
if not "downloads.xtream-codes.com" in open("/etc/hosts").read(): os.system('echo "127.0.0.1 downloads.xtream-codes.com" >> /etc/hosts')
|
||||
@@ -340,10 +341,10 @@ def configure():
|
||||
def start(first=True):
|
||||
if first:
|
||||
printc("Starting Xtream Codes")
|
||||
os.system("sudo systemctl start xtreamcodes > /dev/null")
|
||||
os.system("sudo systemctl start xtreamcodes >/dev/null 2>&1")
|
||||
else:
|
||||
printc("Restarting Xtream Codes")
|
||||
os.system("sudo systemctl restart xtreamcodes > /dev/null")
|
||||
os.system("sudo systemctl restart xtreamcodes >/dev/null 2>&1")
|
||||
|
||||
def modifyNginx():
|
||||
printc("Modifying Nginx")
|
||||
|
||||
Reference in New Issue
Block a user