mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 13:46:32 +00:00
Dehydrated: add libexec helpers
This commit is contained in:
parent
24200be6a2
commit
822c04d424
27
board/common/overlay/usr/libexec/dehydrated-dumb-httpd
Executable file
27
board/common/overlay/usr/libexec/dehydrated-dumb-httpd
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
CHALLENGE="$1"
|
||||
PORT=80
|
||||
LIFETIME=10
|
||||
|
||||
if [[ -z "${CHALLENGE}" ]]; then
|
||||
echo "Usage $0 <challenge>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function make_response() {
|
||||
echo -en "HTTP/1.1 200 OK\r\n"
|
||||
echo -en "Content-Length: ${#CHALLENGE}\r\n"
|
||||
echo -en "Content-Type: text/plain\r\n"
|
||||
echo -en "Connection: close\r\n\r\n${CHALLENGE}"
|
||||
}
|
||||
|
||||
start_time=$(date +%s)
|
||||
echo "Dumb httpd started"
|
||||
while true; do
|
||||
make_response | nc -l -w "${LIFETIME}" -p ${PORT} >/dev/null
|
||||
if (( $(date +%s) - ${start_time} > ${LIFETIME} )); then
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "Dumb httpd exit"
|
15
board/common/overlay/usr/libexec/dehydrated-hook
Executable file
15
board/common/overlay/usr/libexec/dehydrated-hook
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
SSL_DIR="/data/etc/ssl"
|
||||
CERT_FILE="${SSL_DIR}/cert.pem"
|
||||
KEY_FILE="${SSL_DIR}/privkey.pem"
|
||||
|
||||
if [[ "$1" == "deploy_challenge" ]]; then
|
||||
/usr/libexec/dehydrated-dumb-httpd "$4" &
|
||||
elif [[ "$1" == "deploy_cert" ]]; then
|
||||
logger -t dehydrated "deploying certificate & rebooting"
|
||||
mkdir -p "${SSL_DIR}"
|
||||
cp "$3" "${KEY_FILE}"
|
||||
cp "$4" "${CERT_FILE}"
|
||||
reboot
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user