echo "启动jupyter 检查文件中..." WORKSPACE="/tmp/jupyter-extension" content=$(nohup jupyter lab --allow-root --ip=0.0.0.0 --port=8888 > /tmp/start.log 2>&1 & sleep 20s; cat /tmp/start.log| grep "JupyterLab application directory") echo $content if [ -z "$content" ]; then echo "content Not Found! please retry!" else jupyter_file_path=$(echo "$content" | grep -oP '(?<=is\s)(\/[^ ]+)') fi # ls "${jupyter_file_path}/static/index.html" # echo "jupyter sourcecode path is :${jupyter_file_path}/static" file_check=$(if [ -d "${jupyter_file_path}/static" ]; then echo "success"; else echo "file check failed"; fi) echo $file_check if [ "failed" == "$file_check" ]; then echo "image jupyter sourcecode path check failed! please retry!" fi # 获取index的内容 那去js名 替换 js_content=$(cat ${jupyter_file_path}/static/index.html) echo $js_content js_path=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/main\.[^"]+\.js\?v=[^"]+' ) js_path2=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js\?v=[^"]+' ) js_path3=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js' ) echo "jupyter js source path is: $js_path" if [ -z "$js_path" ];then if [ -z "$js_path2" ];then if [ -z "$js_path3" ];then echo "image jupyter sourcecode main js path check failed!please retry!" else js_path=$js_path3 fi else js_path=$js_path2 fi fi cat $WORKSPACE/static/index-base.html > $WORKSPACE/static/index.html sed -i "s#mainJsParam#${js_path}#g" $WORKSPACE/static/index.html cp -a $WORKSPACE/static/index.html ${jupyter_file_path}/static/index.html cp -a $WORKSPACE/static/scnet-loading.gif ${jupyter_file_path}/static/scnet-loading.gif pip3 uninstall -r $WORKSPACE/requirements.txt pip3 install --no-index --find-links=$WORKSPACE/ -r $WORKSPACE/requirements.txt if pip list | grep -E 'jupyter_ext_platform' && pip list | grep -E 'jupyter_ext_model' && pip list | grep -E 'jupyterlab-language-pack-zh-CN' && [ "$(jupyter lab --version | cut -d. -f1)" -gt 2 ];then echo "安装成功";else echo \"安装失败!! \" | tee /jupyter-ext/errorImages.txt; fi # 禁用splash插件 jupyter labextension disable @jupyterlab/apputils-extension:splash rm -r $WORKSPACE