#!/bin/bash
-GROUP=$(getent group www-data | cut -f3 -d:)
-USER=$(getent passwd www-data | cut -f3 -d:)
-
rm -rf vm/ vm.squashfs
mkdir -p vm/proc/
mount /proc -o bind vm/proc
ln -s vm/usr/bin/mawk vm/bin/awk
echo '/sbin/poweroff -f' > vm/.bash_logout
cat > vm/etc/fstab <<EOF
-virtfs /mnt 9p trans=virtio,auto 0 0
-tmpfs /tmp tmpfs defaults 0 0
+virtfs /mnt 9p trans=virtio 0 0
+tmpfs /tmp tmpfs defaults 0 0
EOF
cat > vm/.profile <<EOF
-mount -a
+mount /mnt
+mount /tmp
stty -F /dev/ttyS1 -echo
cd /mnt
export PS1="# "
EOF
-cat > vm/etc/initramfs-tools/modules <<EOF
-squashfs
-9p
-9pnet
-9pnet_virtio
+cat >> vm/etc/sudoers <<EOF
+Defaults>nobody closefrom=5
+Defaults>nobody !env_check
+Defaults>nobody env_keep="ONLINE_JUDGE PATH HOME"
EOF
install gruntmaster-exec gruntmaster-compile vm/usr/bin/
-sed -i -e "s/setgid 65534/setgid $GROUP/" -e "s/setuid 65534/setuid $USER/" vm/usr/bin/gruntmaster-exec
-chroot vm update-initramfs -d -k 3.2.0-4-amd64
-chroot vm update-initramfs -c -k 3.2.0-4-amd64
umount vm/proc
mksquashfs vm vm.squashfs -comp lzo