Initial commit

This commit is contained in:
sleirsgoevy 2017-12-10 20:06:11 +03:00
commit 5427ff5cec
6 changed files with 72 additions and 0 deletions

29
bin/compile Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
export APP="$(realpath "$1")"
export CACHE="$2"
export ENV="$3"
export BP="$(realpath "$(dirname "$0")/..")"
export PATH="$PATH:$BP/bin"
. "$BP/bin/read_config"
mkdir "$CACHE/app_root"
find "$APP" ! -path "$APP" -maxdepth 1 -exec mv "{}" "$CACHE/app_root" \;
mv "$CACHE/app_root" "$APP/root"
tar -xvzf "$BP/uml.tar.gz" -C "$APP"
mkdir "$APP/tmp"
mkdir "$APP/shadow_root"
mkdir "$APP/shadow_mount"
dd if=/dev/zero of="$APP/shadow_root.img" bs=1048576 count="$FS_SIZE"
/sbin/mke2fs "$APP/shadow_root.img"
wget http://ftp.debian.org/debian/pool/main/c/criu/criu_3.6-2_amd64.deb -O "$APP/criu.deb"
echo $MEM
uml_run "rm /var/lib/dpkg/lock /var/lib/dpkg/triggers/Lock; rm -r /var/cache/apt/archives/*; umount /app; dpkg -i '$APP/criu.deb'; apt-get -f install; mount --bind '$APP/root' /app; bash /app/install.sh"
mkdir "$APP/.profile.d"
cp "$BP/bin/read_config" "$APP/.profile.d"
cp "$APP/root/Procfile" "$APP/Procfile"
fix_procfile "$APP/Procfile"

10
bin/detect Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
APP="$1"
if test -f "$APP/config.sh" && test -f "$APP/install.sh"
then echo "UML"
exit 0
fi
exit 1

17
bin/fix_procfile Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python3
import sys, shlex
procfile_path = sys.argv[1]
lines = []
with open(procfile_path) as file:
for line in file:
if ":" in line:
type, cmd = line.split(':', 1)
lines.append(type+': /app/uml/uml_run '+shlex.quote('cd /app; '+cmd.strip())+'\n')
else:
lines.append(line)
with open(procfile_path, 'w') as file:
file.writelines(lines)

11
bin/read_config Normal file
View File

@ -0,0 +1,11 @@
FS_SIZE=512
MEM=1024
if [ "x$APP" == x ]
then export APP=/app
fi
. "$APP/config.sh"
export FS_SIZE="$FS_SIZE"
export MEM="$MEM"

5
bin/uml_run Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "$1" > "$APP/uml_command"
TEMP="$APP" "$APP/uml/uml" root=/dev/root rw rootflags=/ rootfstype=hostfs init="$APP/uml/init" mem=${MEM}M quiet app="$APP"
rm "$APP/uml_command"

BIN
uml.tar.gz Normal file

Binary file not shown.