Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.05 KB

README_zh.md

File metadata and controls

44 lines (34 loc) · 1.05 KB

WSL 服务自启动脚本

支持在Windows启动时启动WSL中的Linux服务.

README | 中文文档

目录

安装

  • 使用 git clone 到任意目录 (e.g C:\wsl-autostart)
git clone https://github.com/troytse/wsl-autostart
  • 在注册表中加入启动项 run-regedit

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run下新增字符串项目 (e.g WSLAutostart) regedit-new-item

  • 设定脚本的路径 (e.g C:\wsl-autostart\start.vbs) regedit-set-path

使用

  • 修改在WSL中/etc/sudoers文件,为需要自启动的服务指定为免密码. 如:
%sudo ALL=NOPASSWD: /etc/init.d/cron
%sudo ALL=NOPASSWD: /etc/init.d/ssh
%sudo ALL=NOPASSWD: /etc/init.d/mysql
%sudo ALL=NOPASSWD: /etc/init.d/apache2
  • 修改commands.txt文件指定需要自启动的服务. 如:
/etc/init.d/cron
/etc/init.d/ssh
/etc/init.d/mysql
/etc/init.d/apache2