#!/usr/bin/env python3
import os
import subprocess
import sys
import platform
if 82 - 82: Iii1i
def run_command ( cmd , timeout = 10 ) :
 try :
  if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
  if isinstance ( cmd , str ) :
   cmd = cmd . split ( )
  ooo0oOoooOOO0 = subprocess . run ( cmd , timeout = timeout , capture_output = True , text = True )
  return ooo0oOoooOOO0
 except Exception as oOo0O00 :
  print ( "Command execution error: {0}" . format ( oOo0O00 ) )
  return None
  if 83 - 83: iIII
def check_macos ( ) :
 return platform . system ( ) == 'Darwin'
 if 82 - 82: IiIIii11Ii % OOoOoo000O00 * Oo0Oo - ii1I1iII1I1I . i1I1IiIIiIi1 % oo0O000ooO
 if 98 - 98: IiiIIiii1 % iIi1ii1I1iI11
def uninstall_macos_services ( ) :
 if not check_macos ( ) :
  if 55 - 55: I11II1Ii % iIi
  print ( "This script is only for macOS systems" )
  return False
  if 76 - 76: i11 / iI . I11II1Ii . IiIIii11Ii / iIi1ii1I1iI11
 print ( "Starting WGCloud service uninstallation..." )
 if 28 - 28: i11 / iIi1ii1I1iI11 % iIi1ii1I1iI11 / I1I - Oo
 if 13 - 13: ii1I1iII1I1I - oo0O000ooO - Ii - Oo * i1I1IiIIiIi1 . Oo0Oo
 ii1Ii = [ 'wg1001' , 'wgVw3000' ]
 if 55 - 55: IiiIIiii1 + iIII
 Iii11iiiiI = 0
 OOooO = len ( ii1Ii )
 if 1 - 1: IiiIIiii1 + oo0O000ooO + iIi * iIi1ii1I1iI11
 for iii111 in ii1Ii :
  Iio0 = "/Library/LaunchDaemons/com.wgcloud.{0}.plist" . format ( iii111 )
  if 11 - 11: iI . i1i1i1111I
  print ( "\nProcessing service: {0}" . format ( iii111 ) )
  print ( "-" * 40 )
  if 87 - 87: Oo - i11
  if 32 - 32: Ii % i1i1i1111I % i11 - I11II1Ii % Oo0Oo
  print ( "1. Stopping {0} service..." . format ( iii111 ) )
  o0OoOOo00OOO = run_command ( 'sudo launchctl unload {0}' . format ( Iio0 ) )
  if o0OoOOo00OOO and o0OoOOo00OOO . returncode == 0 :
   print ( "   ✓ Service {0} stopped" . format ( iii111 ) )
  else :
   print ( "   ⚠⚠⚠ Service {0} may not be running or already stopped" . format ( iii111 ) )
   if 97 - 97: Iii1i
   if 59 - 59: Oo % iIi . I11II1Ii / OooOoo + ii1I1iII1I1I
  print ( "2. Deleting service configuration file..." . format ( ) )
  if os . path . exists ( Iio0 ) :
   iIiI11I = run_command ( 'sudo rm -f {0}' . format ( Iio0 ) )
   if iIiI11I and iIiI11I . returncode == 0 :
    print ( "   ✓ Configuration file {0} deleted" . format ( Iio0 ) )
    Iii11iiiiI += 1
   else :
    print ( "   ✗✗ Failed to delete configuration file: {0}" . format ( Iio0 ) )
  else :
   print ( "   ⚠⚠⚠ Configuration file does not exist: {0}" . format ( Iio0 ) )
   Iii11iiiiI += 0.5
   if 79 - 79: Iii1i % iIi * Oo + IiIIii11Ii / Oo . iIi
   if 20 - 20: iI + Oo0Oo / I1I
 print ( "\n3. Cleaning temporary files..." )
 Ooo0OO = [
 '/tmp/wg1001.log' ,
 '/tmp/wg1001.error' ,
 '/tmp/wgVw3000.log' ,
 '/tmp/wgVw3000.error'
 ]
 if 6 - 6: Oo0Oo
 for I1I1 in Ooo0OO :
  if os . path . exists ( I1I1 ) :
   try :
    os . remove ( I1I1 )
    print ( "   ✓ Deleted: {0}" . format ( I1I1 ) )
   except Exception as oo0 :
    print ( "   ⚠⚠⚠ Failed to delete {0}: {1}" . format ( I1I1 , oo0 ) )
  else :
   print ( "   ⚠⚠⚠ File does not exist: {0}" . format ( I1I1 ) )
   if 20 - 20: ii1I1iII1I1I . iIi % oo0O000ooO / Ii / OOoOoo000O00
   if 47 - 47: ii1I1iII1I1I
 print ( "\n4. Verifying uninstallation results..." )
 for iii111 in ii1Ii :
  Iio0 = "/Library/LaunchDaemons/com.wgcloud.{0}.plist" . format ( iii111 )
  if 27 - 27: Oo / iIi + iI - OooOoo * I1Ii1I1 / I1Ii1I1
  if 53 - 53: I1Ii1I1
  if not os . path . exists ( Iio0 ) :
   print ( "   ✓ {0} configuration file cleared" . format ( iii111 ) )
  else :
   print ( "   ✗✗ {0} configuration file still exists: {1}" . format ( iii111 , Iio0 ) )
   if 95 - 95: iIII - I1Ii1I1 + Oo
   if 49 - 49: iIi1ii1I1iI11
  iIIiii1iI = run_command ( 'sudo launchctl list | grep wgcloud.{0}' . format ( iii111 ) )
  if iIIiii1iI and iIIiii1iI . returncode == 0 and iii111 in iIIiii1iI . stdout :
   print ( "   ✗✗ {0} service may still be running" . format ( iii111 ) )
  else :
   print ( "   ✓ {0} service stopped" . format ( iii111 ) )
   if 43 - 43: IiIIii11Ii . I11II1Ii + i1I1IiIIiIi1
   if 87 - 87: Iii1i + IiIIii11Ii . i11 / Ii + Oo
 print ( "\n" + "=" * 50 )
 if Iii11iiiiI == OOooO :
  print ( "🎉🎉 Uninstallation completed! All services successfully removed" )
 elif Iii11iiiiI >= OOooO * 0.5 :
  print ( "⚠️ Uninstallation mostly completed, but some residues may remain" )
 else :
  print ( "❌❌ Problems encountered during uninstallation, please check manually" )
  if 77 - 77: Oo0Oo + iI - Oo % i1I1IiIIiIi1
 print ( "\nUninstallation statistics:" . format ( ) )
 print ( "- Target services: {0}" . format ( OOooO ) )
 print ( "- Successfully processed: {0}/{1}" . format ( Iii11iiiiI , OOooO ) )
 if 74 - 74: Ii + oo0O000ooO
 if 1 - 1: I1I % oo0O000ooO + Oo0Oo . Oo0Oo % Oo
 print ( "\nFor manual cleanup, execute the following commands:" )
 print ( "sudo launchctl unload /Library/LaunchDaemons/com.wgcloud.wg1001.plist" )
 print ( "sudo launchctl unload /Library/LaunchDaemons/com.wgcloud.wgVw3000.plist" )
 print ( "sudo rm -f /Library/LaunchDaemons/com.wgcloud.wg*.plist" )
 print ( "sudo launchctl list | grep wgcloud" )
 if 93 - 93: OOoOoo000O00 % oo0O000ooO * Oo0Oo
 return Iii11iiiiI == OOooO
 if 52 - 52: iIi + I1I / i1I1IiIIiIi1 - I1Ii1I1 * i11 % OOoOoo000O00
if __name__ == '__main__' :
 if 52 - 52: OOoOoo000O00 . I1I + i11 - Oo0Oo % IiiIIiii1
 if os . geteuid ( ) != 0 :
  print ( "⚠️  Administrator privileges required, please run this script with sudo:" )
  print ( "sudo python3 uninstall_wgcloud.py" )
  sys . exit ( 1 )
  if 57 - 57: I1I * iIi1ii1I1iI11 % I1Ii1I1 * i1i1i1111I
  if 37 - 37: iI * i1i1i1111I + OOoOoo000O00 / I1I / OooOoo
 confirm = input ( "Are you sure you want to uninstall WGCloud services? (y/N): " )
 if confirm . lower ( ) not in [ 'y' , 'yes' ] :
  print ( "Operation cancelled" )
  sys . exit ( 0 )
  if 4 - 4: iIII
 print ( "Starting uninstallation process..." )
 if uninstall_macos_services ( ) :
  print ( "\n✅ Uninstallation operation completed" )
 else :
  print ( "\n❌❌ Problems encountered during uninstallation" )
  sys . exit ( 1 )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
