summaryrefslogtreecommitdiffstats
path: root/prog/jelka
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xprog/jelka/chroot.sh4
-rwxr-xr-xprog/jelka/daemon.py7
-rw-r--r--prog/jelka/jelka_hardware.py2
-rwxr-xr-xprog/jelka/wrapper.py2
4 files changed, 9 insertions, 6 deletions
diff --git a/prog/jelka/chroot.sh b/prog/jelka/chroot.sh
index cf6a1da..b55645e 100755
--- a/prog/jelka/chroot.sh
+++ b/prog/jelka/chroot.sh
@@ -1,9 +1,9 @@
#!/bin/bash
set -xeuo pipefail
-mkdir -p $2
-mount -t tmpfs -o nr_blocks=1,mode=0755 tmp $2
if [ x$1 = xstart ]
then
+ mkdir -p $2
+ mount -t tmpfs -o nr_blocks=1,mode=0755 tmp $2
for i in /bin /dev/null /etc /lib /usr
do
[ -d $i ] && mkdir -p $2/$i || { mkdir -p $2/`rev <<<$i | cut -d/ -f2- | rev` && touch $2/$i; }
diff --git a/prog/jelka/daemon.py b/prog/jelka/daemon.py
index a288f35..badae36 100755
--- a/prog/jelka/daemon.py
+++ b/prog/jelka/daemon.py
@@ -67,7 +67,7 @@ def update_preflight(koda):
return flask.Response("", status=204, headers={"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, OPTIONS", "Access-Control-Allow-Headers": "Content-Type", "Access-Control-Max-Age": "86400"})
def kode():
- return [base64.b64encode(hashlib.sha256(skrivnost+bytes(str(int(time.time()/1000)), encoding="utf-8")).digest()).replace(b"/", b"").replace(b"+", b"")[:4].lower().decode(), base64.b64encode(hashlib.sha256(skrivnost+bytes(str(int(time.time()/1000)-1), encoding="utf-8")).digest()).replace(b"/", b"").replace(b"+", b"")[:4].lower().decode()]
+ return [base64.b64encode(hashlib.sha256(skrivnost+bytes(str(int(time.time()/1000)), encoding="utf-8")).digest()).replace(b"/", b"").replace(b"+", b"")[:4].lower().decode(), base64.b64encode(hashlib.sha256(skrivnost+bytes(str(int(time.time()/1000)-1), encoding="utf-8")).digest()).replace(b"/", b"").replace(b"+", b"")[:4].lower().decode(), os.getenv("KODA")]
def zaznaj_smrt():
proces.wait()
@@ -98,5 +98,8 @@ začni_vzorec = threading.Event()
sprememba_stanja = threading.Event()
if __name__ == "__main__":
- threading.Thread(target=lambda: http.run(host="::", port=6969, debug=True, use_reloader=False)).start()
+ port = 6969
+ if os.getenv("PORT"):
+ port = int(os.getenv("PORT"))
+ threading.Thread(target=lambda: http.run(host="::", port=port, debug=True, use_reloader=False)).start()
threading.Thread(target=subprocess_manager).start()
diff --git a/prog/jelka/jelka_hardware.py b/prog/jelka/jelka_hardware.py
index 7361ed7..effee52 100644
--- a/prog/jelka/jelka_hardware.py
+++ b/prog/jelka/jelka_hardware.py
@@ -10,7 +10,7 @@ LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
-luči = LED_COUNT
+luči = jelka_config.luči
strip = PixelStrip(luči, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
strip.begin()
diff --git a/prog/jelka/wrapper.py b/prog/jelka/wrapper.py
index 4e496c7..4b287a7 100755
--- a/prog/jelka/wrapper.py
+++ b/prog/jelka/wrapper.py
@@ -47,7 +47,7 @@ env["PWD"] = cwd
env["USER"] = pw_record.pw_name
env["PYTHONPATH"] = "/jelka"
process = subprocess.Popen(
- args, preexec_fn=demote(pw_record.pw_uid, pw_record.pw_uid, os.path.abspath("chroot")), cwd=cwd, env=env, pass_fds=[w]
+ args, preexec_fn=demote(pw_record.pw_uid, pw_record.pw_gid, os.path.abspath("chroot")), cwd=cwd, env=env, pass_fds=[w]
)
try:
while io.FileIO(r, closefd=False).read(1):