-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-screenshot.sh
executable file
·44 lines (35 loc) · 1.07 KB
/
update-screenshot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Grab the database
wget https://datasette.io/content.db
# Delete the triggers on the licenses table
sqlite3 content.db "DROP TRIGGER IF EXISTS licenses_ai"
sqlite3 content.db "DROP TRIGGER IF EXISTS licenses_ad"
sqlite3 content.db "DROP TRIGGER IF EXISTS licenses_au"
# Setup the root plugin
mkdir shot-plugins
cat > shot-plugins/root.py <<EOL
from datasette import hookimpl, Response
@hookimpl
def register_routes():
def login_as_root(datasette, request):
response = Response.redirect("/-/edit-schema/content/licenses")
response.set_cookie(
"ds_actor", datasette.sign({"a": {"id": "root"}}, "actor")
)
return response
return (
("/-/root", login_as_root),
)
EOL
# Start the server in the background and capture its PID
datasette -p 8045 content.db --plugins-dir shot-plugins &
SERVER_PID=$!
# Wait for server to start
sleep 2
# Take the screenshot
shot-scraper http://localhost:8045/-/root -w 800 -o datasette-edit-schema.png
# Kill the server
kill $SERVER_PID
# Cleanup
rm content.db
rm -rf shot-plugins