# 创建linux服务
# sudo python3 install_linux_service.py
import os
import subprocess
import sys
if 82 - 82: Iii1i
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
if 31 - 31: i1I
if 9 - 9: IiI11Ii111 / oOo0O00 / IiIIii11Ii - I11iiIi11i1I - iI1iII1I1I1i
def run_file ( cmd ) :
 try :
  if 16 - 16: i1i1i1111I / i1iiIII111
  subprocess . run ( cmd . split ( ) , timeout = 5 )
 except Exception as iiii11iiiiI :
  print ( iiii11iiiiI )
  print ( cmd )
  if 10 - 10: ooOOO / IIiIIiIi11I1 * oOO / i1I / i1I
  if 61 - 61: Ooo0Ooo - I1I
if __name__ == '__main__' :
 wgcloudpathdir = os . path . dirname ( os . path . abspath ( __file__ ) )
 print ( "wgcloudpathdir=" , wgcloudpathdir )
 pythonexe = sys . executable
 if 13 - 13: Ooo0Ooo
 wg1001servicefilename = "wg1001.service"
 if os . path . exists ( "/etc/systemd/system/{}" . format ( wg1001servicefilename ) ) :
  run_file ( 'systemctl stop {}' . format ( "wg1001" ) )
  if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
  run_file ( 'systemctl disable {}' . format ( wg1001servicefilename ) )
  run_file ( 'rm /etc/systemd/system/{}' . format ( wg1001servicefilename ) )
  if 52 - 52: Oo + I1I / oOO / OooOoo - I1Ii1I1 - ooOOO
  if 60 - 60: iI1iII1I1I1i . oOO
 with open ( "/etc/systemd/system/{}" . format ( wg1001servicefilename ) , "w" ) as f :
  if 13 - 13: oOO
  if 2 - 2: i1
  if 22 - 22: IIiIIiIi11I1 - ooo000 / I1Ii1I1 . ooo000
  f . write ( "[Unit]" )
  f . write ( "\r\n" )
  f . write ( "Description=wg1001" )
  f . write ( "\r\n" )
  if 1 - 1: iI1iII1I1I1i + Ooo0Ooo + oOO * IIiIIiIi11I1
  f . write ( "After=network.target network-online.target" )
  if 20 - 20: I1I + Ii
  f . write ( "\r\n" )
  if 75 - 75: Ii % i1iiIII111 * Ii . IIiIIiIi11I1 % I11iiIi11i1I % I1Ii1I1
  f . write ( "Wants=network-online.target" )
  if 8 - 8: I1Ii1I1 . IiI11Ii111 . i1 . Oo - i1I
  f . write ( "\r\n" )
  if 32 - 32: Ii % i1i1i1111I % i1I - I11iiIi11i1I % i1iiIII111
  f . write ( "[Service]" )
  f . write ( "\r\n" )
  if 34 - 34: i1iiIII111 * i1
  if 34 - 34: oOo0O00 / i1iiIII111 - Iii1i . iI1iII1I1I1i
  if 80 - 80: i1i1i1111I . I1I % ooOOO % IiIIii11Ii / i1i1i1111I
  if 32 - 32: I1Ii1I1 + oOO - oOo0O00
  f . write ( "ExecStart={} '{}/1001CloudServer.py' &" . format ( pythonexe , wgcloudpathdir ) )
  f . write ( "\r\n" )
  if 79 - 79: Iii1i % oOO * Oo + ooOOO / Oo . oOO
  f . write ( "WorkingDirectory={}" . format ( wgcloudpathdir ) )
  f . write ( "\r\n" )
  if 20 - 20: IiI11Ii111 + i1iiIII111 / I1I
  f . write ( "Restart=on-failure" )
  f . write ( "\r\n" )
  f . write ( "RestartSec=30s" )
  f . write ( "\r\n" )
  f . write ( "StandardOutput=null" )
  f . write ( "\r\n" )
  if 88 - 88: I11iiIi11i1I + ooOOO - i1i1i1111I . Ooo0Ooo * Ii + Iii1i
  f . write ( "\r\n" )
  if 43 - 43: ooOOO * I1Ii1I1
  f . write ( "[Install]" )
  f . write ( "\r\n" )
  f . write ( "WantedBy=multi-user.target" )
  f . write ( "\r\n" )
  if 95 - 95: Ooo0Ooo % Iii1i % i1i1i1111I . OooOoo
  if 70 - 70: IiIIii11Ii
 run_file ( 'systemctl enable {}' . format ( wg1001servicefilename ) )
 print ( "create 1001CloudServer service (wg1001) finished.\r\n" )
 run_file ( 'systemctl start {}' . format ( "wg1001" ) )
 print ( "start 1001CloudServer service (wg1001).\r\n" )
 if 75 - 75: Ooo0Ooo / Ii / IiIIii11Ii + IiIIii11Ii . I1I
 if 88 - 88: Oo * IiIIii11Ii
 Vw3000servicefilename = "Vw3000.service"
 if os . path . exists ( "/etc/systemd/system/{}" . format ( Vw3000servicefilename ) ) :
  run_file ( 'systemctl stop {}' . format ( "Vw3000" ) )
  if 100 - 100: IiI11Ii111 - OooOoo * I1Ii1I1 / Ooo0Ooo / Iii1i
  run_file ( 'systemctl disable {}' . format ( Vw3000servicefilename ) )
  run_file ( 'rm /etc/systemd/system/{}' . format ( Vw3000servicefilename ) )
  if 23 - 23: Ooo0Ooo + i1 * I1Ii1I1 + Oo * Ii - IIiIIiIi11I1
 Vw3000servicefilename = "wgVw3000.service"
 if os . path . exists ( "/etc/systemd/system/{}" . format ( Vw3000servicefilename ) ) :
  run_file ( 'systemctl stop {}' . format ( "wgVw3000" ) )
  if 29 - 29: IiIIii11Ii - oOo0O00
  run_file ( 'systemctl disable {}' . format ( Vw3000servicefilename ) )
  run_file ( 'rm /etc/systemd/system/{}' . format ( Vw3000servicefilename ) )
  if 30 - 30: I1I . ooo000
  if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
 with open ( "/etc/systemd/system/{}" . format ( Vw3000servicefilename ) , "w" ) as f :
  if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
  if 77 - 77: i1iiIII111 + IiI11Ii111 - Oo % ooo000
  if 74 - 74: Ii + Ooo0Ooo
  f . write ( "[Unit]" )
  f . write ( "\r\n" )
  if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
  f . write ( "Description=wgVw3000" )
  f . write ( "\r\n" )
  f . write ( "After=network.target network-online.target" )
  f . write ( "\r\n" )
  if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
  f . write ( "[Service]" )
  f . write ( "\r\n" )
  if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
  if 52 - 52: oOo0O00 . I1I + i1I - i1iiIII111 % iI1iII1I1I1i
  if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
  f . write ( "ExecStart={} '{}/Vw3000.py'" . format ( pythonexe , wgcloudpathdir ) )
  f . write ( "\r\n" )
  if 37 - 37: IiI11Ii111 * i1i1i1111I + oOo0O00 / I1I / OooOoo
  f . write ( "WorkingDirectory={}" . format ( wgcloudpathdir ) )
  f . write ( "\r\n" )
  if 4 - 4: i1
  f . write ( "Restart=on-failure" )
  f . write ( "\r\n" )
  f . write ( "RestartSec=30s" )
  f . write ( "\r\n" )
  f . write ( "StandardOutput=null" )
  f . write ( "\r\n" )
  if 61 - 61: iI1iII1I1I1i . i1I - ooo000 / ooo000 - i1
  f . write ( "[Install]" )
  f . write ( "\r\n" )
  f . write ( "WantedBy=multi-user.target" )
  f . write ( "\r\n" )
  if 19 - 19: Iii1i * Ooo0Ooo . I1Ii1I1 / I11iiIi11i1I * Ii - oOO
  if 32 - 32: iI1iII1I1I1i
 run_file ( 'systemctl enable {}' . format ( Vw3000servicefilename ) )
 if 18 - 18: I11iiIi11i1I * IiI11Ii111 % iI1iII1I1I1i + IiI11Ii111
 print ( "create Vw3000 service (wgVw3000) finished.\r\n" )
 run_file ( 'systemctl start {}' . format ( "wgVw3000" ) )
 print ( "start 1001CloudServer service (wgVw3000).\r\n" )
 print ( "\r\n" )
 print ( "\r\n" )
 if 93 - 93: oOO - I1Ii1I1 - IIiIIiIi11I1 * ooOOO - i1
 if 82 - 82: IIiIIiIi11I1 % i1 * ooOOO
 if 57 - 57: oOo0O00
 if 31 - 31: i1iiIII111 + i1i1i1111I % OooOoo
 print ( " !!!visit web:  http://localhost:61085/      (user: abc   password: 123)\r\n" )
 print ( "\r\n" )
 if 20 - 20: OooOoo - I1I
 if 9 - 9: i1iiIII111 - iI1iII1I1I1i % Ii - I1I
 if 54 - 54: Iii1i % ooo000 % Iii1i - IiIIii11Ii
 if 39 - 39: oOO - oOO * i1 % IIiIIiIi11I1
 if 29 - 29: IIiIIiIi11I1 - ooo000 . i1iiIII111
 if 86 - 86: I1Ii1I1 - OooOoo - oOO % ooo000 . i1I % Iii1i
 if 11 - 11: OooOoo - I1Ii1I1 - ooOOO . i1iiIII111 - iI1iII1I1I1i / i1iiIII111
 if 44 - 44: Ooo0Ooo + i1i1i1111I + Iii1i - oOO
 if 7 - 7: i1i1i1111I / Ii * Iii1i
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
