mirror of
https://github.com/AuxXxilium/arv-v-dsm.git
synced 2024-11-23 23:10:58 +07:00
feat: Store config in RAM (#559)
This commit is contained in:
parent
3a507f5bf6
commit
575da1f574
@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
[ -f "/run/qemu.end" ] && echo "QEMU is shutting down.." && exit 1
|
||||
[ ! -f "/run/qemu.pid" ] && echo "QEMU is not running yet.." && exit 0
|
||||
[ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1
|
||||
[ ! -f "/run/shm/qemu.pid" ] && echo "QEMU is not running yet.." && exit 0
|
||||
|
||||
file="/run/dsm.url"
|
||||
address="/run/qemu.ip"
|
||||
file="/run/shm/dsm.url"
|
||||
address="/run/shm/qemu.ip"
|
||||
|
||||
[ ! -f "$file" ] && echo "DSM has not enabled networking yet.." && exit 1
|
||||
|
||||
|
@ -139,7 +139,7 @@ if [ -f "$RDC" ]; then
|
||||
(( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92
|
||||
fi
|
||||
|
||||
mkdir -p /run/extract
|
||||
rm -rf /run/extract && mkdir -p /run/extract
|
||||
for file in $TMP/usr/lib/libcurl.so.4 \
|
||||
$TMP/usr/lib/libmbedcrypto.so.5 \
|
||||
$TMP/usr/lib/libmbedtls.so.13 \
|
||||
@ -211,6 +211,7 @@ else
|
||||
|
||||
fi
|
||||
|
||||
rm -rf /run/extract
|
||||
info "Install: Preparing system partition..."
|
||||
|
||||
BOOT=$(find "$TMP" -name "*.bin.zip")
|
||||
@ -275,15 +276,8 @@ PKG="$TMP/packages"
|
||||
HDP="$TMP/synohdpack_img"
|
||||
|
||||
[ ! -f "$HDA.tgz" ] && error "The PAT file contains no OS image." && exit 64
|
||||
|
||||
mv "$HDA.tgz" "$HDA.txz"
|
||||
|
||||
if [[ "$ROOT" != [Nn]* ]]; then
|
||||
|
||||
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
|
||||
|
||||
fi
|
||||
|
||||
[ -d "$PKG" ] && mv "$PKG/" "$MOUNT/.SynoUpgradePackages/"
|
||||
rm -f "$MOUNT/.SynoUpgradePackages/ActiveInsight-"*
|
||||
|
||||
@ -301,6 +295,8 @@ NUMBLOCKS="622560" # (4980480 * 512) / 4096
|
||||
|
||||
if [[ "$ROOT" != [Nn]* ]]; then
|
||||
|
||||
tar xpfJ "$HDA.txz" --absolute-names --skip-old-files -C "$MOUNT/"
|
||||
|
||||
info "Install: Installing system partition..."
|
||||
|
||||
mke2fs -q -t ext4 -b 4096 -d "$MOUNT/" -L "$LABEL" -F -E "offset=$OFFSET" "$SYSTEM" "$NUMBLOCKS"
|
||||
|
@ -218,7 +218,7 @@ getInfo() {
|
||||
|
||||
GATEWAY=$(ip r | grep default | awk '{print $3}')
|
||||
IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
|
||||
echo "$IP" > /run/qemu.ip
|
||||
echo "$IP" > /run/shm/qemu.ip
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ API_HOST="127.0.0.1:2210"
|
||||
QEMU_TERM=""
|
||||
QEMU_PORT=7100
|
||||
QEMU_TIMEOUT=50
|
||||
QEMU_PID="/run/qemu.pid"
|
||||
QEMU_LOG="/run/qemu.log"
|
||||
QEMU_OUT="/run/qemu.out"
|
||||
QEMU_END="/run/qemu.end"
|
||||
QEMU_PID="/run/shm/qemu.pid"
|
||||
QEMU_LOG="/run/shm/qemu.log"
|
||||
QEMU_OUT="/run/shm/qemu.out"
|
||||
QEMU_END="/run/shm/qemu.end"
|
||||
|
||||
if [[ "$KVM" == [Nn]* ]]; then
|
||||
API_TIMEOUT=$(( API_TIMEOUT*2 ))
|
||||
|
@ -6,9 +6,9 @@ set -Eeuo pipefail
|
||||
info () { printf "%b%s%b" "\E[1;34m❯ \E[1;36m" "$1" "\E[0m\n" >&2; }
|
||||
error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: $1" "\E[0m\n" >&2; }
|
||||
|
||||
file="/run/dsm.url"
|
||||
address="/run/qemu.ip"
|
||||
shutdown="/run/qemu.end"
|
||||
file="/run/shm/dsm.url"
|
||||
address="/run/shm/qemu.ip"
|
||||
shutdown="/run/shm/qemu.end"
|
||||
url="http://127.0.0.1:2210/read?command=10"
|
||||
|
||||
resp_err="Guest returned an invalid response:"
|
||||
|
19
src/reset.sh
19
src/reset.sh
@ -31,17 +31,24 @@ VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
|
||||
# Check folder
|
||||
|
||||
STORAGE="/storage"
|
||||
[ ! -d "$STORAGE" ] && error "Storage folder ($STORAGE) not found!" && exit 13
|
||||
if [ ! -d "$STORAGE" ]; then
|
||||
error "Storage folder ($STORAGE) not found!" && exit 13
|
||||
fi
|
||||
|
||||
if [ ! -d "/run/shm" ]; then
|
||||
if [ -d "/dev/shm" ]; then
|
||||
ln -s /dev/shm /run/shm
|
||||
else
|
||||
error "Folder /dev/shm not found!" && exit 14
|
||||
fi
|
||||
fi
|
||||
|
||||
# Cleanup files
|
||||
|
||||
rm -f /run/dsm.url
|
||||
rm -f /run/qemu.*
|
||||
rm -f /run/shm/qemu.*
|
||||
rm -f /run/shm/dsm.url
|
||||
|
||||
# Cleanup dirs
|
||||
|
||||
rm -rf /tmp/dsm
|
||||
rm -f /tmp/server.*
|
||||
rm -rf "$STORAGE/tmp"
|
||||
|
||||
# Helper functions
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
TMP_FILE=$(mktemp -q /tmp/server.XXXXXX)
|
||||
TMP_FILE=$(mktemp -q /run/shm/server.XXXXXX)
|
||||
|
||||
stop() {
|
||||
trap - SIGINT EXIT
|
||||
@ -53,7 +53,7 @@ else
|
||||
HTML=$(html "xxx")
|
||||
|
||||
{ echo "#!/bin/bash"
|
||||
echo "[ -f \"/run/dsm.url\" ] && LOCATION=\$(cat \"/run/dsm.url\")"
|
||||
echo "[ -f \"/run/shm/dsm.url\" ] && LOCATION=\$(cat \"/run/shm/dsm.url\")"
|
||||
echo "HTML=\"$HTML\"; [ -z \"\$LOCATION\" ] && BODY=\"$WAIT\" || BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}"
|
||||
echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
|
||||
} > "$TMP_FILE"
|
||||
|
Loading…
Reference in New Issue
Block a user