Skip to content

Commit

Permalink
Add juphub-utils to base image
Browse files Browse the repository at this point in the history
Signed-off-by: Isaiah Stapleton <istaplet@redhat.com>
  • Loading branch information
IsaiahStapleton committed Jan 17, 2024
1 parent e417c31 commit f14aa14
Show file tree
Hide file tree
Showing 17 changed files with 182 additions and 0 deletions.
2 changes: 2 additions & 0 deletions containers/testing/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ RUN /usr/local/bin/start.sh true; \

COPY start-notebook.d /usr/local/bin/start-notebook.d

COPY juphub-utils /opt/app-root/src/juphub-utils

ENV USER=$NB_USER

# Change the ownership of the home directory to ope group so it starts up properly
Expand Down
14 changes: 14 additions & 0 deletions containers/testing/base/juphub-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# JUPYER HUB utilities

This is a repo that contains a set of scripts that codify how I use jupyterhub
bu book instances where home directories are not persistent

Clone this repo as bin in your persistent directory and then source the setup script


```
cd /opt/app-root/src
git clone https://github.com/jappavoo/juphub-utils.git
./juphub-utils/setup.sh
```

13 changes: 13 additions & 0 deletions containers/testing/base/juphub-utils/dowork
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
if [[ ! -a ~/Work && -a /opt/app-root/src ]]; then
echo "linking: ln -s /opt/app-root/src ~/Work"
ln -s /opt/app-root/src ~/Work
fi

. sshagent.sh

#watchmem

echo "do this"
echo ". $ENVFILE"

3 changes: 3 additions & 0 deletions containers/testing/base/juphub-utils/findtree
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

find $@ | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
1 change: 1 addition & 0 deletions containers/testing/base/juphub-utils/ft
2 changes: 2 additions & 0 deletions containers/testing/base/juphub-utils/myaliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alias gl="git log --decorate --oneline --graph"
alias gll="gl --all"
14 changes: 14 additions & 0 deletions containers/testing/base/juphub-utils/myjupyter_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if [[ -d /opt/app-root/src/juphub-utils ]]; then
cat >>~/.profile <<EOF
# add persistent user bin to path
if [[ -d /opt/app-root/src/juphub-utils ]]; then
export PATH=/opt/app-root/src/juphub-utils:\$PATH
fi
EOF

# Kludge when running locally profile is started before startup hook so we
# explicitly add to path here
export PATH=/opt/app-root/src/juphub-utils:$PATH

fi
12 changes: 12 additions & 0 deletions containers/testing/base/juphub-utils/pubbk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
BASEDIR=${BASEDIR:-/opt/app-root/src}
UCDIR=${UCDIR:-${BASEDIR}/UndertheCovers}
DEST=${DEST:-jappavoo@csa2.bu.edu:www/UC/textbook/}

if [[ -d ${UCDIR} ]]; then
rsync -azq --delete ${UCDIR}/textbook/_build/html/ ${DEST}
else
echo "ERROR: can't find directory: $UCDIR"
exit -1
fi
exit $?
39 changes: 39 additions & 0 deletions containers/testing/base/juphub-utils/reenable_jup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

JUPY_EXTS="@jupyterlab/fileeditor-extension:plugin
@jupyterlab/filebrowser-extension:widget
@jupyterlab/filebrowser-extension:browser
@jupyterlab/filebrowser-extension:download
@jupyterlab/filebrowser-extension:open-browser-tab
@jupyterlab/filebrowser-extension:open-with
@jupyterlab/console-extension:tracker
@jupyterlab/console-extension:foreign
@jupyterlab/debugger-extension:main
@jupyterlab/extensionmanager-extension:plugin
@jupyterlab/launcher-extension:plugin
@jupyterlab/apputils-extension:palette
@jupyterlab/logconsole-extension:plugin
@jupyterlab/codemirror-extension:commands
@jupyterlab/inspector-extension:consoles
@jupyterlab/inspector-extension:inspector
@jupyterlab/inspector-extension:notebooks
@jupyterlab/shortcuts-extension:shortcuts"

