This repository has been archived by the owner on Jun 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2209 from ryanlovett/update-course-fetch
Extract course profiles from new hub location.
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
aiohttp==3.5.4 | ||
ruamel.yaml==0.16.0 | ||
aiohttp==3.7.3 | ||
ruamel.yaml==0.16.12 | ||
yq==2.12.0 | ||
git+https://github.com/ryanlovett/sis-cli.git@1635650 | ||
git+https://github.com/ryanlovett/ucbhr.git@48975fb |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# set -e | ||
|
||
# all hub configuration | ||
config_values="/etc/jupyterhub/config/values.yaml" | ||
|
||
# output location | ||
profile_dir="/srv/jupyterhub/profiles.d" | ||
|
||
course_emails="/usr/local/bin/course-emails.py" | ||
|
||
# space 24 hours apart; TODO: guessing k8s can loop this for us somehow | ||
sleep_time=86400 | ||
|
||
while true ; do | ||
|
||
if [ ! -f $custom_profiles ]; then | ||
echo "No such file: $custom_profiles" | ||
else | ||
|
||
if [ ! -d $profile_dir ]; then mkdir -p $profile_dir ; fi | ||
|
||
profiles=`cat ${config_values} | yq .custom.profiles | jq -r 'keys[]'` | ||
echo profiles: ${profiles} | ||
|
||
# write out email lists for each profile | ||
for profile in ${profiles} ; do | ||
for people in students instructors ; do | ||
filename="${profile_dir}/${profile}-${people}.txt" | ||
# write to tempfile because gathering addresses takes time | ||
# and we don't want the hub to read an abbreviated list | ||
outfile=`mktemp` | ||
echo $profile $people $outfile | ||
$course_emails $profile $people > $outfile | ||
if [ -f $outfile ]; then mv $outfile $filename ; fi | ||
done | ||
done | ||
fi | ||
|
||
sleep $sleep_time | ||
done |