setup.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. This file is part of the UFONet project, https://ufonet.03c8.net
  5. Copyright (c) 2013/2026 | psy <epsylon@riseup.net>
  6. You should have received a copy of the GNU General Public License along
  7. with UFONet; if not, write to the Free Software Foundation, Inc., 51
  8. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  9. """
  10. import sys, time
  11. if sys.version_info[0] != 3:
  12. sys.exit("Sorry, UFONet requires Python >= 3")
  13. libs = ("pygeoip", "requests", "urllib3", "whois", "scapy", "pycryptodomex", "ddgs", "dnspython", "certifi")
  14. import subprocess, os
  15. PY_TAG = "python{}.{}".format(sys.version_info[0], sys.version_info[1])
  16. LIBPYTHON_DEV = "libpython{}.{}-dev".format(sys.version_info[0], sys.version_info[1])
  17. PIP_FLAGS = ["--no-warn-script-location", "--root-user-action=ignore", "--break-system-packages"]
  18. def speech():
  19. print("[MASTER] Connecting UFONET [AI] system, remotely...\n")
  20. time.sleep(5)
  21. print("\n[AI] Hello Master!... ;-)\n")
  22. print("\n[AI] Launching self-deployment protocols...\n")
  23. time.sleep(2)
  24. print(r" _______")
  25. print(r" |.-----.|")
  26. print(r" ||x . x||")
  27. print(r" ||_.-._||")
  28. print(r" `--)-(--`")
  29. print(r" __[=== o]___")
  30. print(r" |:::::::::::|")
  31. def checkeuid():
  32. try:
  33. euid = os.geteuid()
  34. except:
  35. sys.exit(2)
  36. return euid
  37. def install(packages):
  38. subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "pip"] + PIP_FLAGS)
  39. subprocess.run([sys.executable, "-m", "pip", "install", "pycurl", "--upgrade"] + PIP_FLAGS)
  40. for lib in packages:
  41. subprocess.run([sys.executable, "-m", "pip", "install", lib, "--ignore-installed"] + PIP_FLAGS)
  42. if __name__ == '__main__':
  43. euid = checkeuid()
  44. if euid != 0:
  45. try:
  46. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  47. os.execlpe('sudo', *args)
  48. except:
  49. sys.exit()
  50. sys.exit()
  51. speech()
  52. apt_cmd = "sudo apt-get install -y --no-install-recommends {libdev} python3-pycurl python3-geoip python3-whois python3-requests libgeoip1 libgeoip-dev".format(libdev=LIBPYTHON_DEV)
  53. os.system(apt_cmd)
  54. install(libs)
  55. print("\n[UFONET] Setup has been completed!. You can now try to run: ./ufonet\n")