for ext in ${JUPY_EXTS}; do
echo "Enabling: $ext"
jupyter labextension enable $ext
done

echo "resetting /opt/conda/share/jupyter/lab/settings/overrides.json"
cat <<EOF > /opt/conda/share/jupyter/lab/settings/overrides.json
{
"@jupyterlab/terminal-extension:plugin": {
"shutdownOnClose": true
},
"@jupyterlab/statusbar-extension:plugin": {
"visible": false
}
}
EOF

echo "reload jupyterlab webpage for new setting to take effect"
1 change: 1 addition & 0 deletions containers/testing/base/juphub-utils/rejup
1 change: 1 addition & 0 deletions containers/testing/base/juphub-utils/sa
19 changes: 19 additions & 0 deletions containers/testing/base/juphub-utils/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# script to run after cloning the this repo
# will install the startup hook script that
# is part of this repo

BASEDIR=${BASEDIR:-/opt/app-root/src}
STARTUPHOOK=${BASEDIR}/.myjupyter_start.sh
MYDIR=$(readlink -f $0)
MYDIR=$(dirname $MYDIR)
STARTUPHOOKSRC=${MYDIR}/myjupyter_start.sh

if [[ ! -a ${STARTUPHOOK} ]]; then
if [[ -a ${STARTUPHOOKSRC} ]]; then
ln -s ${STARTUPHOOKSRC} ${STARTUPHOOK}
else
echo "ERROR: can't find ${STARTUPHOOKSRC}"
exit -1
fi
fi
21 changes: 21 additions & 0 deletions containers/testing/base/juphub-utils/spin
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
#set -x
duration=${1:-1.5}
delay=${2:-10}
typeset -i loops=$(echo "(60*60*$duration)/($delay*4)" | bc)
#echo "loops=$loops"; sleep 1
for ((i=0; i<loops; i++)); do
clear
echo -n "|";
sleep $delay;
clear;
echo -n "/";
sleep $delay;
clear;
echo -n "-";
sleep $delay;
clear;
echo -n "\\";
sleep $delay;
done
echo
17 changes: 17 additions & 0 deletions containers/testing/base/juphub-utils/sshagent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#set -x
ENVFILE=~/.sa.env

if [[ ! -a ~/.sa.env ]]; then
ssh-agent > $ENVFILE
. $ENVFILE
ssh-add
if ! grep -q $ENVFILE ~/.bashrc ; then
cat >> ~/.bashrc <<EOF
# sourcing $ENVFILE if it exits
[[ -a $ENVFILE ]] && . $ENVFILE > /dev/null
EOF
fi
else
. $ENVFILE
fi
11 changes: 11 additions & 0 deletions containers/testing/base/juphub-utils/validateASLR
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

count=$(for ((i=0;i<100; i++)); do gdb -ex starti -ex quit -q --batch /usr/bin/date 2>/dev/null | grep ld; done | tee out | uniq | wc -l)

if [[ $count == 1 ]]; then
echo "OK: Looks good"
exit 0
else
echo "ERROR: Failed to start a binary with a constant instruction addres: $count"
exit -1
fi
9 changes: 9 additions & 0 deletions containers/testing/base/juphub-utils/watchmem
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
MYDIR=$(readlink -f $0)
MYDIR=$(dirname $MYDIR)

#echo $MYDIR

# from Erwan Granger @ Redhat

watch " ps -eo size,command --sort -size | awk '{ hr=\$1/1024 ; sum +=hr} END {print sum \" MB of memory used\" }' | tee $MYDIR/watchmem.last"
3 changes: 3 additions & 0 deletions containers/testing/base/juphub-utils/whatjup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
env | grep -i hub_host
env | grep -i image

0 comments on commit f14aa14

Please sign in to comment.