Last active
November 13, 2024 15:05
-
-
Save sallysooo/529f1f02a68ee0a99f26319b2cb532ba to your computer and use it in GitHub Desktop.
script for installing jupyterhub in Rocky Linux
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 characters
#!/bin/bash | |
echo "Updating system packages..." | |
dnf -y update | |
echo "Install JupyterHub and Libraries..." | |
dnf install -y python3-pip npm | |
npm install -g configurable-http-proxy | |
pip install jupyterhub jupyterlab notebook | |
echo "Creating JupyterHub configuration files..." | |
mkdir -p /etc/jupyterhub | |
jupyterhub --generate-config | |
mv jupyterhub_config.py /etc/jupyterhub/ | |
echo "Editing JupyterHub configuration files..." | |
echo "c.Authenticator.allow_all = True" >> /etc/jupyterhub/jupyterhub_config.py | |
echo "c.JupyterHub.ip = ''" >> /etc/jupyterhub/jupyterhub_config.py | |
echo "Updating firewall rules..." | |
firewall-cmd --permanent --add-port=8000/tcp | |
firewall-cmd --reload | |
echo "Creating JupyterHub systemd service..." | |
cat << EOF > /etc/systemd/system/jupyterhub.service | |
[Unit] | |
Description=JupyterHub service | |
After=syslog.target network.target | |
[Service] | |
User=root | |
Type=simple | |
WorkingDirectory=/etc/jupyterhub | |
ExecStart=/usr/local/bin/jupyterhub --config=/etc/jupyterhub/jupyterhub_config.py | |
ExecStop=/usr/bin/pkill -f jupyterhub | |
Restart=always | |
TimeoutStartSec=60 | |
RestartSec=60 | |
StandardOutput=syslog | |
StandardError=syslog | |
SyslogIdentifier=jupyterhub | |
[Install] | |
WantedBy=multi-user.target network-online.target | |
EOF | |
echo "Starting JupyterHub service..." | |
systemctl daemon-reload | |
systemctl enable jupyterhub | |
systemctl start jupyterhub | |
echo "Checking JupyterHub service status..." | |
systemctl status jupyterhub | |
echo "JupyterHub installation complete. Service is now running." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment