Last active
July 20, 2019 10:41
-
-
Save shr00mie/0f45256d99d9144086ab6ae5c2ca93f2 to your computer and use it in GitHub Desktop.
Revisions
-
shr00mie revised this gist
Mar 20, 2018 . 2 changed files with 115 additions and 84 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,84 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,115 @@ #!/bin/bash # variables # listening address for jupyter. set to localhost if only accessing locally. read -p $'\n\e[32mServer static IP address\e[m: ' ipAddress # Set this either as parent or direct working directory of the project you want to work on. read -p $'\n\e[32mProject Parent Directory\e[m: ' WorkingDirectory echo -e "\n...\e[32mGenerating random token\e[m...\n" token=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 35 | head -n 1) echo -e "\n...\e[32mUpdating system\e[m...\n" sudo apt update && sudo apt upgrade -y echo -e "\n...\e[32mAdding Nodejs 9.x repository\e[m...\n" wget https://gist.githubusercontent.com/shr00mie/8473a7f885316dba7f4ac39ca5b13874/raw/fed1b63626ebee6dbc66bacbe0525e5fec4d1aea/nodejs-9x-install.sh chmod u+x nodejs-9x-install.sh sudo ./nodejs-9x-install.sh echo -e "\n...\e[32mInstalling python3, python3-dev, python3-pip, and nodejs\e[m...\n" sudo apt install python3 python3-dev python3-pip nodejs -y echo -e "\n...\e[32mInstalling NVM\e[m...\n" curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash echo -e "\n...\e[32mInstall Cleanup\e[m...\n" sudo apt autoclean && sudo apt autoremove -y rm nodejs-9x-install.sh echo -e "\n...\e[32mUpgrading pip\e[m...\n" pip3 install -U pip echo -e "\n...\e[32mInstalling dependencies\e[m...\n" pip3 install --user autopep8 pylama beautysh websocket-client pymongo mongoengine bintrees requests echo -e "\n...\e[32mInstalling Jupyter Lab & enabling jupyterlab server extension\e[m...\n" pip3 install --user jupyterlab jupyter serverextension enable --py jupyterlab echo -e "\n...\e[32mAdding update alias to ~/.bashrc\e[m...\n" cat << EOF | sudo tee -a /home/$USER/.bashrc # ALIASES alias update='sudo apt update && sudo apt upgrade -y' # PATH export PATH=/home/$USER/.local/bin:$PATH EOF echo -e "\n...\e[32mGenerating jupyter config file\e[m...\n" jupyter-lab --generate-config echo -e "\n...\e[32mTweaking config file\e[m...\n" # allow connections from other devices # listen on static IP # don't open browser on start # set port # set token # Configuration # Incoming connection whitelist. tried with IP & CIDR. not sure about ranges. should be comma separated if more than one. sed -i.back "s/#c.NotebookApp.allow_origin = ''/c.NotebookApp.allow_origin = '10.1.0.0\/24'/" ~/.jupyter/jupyter_notebook_config.py # Jupyter listening IP. Set to localhost if only planning on using locally. sed -i "s/#c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '$ipAddress'/" ~/.jupyter/jupyter_notebook_config.py # Whether or not to open browser on jupyter launch. If headless, or server, set to False. sed -i "s/#c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/" ~/.jupyter/jupyter_notebook_config.py # Listening port. Change as necessary sed -i "s/#c.NotebookApp.port = 8888/c.NotebookApp.port = 8888/" ~/.jupyter/jupyter_notebook_config.py # Randomly generated token for access without user/pass sed -i "s/^#c.NotebookApp.token .*/c.NotebookApp.token = '$token'/" ~/.jupyter/jupyter_notebook_config.py # Trash Cleanup sed -i "s/#c.NotebookApp.cookie_secret = b''/#c.NotebookApp.cookie_secret = ''/" ~/.jupyter/jupyter_notebook_config.py sed -i "s/#c.Session.key = b''/#c.Session.key = ''/" ~/.jupyter/jupyter_notebook_config.py sed -i "s/#c.NotebookNotary.secret = b''/#c.NotebookNotary.secret = ''/" ~/.jupyter/jupyter_notebook_config.py echo -e "\n...\e[32mCreating Jupyter Lab service\e[m...\n" cat << EOF | sudo tee /etc/systemd/system/jupyter-lab.service [Unit] Description=Jupyter Lab [Service] Type=simple PIDFile=/run/jupyter.pid ExecStart=/home/$USER/.local/bin/jupyter-lab --config=/home/$USER/.jupyter/jupyter_notebook_config.py WorkingDirectory=$WorkingDirectory User=$USER Group=$USER Restart=always RestartSec=10 #KillMode=mixed [Install] WantedBy=multi-user.target EOF echo -e "\n...\e[32mReloading systemctl daemon after creating service entry\e[m...\n" sudo systemctl daemon-reload echo -e "\n...\e[32mEnabling Jupyter Lab service\e[m...\n" sudo systemctl enable jupyter-lab.service echo -e "\n...\e[32mStarting Jupyter Lab service\e[m...\n" sudo systemctl start jupyter-lab.service echo -e "\n...\e[32mChecking status of Jupyter Lab service\e[m...\n" sudo systemctl status jupyter-lab.service echo -e "\n...\e[32mAtom Hydrogen gateway configuration\e[m...\n" echo "[{\"name\":\"Jupiter Lab - Ubuntu Server 16.04\",\"options\":{\"baseUrl\":\"http://$ipAddress:8888\",\"token\":\"$token\"}}]" echo -e "\n...\e[32mYou should be able to test the installation by opening a browser and opening the below URL\e[m...\n" echo "http://$ipAddress:8888/?token=$token/" -
shr00mie created this gist
Mar 16, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,84 @@ #!/bin/bash # variables read -p $' \e[32mServer static IP address\e[m: ' ipAddress echo -e "\n...\e[32mGenerating random token\e[m..." token=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1) echo -e "\n...\e[32mAdding Jonathon F Python 3.6 PPA\e[m..." sudo add-apt-repository ppa:jonathonf/python-3.6 echo -e "\n...\e[32mUpdating system\e[m..." sudo apt update && sudo apt upgrade -y echo -e "\n...\e[32mInstalling python 3.6, python 3.6 dev, and python-pip\e[m..." sudo apt install python3.6 python3.6-dev python-pip -y echo -e "\n...\e[32mInstall Cleanup\e[m..." sudo apt autoclean && sudo apt autoremove -y echo -e "\n...\e[32mUpgrading pip\e[m..." sudo -H pip install --upgrade pip echo -e "\n...\e[32mInstalling Jupyter\e[m..." sudo -H pip install jupyter echo -e "\n...\e[32mGenerating jupyter config file\e[m..." jupyter-notebook --generate-config echo -e "\n...\e[32mTweaking config file\e[m..." # allow connections from other devices # listen on static IP # don't open browser on start # set port # set token sudo sed -i.back "s/#c.NotebookApp.allow_origin = ''/c.NotebookApp.allow_origin = '*'/ ; s/#c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '$ipAddress'/ ; s/#c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/ ; s/#c.NotebookApp.port = 8888/c.NotebookApp.port = 8888/ ; s/#c.NotebookApp.token = '<generated>'/c.NotebookApp.token = '$token'/" ~/.jupyter/jupyter_notebook_config.py echo -e "\n...\e[32mCreating service user for Jupyter Notebook service\e[m..." sudo adduser -q --system --shell /usr/sbin/nologin --group JupyterNotebook echo -e "\n...\e[32mCreating Jupyter Notebook service\e[m..." cat << EOF | sudo tee /etc/systemd/system/jupyter.service [Unit] Description=Jupyter Notebook Service [Service] Type=simple PIDFile=/run/jupyter.pid ExecStart=/usr/local/bin/jupyter-notebook --config=/home/JupyterNotebook/.jupyter/jupyter_notebook_config.py User=JupyterNotebook Group=JupyterNotebook Restart=always RestartSec=10 #KillMode=mixed [Install] WantedBy=multi-user.target EOF echo -e "\n...\e[32mCopying Jupyter Notebook configuration to service user home directory\e[m..." sudo mkdir /home/JupyterNotebook/.jupyter sudo cp ~/.jupyter/jupyter_notebook_config.py /home/JupyterNotebook/.jupyter/jupyter_notebook_config.py sudo chown JupyterNotebook:JupyterNotebook /home/JupyterNotebook/.jupyter sudo chown JupyterNotebook:JupyterNotebook /home/JupyterNotebook/.jupyter/jupyter_notebook_config.py echo -e "\n...\e[32mReloading systemctl daemon after creating service entry\e[m..." sudo systemctl daemon-reload echo -e "\n...\e[32mEnabling Jupyter Notebook service\e[m..." sudo systemctl enable jupyter.service echo -e "\n...\e[32mStarting Jupyter Notebook service\e[m..." sudo systemctl start jupyter.service echo -e "\n...\e[32mChecking status of Jupyter Notebook service\e[m..." sudo systemctl status jupyter.service echo -e "\n...\e[32mCopy the below entry and paste it into your Atom configuration file under \"Hydrogen:\"\e[m..." echo "gateways: \"[{ \"name\" : \"Jupiter Notebook - Ubuntu Server 16.04\" , \"options\" : { \"baseUrl\" : \"http://$ipAddress:8888\" , \"token\" : \"$token\" } }]\"" echo -e "\n...\e[32mYou should be able to test the installation by opening a browser and opening the below URL\e[m..." echo "http://$ipAddress:8888/?token=$token/"