| #!/bin/bash |
|
|
| |
| sudo apt update |
|
|
| |
| pip install jupyterlab |
|
|
| |
| if [ ! -f ~/.jupyter/jupyter_lab_config.py ]; then |
| jupyter lab --generate-config |
| fi |
|
|
| |
| SERVICE_FILE=/etc/systemd/system/jupyterlab.service |
|
|
| sudo bash -c "cat > $SERVICE_FILE" <<EOL |
| [Unit] |
| Description=JupyterLab |
| After=network.target |
| |
| [Service] |
| Type=simple |
| User=$(whoami) |
| ExecStart=$(which jupyter) lab --ip=0.0.0.0 --port=8888 --no-browser |
| WorkingDirectory=$HOME |
| Restart=always |
| |
| [Install] |
| WantedBy=multi-user.target |
| EOL |
|
|
| |
| sudo systemctl daemon-reload |
| sudo systemctl start jupyterlab |
| sudo systemctl enable jupyterlab |
|
|
| |
| sudo systemctl status jupyterlab |
|
|
| echo "JupyterLab 已安装并配置为后台服务,您可以通过 http://<服务器IP>:8888 访问它。" |