Compare commits

...

5 Commits

3 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,7 @@
{
"name": "Virtual DSM",
"service": "vdsm",
"forwardPorts": [5000],
"portsAttributes": {
"5000": {
"label": "Web",

View File

@ -33,6 +33,7 @@ _trap() {
finish() {
local pid
local cnt=0
local reason=$1
touch "$QEMU_END"
@ -40,14 +41,24 @@ finish() {
if [ -s "$QEMU_PID" ]; then
pid=$(<"$QEMU_PID")
echo && error "Forcefully terminating QEMU process, reason: $reason..."
echo && error "Forcefully terminating Virtual DSM, reason: $reason..."
{ kill -15 "$pid" || true; } 2>/dev/null
while isAlive "$pid"; do
sleep 1
cnt=$((cnt+1))
# Workaround for zombie pid
[ ! -s "$QEMU_PID" ] && break
if [ "$cnt" == "5" ]; then
echo && error "QEMU did not terminate itself, forcefully killing process..."
{ kill -9 "$pid" || true; } 2>/dev/null
fi
done
fi
fKill "print.sh"

View File

@ -13,7 +13,7 @@ escape () {
return 0
}
file="$1"
path="$1"
total="$2"
body=$(escape "$3")
@ -24,20 +24,20 @@ fi
while true
do
if [ ! -s "$file" ] && [ ! -d "$file" ]; then
if [ ! -s "$path" ] && [ ! -d "$path" ]; then
bytes="0"
else
bytes=$(du -sb "$file" | cut -f1)
bytes=$(du -sb "$path" | cut -f1)
fi
if (( bytes > 1000 )); then
if (( bytes > 4096 )); then
if [ -z "$total" ] || [[ "$total" == "0" ]] || [ "$bytes" -gt "$total" ]; then
size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/')
else
size="$(echo "$bytes" "$total" | awk '{printf "%.1f", $1 * 100 / $2}')"
size="$size%"
fi
echo "${body//(\[P\])/($size)}"> "$info"
[[ "$size" != "0.0%" ]] && echo "${body//(\[P\])/($size)}"> "$info"
fi
sleep 1 & wait $!