gendeploy.py 842 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. def readIniConf():
  3. conf = dict()
  4. with open('config.ini') as fp:
  5. for line in fp:
  6. if len(line.strip()) == 0: continue
  7. s = line.split('=', 1)
  8. key = s[0].strip()
  9. value = s[1].strip()
  10. conf[key] = value
  11. return conf
  12. iniConf = readIniConf()
  13. src = """./scripts/genservconf.py
  14. ./scripts/gencliconf.py
  15. scp ./serv-conf/""" + iniConf['server-interface'] + '.conf ' + \
  16. iniConf['ssh-target'] + ':./' + '\n' + \
  17. 'ssh -t ' + iniConf['ssh-target'] + ' \'sudo wg-quick down ' + iniConf['server-interface'] + '\'' + '\n' \
  18. 'ssh -t ' + iniConf['ssh-target'] + ' \'sudo mv ' + iniConf['server-interface'] + '.conf /etc/wireguard/\'' + '\n' \
  19. 'ssh -t ' + iniConf['ssh-target'] + ' \'sudo wg-quick up ' + iniConf['server-interface'] + '\'' + '\n'
  20. print(src)