My evakool fridge comes with an app that connects over WiFi to a proprietary TCP service. ie: not HTTP.
The Android app that talks to this TCP service is shit.
I'm going to attempt to make a less shit app.
ARG USERNAME | |
ARG WSL_DISTRO_NAME | |
RUN mv /home /home-tpl | |
COPY ./mount-home.ts /usr/bin/mount-home.ts | |
RUN deno cache /usr/bin/mount-home.ts | |
RUN chmod +x /usr/bin/mount-home.ts | |
RUN sed -i "s/%USERNAME%/$(printf '%s\n' "$USERNAME" | sed -e 's/[\/&]/\\&/g')/g" /usr/bin/mount-home.ts | |
RUN sed -i "s/%WSL_DISTRO_NAME%/$(printf '%s\n' "$WSL_DISTRO_NAME" | sed -e 's/[\/&]/\\&/g')/g" /usr/bin/mount-home.ts | |
COPY ./mount-home.service /usr/lib/systemd/system/mount-home.service | |
RUN systemctl enable mount-home.service |
#!/bin/bash | |
exec deno run --cached-only -qA /usr/bin/xdg-open.ts "$@" |
const { syscall, getAddress } = require("libsys"); | |
const os = require("os"); | |
if (os.endianess() != "LE") | |
throw "only little endian supported"; | |
let dontGC = []; | |
function ref(buffer) { | |
dontGC.push(buffer); | |
return getAddress(buffer); |
I'm buiding a command line tool in Go that has an option to install itself as a service on Windows, which it needs admin rights for. I wanted to be able to have it reliably detect if it was running as admin already and if not, relaunch itself as admin. When the user runs the tool with the specific switch to trigger this functionality (-install or -uninstall in my case) they are prompted by UAC (User Account Control) to run the program as admin, which allows the tool to relaunch itself with the necessary rights.
To detect if I was admin, I tried the method described here first:
https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/
This wasn't accurately detecting that I was elevated, and was reporting that I was not elevated even when running the tool in CMD prompt started with "Run as Administrator" so I needed a more reliable method.
I didn't want to try writing to an Admin protected area of the filesystem or registry because Windows has the ability to transparently virtualize those writes
RUN export BUILD_PACKAGES="gnupg curl ca-certificates apt-transport-https" \ | |
&& export EXISTING_PACKAGES="$(mktemp)" && apt-mark showauto | sort > $EXISTING_PACKAGES \ | |
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_PACKAGES \ | |
&& export NEW_PACKAGES="$(mktemp)" && apt-mark showauto | sort > $NEW_PACKAGES \ | |
&& export PACKAGES_TO_REMOVE="$(comm -23 $NEW_PACKAGES $EXISTING_PACKAGES)" \ | |
\ | |
&& mkdir -p /usr/share/man/man1 \ | |
&& curl -s https://apt.corretto.aws/corretto.key | apt-key add - \ | |
&& echo 'deb https://apt.corretto.aws stable main' > /etc/apt/sources.list.d/corretto.list \ | |
&& apt-get update && apt-get install -y --no-install-recommends java-1.8.0-amazon-corretto-jdk \ |
cmdkey /generic:"TERMSRV/{{IP_OR_HOSTNAME}}" /user:"{{USERNAME}}" /pass:"{{PASSWORD}}"; mstsc.exe /v:"{{IP_OR_HOSTNAME}}"; cmdkey /delete:"TERMSRV/{{IP_OR_HOSTNAME}}"; |
I hereby claim:
To claim this, I am signing this object:
FROM alpine:latest AS devel | |
RUN apk --no-cache add git | |
RUN mkdir /app | |
RUN touch /app/foo | |
FROM scratch AS runtime | |
COPY --from=devel /app/. /app |