Repository navigation
Expand file tree
/
Copy pathmainfile.py
More file actions
53 lines (42 loc) · 1.63 KB
/
Copy pathmainfile.py
File metadata and controls
53 lines (42 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import subprocess
import tarfile
import urllib.request
def download_file(url, filename):
urllib.request.urlretrieve(url, filename)
def extract_tar(filename, destination):
with tarfile.open(filename, 'r:gz') as tar:
tar.extractall(destination)
def create_eula_file():
with open('eula.txt', 'w') as f:
f.write('eula=true')
def create_launch_script(ram):
with open('lunch.py', 'w') as f:
f.write(f'''#!/usr/bin/env python3
import subprocess
subprocess.run(["./java/jdk-17/bin/java", "-Xms{ram}g", "-Xmx{ram}g", "-jar", "./server.jar"])
print("FINISHED")
print("THX FOR TIME (Shiref Reda)")
print("fb.com/shiref.reda.official")
print("t.me/instantlly")
print("BYE")
''')
def main():
url = input("Enter the link to download: ")
download_file(url, 'server.jar')
create_eula_file()
download_java = input("Do you want to download Java? (yes/no): ")
if download_java.lower() == 'yes':
java_url = "https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz"
download_file(java_url, 'java.tar.gz')
os.makedirs('java')
extract_tar('java.tar.gz', 'java')
os.remove('java.tar.gz') # Remove the compressed file after extraction
create_launch = input("Do you want to create a launch script? (yes/no): ")
if create_launch.lower() == 'yes':
ram = input("Enter the amount of RAM in gigabytes (min is 1): ")
create_launch_script(ram)
os.chmod('lunch.py', 0o755)
print("Launch script created successfully as 'lunch.py'.")
if __name__ == "__main__":
main()