shells.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 'use strict';
  2. module.exports = {
  3. // strongswan相关命令
  4. swIsEnabled: 'systemctl is-enabled strongswan-swanctl',
  5. // 查看strongswan服务是否开机自启动
  6. swEnable: 'systemctl enable strongswan-swanctl',
  7. // 开启strongswan服务的自启动
  8. swDisable: 'systemctl disable strongswan-swanctl',
  9. // 关闭strongswan服务的自启动
  10. swStatus: 'systemctl status strongswan-swanctl',
  11. // 查看strongswan服务是否正在运行
  12. swStart: 'systemctl start strongswan-swanctl',
  13. // 启动strongswan服务
  14. swRestart: 'systemctl restart strongswan-swanctl',
  15. // 重启strongswan服务
  16. swStop: 'systemctl stop strongswan-swanctl',
  17. // 停止strongswan服务
  18. swReload: 'systemctl reload strongswan-swanctl',
  19. // openvpn相关命令
  20. opIsEnabled: 'systemctl is-enabled openvpn',
  21. // 查看Openvpn是否开机自启动
  22. opEnable: 'systemctl enable openvpn',
  23. // 打开Openvpn服务的自启动
  24. opDisable: 'systemctl disable openvpn',
  25. // 关闭Openvpn服务的自启动
  26. opStatus: 'systemctl status openvpn',
  27. // 查看Openvpn服务是否正在运行
  28. opStart: 'systemctl start openvpn',
  29. // 启动Openvpn服务
  30. opRestart: 'systemctl restart openvpn',
  31. // 重启Openvpn服务
  32. opStop: 'systemctl stop openvpn',
  33. // 停止Openvpn服务
  34. // dhcp相关命令
  35. dhcpIsEnabled: 'systemctl is-enabled isc-dhcp-server',
  36. // 查看dhcp是否开机自启动
  37. dhcpEnable: 'systemctl enable isc-dhcp-server',
  38. // 打开dhcp服务的自启动
  39. dhcpDisable: 'systemctl disable isc-dhcp-server',
  40. // 关闭dhcp服务的自启动
  41. dhcpStatus: 'systemctl status isc-dhcp-server',
  42. // 查看dhcp服务是否正在运行
  43. dhcpStart: 'systemctl start isc-dhcp-server',
  44. // 启动dhcp服务
  45. dhcpRestart: 'systemctl restart isc-dhcp-server',
  46. // 重启dhcp服务
  47. dhcpStop: 'systemctl stop isc-dhcp-server',
  48. // 停止dhcp服务
  49. // 网络配置相关命令
  50. wanDown: 'ifconfig wan down',
  51. // 禁用wan网卡
  52. wanUp: 'ifconfig wan up',
  53. // 启用wan网卡
  54. lanDown: 'ifconfig br-lan down',
  55. // 禁用br-lan网卡
  56. lanUp: 'ifconfig br-lan up',
  57. // 启用br-lan网卡
  58. // 系统重启命令
  59. reboot: 'reboot',
  60. // reboot后系统将自动重启
  61. // 状态检测相关命令
  62. // cpu使用率和内存使用率
  63. deviceState: 'top | head -n 5',
  64. // 结果:
  65. // top - 08:51:46 up 2:49, 1 user, load average: 0.01, 0.11, 0.15
  66. // Tasks: 87 total, 1 running, 46 sleeping, 0 stopped, 0 zombie
  67. // %Cpu(s): 1.4 us, 0.5 sy, 0.0 ni, 97.9 id, 0.0 wa, 0.1 hi, 0.1 si, 0.0 st
  68. // KiB Mem : 997064 total, 682744 free, 154900 used, 159420 buff/cache
  69. // KiB Swap: 0 total, 0 free, 0 used. 747584 avail Mem
  70. // CPU使用率:取第3行 97.9id(比如空闲CPU,100-97.9=2.1 即CPU使用率)
  71. // 内存使用率:取第4行 (997064-682744)/997064
  72. // VPN连接状态
  73. vpnState: 'swanctl -l | grep established',
  74. // 结果(如果已建立连接此显示类似如下信息):
  75. // 如果命令结果为空,表示未建立连接
  76. // 如果命令显示类似:established 74s ago, rekeying in 13516s,表示已建立连接74s
  77. // 时间命令
  78. // 获取当前时间
  79. // date "+%Y-%m-%d %H:%M:%S"
  80. // 结果:2021-03-01 06:19:50
  81. // 设置系统时间
  82. // date -s "2021-03-01 06:19:50"
  83. // 结果:系统时间将被修改为:2021-03-01 06:19:50
  84. // ntp时间同步命令
  85. // 连接测试
  86. // ping 192.168.88.10
  87. // 恢复默认配置
  88. configDefault: 'echo ok',
  89. };