aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2023-10-17 21:05:01 +0200
committerMarvin Borner2023-10-17 21:05:01 +0200
commitb0fb8392227844e895b0c4f2fb6d2cd60956136e (patch)
tree41bf23d1385336af1027875041e6b18639566459
Added filesHEADmain
-rw-r--r--config/eduroam.8021x10
-rw-r--r--readme.md18
-rwxr-xr-xscripts/almanot24
-rwxr-xr-xscripts/iliasnot64
4 files changed, 116 insertions, 0 deletions
diff --git a/config/eduroam.8021x b/config/eduroam.8021x
new file mode 100644
index 0000000..1e77900
--- /dev/null
+++ b/config/eduroam.8021x
@@ -0,0 +1,10 @@
+[Security]
+EAP-Method=PEAP
+EAP-Identity=zx...
+EAP-PEAP-CACert=/opt/eduroam.crt
+EAP-PEAP-Phase2-Method=MSCHAPV2
+EAP-PEAP-Phase2-Identity=zx...@uni-tuebingen.de
+EAP-PEAP-Phase2-Password-Hash=...
+
+[Settings]
+AutoConnect=true
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..b33d3e5
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,18 @@
+# Tools/config for University of Tübingen
+
+## Config
+
+- eduroam for iwd: Move `eduroam.8021x` to `/var/lib/iwd/`. Move the
+ public certificate `eduroam.crt` to `/opt/eduroam.crt`. Don't forget
+ to assign the correct permissions.
+
+## Scripts
+
+- `almanot`: Get notifications if something on Alma changes. Uses the
+ official RSS feed endpoint.
+- `iliasnot`: Get notifications for changes of course pages.
+ *UNOFFICIAL* scraping method, only use this script if you have
+ permission to scrape the website!
+
+Then `crontab -e` and `*/10 * * * * <PATH>/almanot` to check every 10
+minutes.
diff --git a/scripts/almanot b/scripts/almanot
new file mode 100755
index 0000000..e24934f
--- /dev/null
+++ b/scripts/almanot
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -e
+
+# for crontab support
+export XAUTHORITY=/home/melvin/.Xauthority
+export DISPLAY=:0
+export XDG_RUNTIME_DIR=/run/user/1000
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
+
+# link to rss feed (Startseite > Service > Persönliche Einstellungen > Kommunikationskanäle anpassen > Feed > abonnieren)
+url="..."
+
+wget -q "$url" -O /tmp/webchange_new
+
+# xq needs python-yq
+xq '.["rdf:RDF"].item.[].title' </tmp/webchange_new | sponge /tmp/webchange_new_diff
+xq '.["rdf:RDF"].item.[].title' </tmp/webchange_current | sponge /tmp/webchange_current_diff
+
+if ! cmp -s /tmp/webchange_new_diff /tmp/webchange_current_diff >/dev/null; then
+ notify-send -t 0 -u critical "ALMA changed!" "$(date)"
+fi
+
+mv /tmp/webchange_new /tmp/webchange_current
diff --git a/scripts/iliasnot b/scripts/iliasnot
new file mode 100755
index 0000000..1ff9bf6
--- /dev/null
+++ b/scripts/iliasnot
@@ -0,0 +1,64 @@
+#!/bin/python3
+# WARNING: Only use this if you are allowed to scrape ILIAS!
+
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+import time
+import subprocess
+
+driver = webdriver.Chrome()
+
+driver.get("https://ovidius.uni-tuebingen.de")
+driver.find_element(By.ID, "shib_login_link").click()
+driver.find_element(By.ID, "username").send_keys("zx...")
+driver.find_element(By.ID, "password").send_keys("...")
+driver.find_elements(By.CLASS_NAME, "form-button")[0].click()
+
+courses = [
+ {
+ "name": "...",
+ "url": "https://ovidius.uni-tuebingen.de/ilias3/goto.php?target=...&client_id=pr02",
+ "last": [],
+ },
+]
+
+while True:
+ for course in courses:
+ driver.get(course["url"])
+ rows = driver.find_elements(By.CLASS_NAME, "ilObjListRow")
+
+ elements = []
+ for row in rows:
+ title = row.find_elements(
+ By.CSS_SELECTOR, "a.il_ContainerItemTitle"
+ )[0].text
+ descs = [
+ x.text
+ for x in row.find_elements(By.CLASS_NAME, "il_Description")
+ ]
+ props = [
+ x.text
+ for x in row.find_elements(
+ By.CSS_SELECTOR, "span.il_ItemProperty"
+ )
+ ]
+ s = title + " - " + (" ".join(descs)) + (" ".join(props))
+ elements.append(s)
+
+ diffs = [item for item in elements if item not in course["last"]]
+ local = time.localtime()
+ time_txt = time.strftime("%I:%M:%S", local)
+ if len(diffs) > 0 and len(course["last"]) > 0:
+ print(f'{time_txt}: {course["name"]}: CHANGES', "\n".join(diffs))
+ subprocess.Popen(
+ [
+ "notify-send",
+ "ILIAS CHANGES " + course["name"],
+ "".join(diffs),
+ ]
+ )
+ else:
+ print(f'{time_txt}: {course["name"]}: No changes')
+ course["last"] = elements
+ time.sleep(1)
+ time.sleep(60)