Skip to content

Instantly share code, notes, and snippets.

@nufeng1999
Last active September 5, 2021 14:31
Show Gist options
  • Select an option

  • Save nufeng1999/7742e23f82a5f982dfac4a17431b0ef1 to your computer and use it in GitHub Desktop.

Select an option

Save nufeng1999/7742e23f82a5f982dfac4a17431b0ef1 to your computer and use it in GitHub Desktop.
[WSL2 startjupyter-lab] 自动映射 jupyter-lab 端口 #WSL2 #jupyter #WSL2端口映射
#!/bin/bash
cd ~/Jupyter
PROC_NAME=jupyter-lab
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`
#echo $ProcNumber
if [ $ProcNumber -le 0 ];then
echo "--->run jupyter-lab<---"
/usr/local/bin/jupyter-lab --ip=0.0.0.0 --allow-root > /dev/null 2>&1 &
fi
export localhost_ip=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d addr:`
echo $localhost_ip
/mnt/c/WINDOWS/System32/cmd.exe /c "netsh interface portproxy add v4tov4 listenport=8888 listenaddress=0.0.0.0 connectport=8888 connectaddress=$localhost_ip" > /dev/null 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment