Actually works decently now
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
parent
fba2ed646e
commit
01df9cc6dc
7 changed files with 32 additions and 31 deletions
|
@ -1,3 +1,3 @@
|
||||||
FROM python:slim-bookworm
|
FROM python:3.12-slim-bookworm
|
||||||
RUN apt update && apt install -y pandoc
|
RUN apt update && apt install -y pandoc
|
||||||
CMD ["/data/run.sh"]
|
CMD ["/data/run.sh"]
|
13
README.md
13
README.md
|
@ -19,7 +19,18 @@ This puts the output of `dd` into a file, which is then read and made into a web
|
||||||
`docker run`:
|
`docker run`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run -it --rm --restart unless-stopped -v .:/data registry.askiiart.net/askiiart/feed-the-void
|
docker run -d --restart unless-stopped -v .:/data --cpus 0.25 registry.askiiart.net/askiiart/feed-the-void
|
||||||
|
docker run -d --restart unless-stopped -v ./site-files:/usr/share/nginx/html -p 8080:80 nginx:alpine-slim
|
||||||
```
|
```
|
||||||
|
|
||||||
`docker-compose.yml`: See [docker-compose.yml](docker-compose.yml)
|
`docker-compose.yml`: See [docker-compose.yml](docker-compose.yml)
|
||||||
|
|
||||||
|
## Running it manually
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
- Python 3.12 or later
|
||||||
|
- `pandoc`
|
||||||
|
- `sed`
|
||||||
|
- `dd`
|
||||||
|
- `/dev/zero` and `/dev/null`
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# From https://stackoverflow.com/a/25755038
|
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
|
||||||
from os import remove
|
|
||||||
|
|
||||||
shell = Popen(['dd', 'if=/dev/zero', 'of=/dev/null', 'status=progress'],
|
|
||||||
stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=1)
|
|
||||||
|
|
||||||
try:
|
|
||||||
remove('output')
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
for line in iter(shell.stdout.readline, b''):
|
|
||||||
f = open('output', 'w')
|
|
||||||
if (line.strip() != ''): # Ignore empty lines (always 1 at the start)
|
|
||||||
line = line.rstrip()
|
|
||||||
#print(line)
|
|
||||||
f.write(line)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
f.close()
|
|
||||||
exit()
|
|
15
dd-progress-to-html.py
Executable file
15
dd-progress-to-html.py
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# From https://stackoverflow.com/a/25755038
|
||||||
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
|
from os import remove, system
|
||||||
|
|
||||||
|
BASE_DIR = '/data'
|
||||||
|
SITE_FILES_DIR = f'{BASE_DIR}/site-files'
|
||||||
|
system(f'pandoc -f markdown-smart --data-dir . --template {SITE_FILES_DIR}/template.html -t html -o {SITE_FILES_DIR}/tmp.html {SITE_FILES_DIR}/index.md --metadata title="$(grep -m 1 -oP \'(?<=^# ).*\' {SITE_FILES_DIR}/index.md | cat)"')
|
||||||
|
system(f'sed -i "s/sourceCode /language-/g" {SITE_FILES_DIR}/tmp.html')
|
||||||
|
|
||||||
|
shell = Popen(['dd', 'if=/dev/zero', 'of=/dev/null', 'status=progress'],
|
||||||
|
stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=1)
|
||||||
|
|
||||||
|
for line in iter(shell.stdout.readline, b''):
|
||||||
|
system(f'sed "s/output here/{line.strip().replace("/", "\\/")}/g" {SITE_FILES_DIR}/tmp.html >{SITE_FILES_DIR}/index.html')
|
|
@ -5,6 +5,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- .:/data
|
- .:/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
cpus: 0.25 # will use 25% of a single core, can be lowered if needed. if you don't set a CPU limit, it'll probably pin a single core the entire time it runs
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine-slim
|
image: nginx:alpine-slim
|
||||||
|
|
3
run.sh
3
run.sh
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
$dir/dd-progress-to-file.py &
|
$dir/dd-progress-to-html.py
|
||||||
$dir/site-files/make-page.sh
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta content="width=device-width, initial-scale=1" charset="utf-8" />
|
<meta content="width=device-width, initial-scale=1" charset="utf-8" />
|
||||||
<link rel="icon" href="feed-the-void.png" type="image/icon">
|
<link rel="icon" href="feed-the-void.png" type="image/icon">
|
||||||
<meta http-equiv="refresh" content="5" />
|
<meta http-equiv="refresh" content="3" />
|
||||||
<title>F E E D T H E V O I D</title>
|
<title>F E E D T H E V O I D</title>
|
||||||
<link href="prism.min.css" rel="stylesheet" />
|
<link href="prism.min.css" rel="stylesheet" />
|
||||||
<link href="style.min.css" rel="stylesheet" />
|
<link href="style.min.css" rel="stylesheet" />
|
||||||
|
@ -29,6 +29,6 @@
|
||||||
<script src="prism.js"></script>
|
<script src="prism.js"></script>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
<footer>
|
||||||
<p><a href="https://git.askiiart.net/askiiart/feed-the-void">code</a> | <b>this page refreshes every 5 seconds</b></p>
|
<p><a href="https://git.askiiart.net/askiiart/feed-the-void">code</a> | <b>this page refreshes every 3 seconds</b></p>
|
||||||
</footer>
|
</footer>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue