നിങ്ങൾക്ക് റൂട്ട് അല്ലെങ്കിൽ സുഡോ ആക്സസ് ഉണ്ടെന്ന് ഈ സ്ക്രിപ്റ്റ് അനുമാനിക്കുന്നു.
import os
import subprocess
def run_command(command):
"""Run a system command and check for errors."""
print(f"Running command: {' '.join(command)}")
result = subprocess.run(command, check=True, text=True)
if result.returncode != 0:
print(f"Error: Command {' '.join(command)} failed with exit code {result.returncode}")
exit(result.returncode)
def install_3proxy():
# Update package list and install dependencies
run_command(['sudo', 'apt-get', 'update'])
run_command(['sudo', 'apt-get', 'install', '-y', 'build-essential', 'wget'])
# Download and extract 3proxy
run_command(['wget', 'https://github.com/3proxy/3proxy/archive/refs/tags/0.9.3.tar.gz'])
run_command(['tar', 'xzf', '0.9.3.tar.gz'])
# Build 3proxy
os.chdir('3proxy-0.9.3')
run_command(['make', '-f', 'Makefile.Linux'])
# Create necessary directories and copy files
run_command(['sudo', 'mkdir', '-p', '/usr/local/3proxy/bin'])
run_command(['sudo', 'mkdir', '-p', '/usr/local/3proxy/logs'])
run_command(['sudo', 'mkdir', '-p', '/usr/local/3proxy/conf'])
run_command(['sudo', 'cp', 'src/3proxy', '/usr/local/3proxy/bin/'])
# Create a sample configuration file
config = """
daemon
maxconn 1024
nserver 8.8.8.8
nserver 8.8.4.4
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
auth none
allow *
proxy -p8080
flush
"""
with open('/tmp/3proxy.cfg', 'w') as config_file:
config_file.write(config)
run_command(['sudo', 'mv', '/tmp/3proxy.cfg', '/usr/local/3proxy/conf/3proxy.cfg'])
# Create systemd service file
service_file = """
[Unit]
Description=3proxy Proxy Server
After=network.target
[Service]
ExecStart=/usr/local/3proxy/bin/3proxy /usr/local/3proxy/conf/3proxy.cfg
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Type=simple
[Install]
WantedBy=multi-user.target
"""
with open('/tmp/3proxy.service', 'w') as service:
service.write(service_file)
run_command(['sudo', 'mv', '/tmp/3proxy.service', '/etc/systemd/system/3proxy.service'])
# Reload systemd, enable and start 3proxy service
run_command(['sudo', 'systemctl', 'daemon-reload'])
run_command(['sudo', 'systemctl', 'enable', '3proxy'])
run_command(['sudo', 'systemctl', 'start', '3proxy'])
print("3proxy has been installed and started successfully.")
if __name__ == '__main__':
install_3proxy()
സ്ക്രിപ്റ്റ് പ്രവർത്തിപ്പിക്കുന്നതിനുള്ള നിർദ്ദേശങ്ങൾ:
- ഒരു ഫയലിലേക്ക് സ്ക്രിപ്റ്റ് സംരക്ഷിക്കുക, ഉദാഹരണത്തിന്,
install_3proxy.py
. - പ്രവർത്തിപ്പിക്കുന്നതിലൂടെ സ്ക്രിപ്റ്റ് എക്സിക്യൂട്ടബിൾ ആണെന്ന് ഉറപ്പാക്കുക
chmod +x install_3proxy.py
. - ഉപയോഗിച്ച് സ്ക്രിപ്റ്റ് പ്രവർത്തിപ്പിക്കുക
sudo python3 install_3proxy.py
.
ഈ സ്ക്രിപ്റ്റ് ചെയ്യും:
- പാക്കേജ് ലിസ്റ്റ് അപ്ഡേറ്റ് ചെയ്യുക.
- ആവശ്യമായ ഡിപൻഡൻസികൾ ഇൻസ്റ്റാൾ ചെയ്യുക.
- ഡൗൺലോഡ് ചെയ്ത് 3proxy നിർമ്മിക്കുക.
- ആവശ്യമായ ഡയറക്ടറികൾ സൃഷ്ടിക്കുക.
- ഒരു അടിസ്ഥാന കോൺഫിഗറേഷൻ സജ്ജമാക്കുക.
- 3proxy കൈകാര്യം ചെയ്യുന്നതിനായി ഒരു systemd സേവനം സൃഷ്ടിക്കുക.
- 3proxy സേവനം പ്രവർത്തനക്ഷമമാക്കി ആരംഭിക്കുക.
നിങ്ങൾക്ക് ആവശ്യാനുസരണം കോൺഫിഗറേഷൻ ഇഷ്ടാനുസൃതമാക്കാം.
അഭിപ്രായങ്ങൾ (0)
ഇവിടെ ഇതുവരെ അഭിപ്രായങ്ങളൊന്നുമില്ല, നിങ്ങൾക്ക് ആദ്യത്തെയാളാകാം!