diff --git a/.gitignore b/.gitignore index 5ef997d..140ea71 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ api/api api/package-lock.json lxc/i lxc/lockfile +container/build.yaml +container/*.tar.xz diff --git a/config/languages.json b/config/languages.json index 2a18b45..2fd5b1e 100644 --- a/config/languages.json +++ b/config/languages.json @@ -222,6 +222,13 @@ "rust" ] }, + { + "name": "scala", + "aliases": [ + "scala", + "sc" + ] + }, { "name": "swift", "aliases": [ diff --git a/container/build.sh b/container/build.sh new file mode 100755 index 0000000..c7f7355 --- /dev/null +++ b/container/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +python3 -m pip install pyyaml +python3 configure.py +distrobuilder build-lxc build.yaml + diff --git a/container/configure.py b/container/configure.py new file mode 100644 index 0000000..5c02fd3 --- /dev/null +++ b/container/configure.py @@ -0,0 +1,13 @@ +import yaml + + +with open('piston.yaml') as dbc: + with open('install_script.sh') as install_script_file: + with open('build.yaml' , 'w+') as distrobuilder_config_file_new: + distrobuilder_config = yaml.safe_load(dbc) + distrobuilder_config['actions'].append({ + 'trigger': 'post-packages', + 'action': install_script_file.read(), + + }) + yaml.dump(distrobuilder_config, distrobuilder_config_file_new) diff --git a/container/install_script.sh b/container/install_script.sh new file mode 100644 index 0000000..65e72c1 --- /dev/null +++ b/container/install_script.sh @@ -0,0 +1,307 @@ +#!/bin/bash +#echo "Don't run this on your system!" && exit 0 + +# install all necessary piston dependencies +echo 'source /opt/.profile' >> /opt/.bashrc +echo 'export HOME=/opt' >> /opt/.profile +echo 'export TERM=linux' >> /opt/.profile +echo 'export PATH=$PATH:/opt/.local/bin' >> /opt/.profile +export HOME=/opt +export TERM=linux +sed -i 's/\/root/\/opt/' /etc/passwd +sed -i \ + 's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' \ + /etc/apt/sources.list +apt-get update +apt-get install -y \ + nano wget build-essential pkg-config libxml2-dev \ + libsqlite3-dev mono-complete curl cmake libpython2.7-dev \ + ruby libtinfo-dev unzip git openssl libssl-dev sbcl libevent-dev + +# install python2 +# final binary: /opt/python2/Python-2.7.17/python +# get version: /opt/python2/Python-2.7.17/python -V +cd /opt && mkdir python2 && cd python2 +wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz +unxz Python-2.7.17.tar.xz +tar -xf Python-2.7.17.tar +cd Python-2.7.17 +./configure +# open Modules/Setup and uncomment zlib line +make +echo 'export PATH=$PATH:/opt/python2/Python-2.7.17' >> /opt/.profile +source /opt/.profile + +# install python3 +# final binary: /opt/python3/Python-3.9.1/python +# get version: /opt/python3/Python-3.9.1/python -V +cd /opt && mkdir python3 && cd python3 +wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz +unxz Python-3.9.1.tar.xz +tar -xf Python-3.9.1.tar +cd Python-3.9.1 +./configure +make +ln -s python python3.9 +echo 'export PATH=$PATH:/opt/python3/Python-3.9.1' >> /opt/.profile +source /opt/.profile + +# install paradoc +# this is not a binary, it is a python module +# therefore it cannot be run directly as it requires python3 to be installed +cd /opt && mkdir paradoc && cd paradoc +git clone https://github.com/betaveros/paradoc.git + +# install node.js +# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/node +# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -v +cd /opt && mkdir nodejs && cd nodejs +wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz +unxz node-v12.16.1-linux-x64.tar.xz +tar -xf node-v12.16.1-linux-x64.tar +echo 'export PATH=$PATH:/opt/nodejs/node-v12.16.1-linux-x64/bin' >> /opt/.profile +source /opt/.profile + +# install typescript +# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc +# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -v +/opt/nodejs/node-v12.16.1-linux-x64/bin/npm i -g typescript + +# install golang +# final binary: /opt/go/go/bin/go +# get version: /opt/go/go/bin/go version +cd /opt && mkdir go && cd go +wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz +tar -xzf go1.14.1.linux-amd64.tar.gz +echo 'export PATH=$PATH:/opt/go/go/bin' >> /opt/.profile +echo 'export GOROOT=/opt/go/go' >> /opt/.profile +echo 'export GOCACHE=/tmp' >> /opt/.profile +source /opt/.profile + +# install php +# final binary: /usr/local/bin/php +# get version: /usr/local/bin/php -v +cd /opt && mkdir php && cd php +wget https://www.php.net/distributions/php-8.0.0.tar.gz +tar -xzf php-8.0.0.tar.gz +cd php-8.0.0 +./configure +make +make install + +# install rust +# final binary: /usr/local/bin/rustc +# get version: /usr/local/bin/rustc --version +cd /opt && mkdir rust && cd rust +wget https://static.rust-lang.org/dist/rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz +tar -xzf rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz +cd rust-1.49.0-x86_64-unknown-linux-gnu +./install.sh + +# install scala +# final binary: /opt/scala/scala3-3.0.0-M3/bin/scala +# get version: /opt/scala/scala3-3.0.0-M3/bin/scala -version +cd /opt && mkdir scala && cd scala +wget https://github.com/lampepfl/dotty/releases/download/3.0.0-M3/scala3-3.0.0-M3.tar.gz +tar -xzf scala3-3.0.0-M3.tar.gz +echo 'export PATH=$PATH:/opt/scala/scala3-3.0.0-M3/bin' >> /opt/.profile +source /opt/.profile + +# install swift +# final binary: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift +# get version: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift --version +cd /opt && mkdir swift && cd swift +wget https://swift.org/builds/swift-5.1.5-release/ubuntu1804/swift-5.1.5-RELEASE/swift-5.1.5-RELEASE-ubuntu18.04.tar.gz +tar -xzf swift-5.1.5-RELEASE-ubuntu18.04.tar.gz +echo 'export PATH=$PATH:/opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin' >> /opt/.profile +source /opt/.profile + +# install nasm +# final binary: /opt/nasm/nasm-2.14.02/nasm +# get version: /opt/nasm/nasm-2.14.02/nasm -v +cd /opt && mkdir nasm && cd nasm +wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz +tar -xzf nasm-2.14.02.tar.gz +cd nasm-2.14.02 +./configure +make +echo 'export PATH=$PATH:/opt/nasm/nasm-2.14.02' >> /opt/.profile +source /opt/.profile + +# install java +# final binary: /opt/java/jdk-14/bin/java +# get version: /opt/java/jdk-14/bin/java -version +cd /opt && mkdir java && cd java +wget https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz +tar -xzf openjdk-14_linux-x64_bin.tar.gz +echo 'export PATH=$PATH:/opt/java/jdk-14/bin' >> /opt/.profile +# Scala will complain if JAVA_HOME isn't set +echo 'export JAVA_HOME=/opt/java/jdk-14' >> /opt/.profile +source /opt/.profile + +# install jelly +cd /opt && mkdir jelly && cd jelly +wget https://github.com/DennisMitchell/jellylanguage/archive/master.zip +unzip master.zip +cd jellylanguage-master +python3.8 -m pip install . +sed -i 's/\/usr\/local\/bin\/python3.8/\/opt\/python3\/Python-3.8.2\/python3.8/' /usr/local/bin/jelly + +# install julia +# final binary: /opt/julia/julia-1.5.0/bin/julia +# get version: /opt/julia/julia-1.5.0/bin/julia --version +cd /opt && mkdir julia && cd julia +wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-linux-x86_64.tar.gz +tar -xzf julia-1.5.0-linux-x86_64.tar.gz +echo 'export PATH=$PATH:/opt/julia/julia-1.5.0/bin' >> /opt/.profile +source /opt/.profile + +# install kotlin +# final binary: /opt/kotlinc/bin/kotlinc +# get version: /opt/kotlinc/bin/kotlinc -version +cd /opt +wget https://github.com/JetBrains/kotlin/releases/download/v1.4.10/kotlin-compiler-1.4.10.zip +unzip kotlin-compiler-1.4.10.zip +rm kotlin-compiler-1.4.10.zip +echo 'export PATH=$PATH:/opt/kotlinc/bin' >> /opt/.profile +source /opt/.profile + +# install elixir and erlang +# final binary: /opt/elixir/bin/elixir +# get version: /opt/elixir/bin/elixir --version +# erlang +cd /opt && mkdir erlang && cd erlang +wget http://erlang.org/download/otp_src_23.0.tar.gz +gunzip -c otp_src_23.0.tar.gz | tar xf - +cd otp_src_23.0 && ./configure +make +echo 'export PATH=$PATH:/opt/erlang/otp_src_23.0/bin' >> /opt/.profile +source /opt/.profile +# elixir +cd /opt && mkdir elixir && cd elixir +wget https://github.com/elixir-lang/elixir/releases/download/v1.10.3/Precompiled.zip +mkdir elixir-1.10.3 && unzip Precompiled.zip -d elixir-1.10.3/ +echo 'export PATH=$PATH:/opt/elixir/elixir-1.10.3/bin' >> /opt/.profile +source /opt/.profile + +# install emacs +# final binary: /opt/emacs/emacs-26.3/src/emacs +# get version: /opt/emacs/emacs-26.3/src/emacs --version +cd /opt && mkdir emacs && cd emacs +wget https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-26.3.tar.xz +tar -xf emacs-26.3.tar.xz +rm emacs-26.3.tar.xz +cd emacs-26.3 +./configure --with-gnutls=no +make +echo 'export PATH=$PATH:/opt/emacs/emacs-26.3/src' >> /opt/.profile +source /opt/.profile + +# install lua +# final binary: /opt/lua/lua54/src/lua +# get version: /opt/lua/lua54/src/lua -v +cd /opt && mkdir lua && cd lua +wget https://sourceforge.net/projects/luabinaries/files/5.4.0/Docs%20and%20Sources/lua-5.4.0_Sources.tar.gz/download +tar -xzf download +cd lua54 +make +echo 'export PATH=$PATH:/opt/lua/lua54/src' >> /opt/.profile +source /opt/.profile + +# install haskell +# final binary: /usr/bin/ghc +# get version: /usr/bin/ghc --version +apt install -y ghc + +# install deno +# final binary: /opt/.deno/bin/deno +# get version: /opt/.deno/bin/deno --version +cd /opt && mkdir deno && cd deno +curl -fsSL https://deno.land/x/install/install.sh | sh +echo 'export DENO_INSTALL="/opt/.deno"' >> /opt/.profile +echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /opt/.profile +source /opt/.profile + +# install brainfuck +cd /opt && mkdir bf && cd bf +git clone https://github.com/texus/Brainfuck-interpreter +cd Brainfuck-interpreter +echo 'export PATH=$PATH:/opt/bf/Brainfuck-interpreter' >> /opt/.profile +source /opt/.profile + +# install crystal +# final binary: /opt/crystal/crystal-0.35.1-1/bin/crystal +# get version: /opt/crystal/crystal-0.35.1-1/bin/crystal -v +cd /opt && mkdir crystal && cd crystal +wget https://github.com/crystal-lang/crystal/releases/download/0.35.1/crystal-0.35.1-1-linux-x86_64.tar.gz +tar -xzf crystal-0.35.1-1-linux-x86_64.tar.gz +echo 'export PATH="$PATH:/opt/crystal/crystal-0.35.1-1/bin:$PATH"' >> /opt/.profile +source /opt/.profile + +# install d +# final binary: /opt/d/dmd2/linux/bin64/dmd +# get version: /opt/d/dmd2/linux/bin64/dmd --version +cd /opt && mkdir d && cd d +wget http://downloads.dlang.org/releases/2.x/2.095.0/dmd.2.095.0.linux.tar.xz +unxz dmd.2.095.0.linux.tar.xz +tar -xf dmd.2.095.0.linux.tar +echo 'export PATH=$PATH:/opt/d/dmd2/linux/bin64' >> /opt/.profile +source /opt/.profile + +# install zig +# final binary: /opt/zig/zig +# get version: /opt/zig/zig version +cd /opt && mkdir zig && cd zig +wget https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz +tar -xf zig-linux-x86_64-0.7.1.tar.xz +mv zig-linux-x86_64-0.7.1 zig +rm zig-linux-x86_64-0.7.1.tar.xz +echo 'export PATH=$PATH:/opt/zig/zig' >> /opt/.profile +source /opt/.profile + +# install nim +# final binary: /opt/nim/bin/nim +# get version: /opt/nim/bin/nim -v +cd /opt && mkdir nim && cd nim +wget https://nim-lang.org/download/nim-1.4.0-linux_x64.tar.xz +unxz nim-1.4.0-linux_x64.tar.xz +tar -xf nim-1.4.0-linux_x64.tar +cd nim-1.4.0 +./install.sh /opt +echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile +source /opt/.profile + +# install 05AB1E +# final binary: /opt/05AB1E/05AB1E/osabie +# requires Elixir to install +cd /opt && mkdir 05AB1E && cd 05AB1E +git clone https://github.com/Adriandmen/05AB1E.git +cd 05AB1E +mix local.hex --force +mix deps.get --force +MIX_ENV=prod mix escript.build --force +echo 'export PATH=$PATH:/opt/05AB1E/05AB1E' >> /opt/.profile +source /opt/.profile + +# create runnable users and apply limits +for i in {1..150}; do + useradd -M runner$i + usermod -d /tmp runner$i + echo "runner$i soft nproc 64" >> /etc/security/limits.conf + echo "runner$i hard nproc 64" >> /etc/security/limits.conf + echo "runner$i soft nofile 2048" >> /etc/security/limits.conf + echo "runner$i hard nofile 2048" >> /etc/security/limits.conf +done + +# remove any lingering write access to others +cd /opt +chown -R root: * +chmod -R o-w * + +# cleanup +rm -rf /home/ubuntu +chmod 777 /tmp + +# disable cron +systemctl stop cron +systemctl disable cron diff --git a/container/piston.yaml b/container/piston.yaml new file mode 100644 index 0000000..4cbb9c0 --- /dev/null +++ b/container/piston.yaml @@ -0,0 +1,355 @@ +image: + name: ubuntu-bionic-x86_64-piston + distribution: ubuntu + release: bionic + description: |- + Ubuntu {{ image.release }} preconfigured for Piston + architecture: x86_64 + +source: + downloader: debootstrap + same_as: bionic + url: http://archive.ubuntu.com/ubuntu + keyserver: keyserver.ubuntu.com + keys: + - '0x790BC7277767219C42C86F933B4FE6ACC0B21F32' + - '0xf6ecb3762474eda9d21b7022871920d1991bc93c' + +targets: + lxc: + create-message: |- + You just created an {{ image.description }} container. + To enable SSH, run: apt install openssh-server + No default root or user password are set by LXC. + config: + - type: all + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf + - type: user + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf + - type: all + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/common.conf + # For Ubuntu 14.04 + lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none bind,optional 0 0 + lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0 + lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none bind,optional 0 0 + lxc.mount.entry = mqueue dev/mqueue mqueue rw,relatime,create=dir,optional 0 0 + - type: user + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/userns.conf + # For Ubuntu 14.04 + lxc.mount.entry = /sys/firmware/efi/efivars sys/firmware/efi/efivars none bind,optional 0 0 + lxc.mount.entry = /proc/sys/fs/binfmt_misc proc/sys/fs/binfmt_misc none bind,optional 0 0 + - type: all + content: |- + lxc.arch = {{ image.architecture_personality }} +files: +- path: /etc/hostname + generator: hostname + +- path: /etc/hosts + generator: hosts + +- path: /etc/resolvconf/resolv.conf.d/original + generator: remove + +- path: /etc/resolvconf/resolv.conf.d/tail + generator: remove + +- path: /etc/machine-id + generator: dump + + +- path: /var/lib/dbus/machine-id + generator: remove + +- path: /etc/netplan/10-lxc.yaml + generator: dump + content: |- + network: + version: 2 + ethernets: + eth0: + dhcp4: true + dhcp-identifier: mac + releases: + - bionic + - eoan + - focal + - groovy + types: + - container + variants: + - default + +- path: /etc/network/interfaces + generator: dump + content: |- + # This file describes the network interfaces available on your system + # and how to activate them. For more information, see interfaces(5). + # The loopback network interface + auto lo + iface lo inet loopback + auto eth0 + iface eth0 inet dhcp + source /etc/network/interfaces.d/*.cfg + releases: + - trusty + - xenial + types: + - container + +- path: /etc/netplan/10-lxc.yaml + generator: dump + content: |- + network: + version: 2 + ethernets: + enp5s0: + dhcp4: true + dhcp-identifier: mac + releases: + - bionic + - eoan + - focal + - groovy + types: + - vm + variants: + - default + +- path: /etc/network/interfaces + generator: dump + content: |- + # This file describes the network interfaces available on your system + # and how to activate them. For more information, see interfaces(5). + # The loopback network interface + auto lo + iface lo inet loopback + auto enp5s0 + iface enp5s0 inet dhcp + source /etc/network/interfaces.d/*.cfg + releases: + - trusty + - xenial + types: + - vm + +- path: /etc/init/lxc-tty.conf + generator: upstart-tty + releases: + - trusty + types: + - container + +- name: meta-data + generator: cloud-init + variants: + - cloud + +- name: network-config + generator: cloud-init + variants: + - cloud + +- name: user-data + generator: cloud-init + variants: + - cloud + +- name: vendor-data + generator: cloud-init + variants: + - cloud + +- name: ext4 + generator: fstab + types: + - vm + +- name: lxd-agent + generator: lxd-agent + types: + - vm + +- path: /etc/default/grub.d/50-lxd.cfg + generator: dump + content: |- + GRUB_RECORDFAIL_TIMEOUT=0 + GRUB_TIMEOUT=0 + GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} console=tty1 console=ttyS0" + GRUB_TERMINAL=console + types: + - vm + +- path: /etc/sudoers.d/90-lxd + generator: dump + mode: '0440' + content: |- + # User rules for ubuntu + ubuntu ALL=(ALL) NOPASSWD:ALL + variants: + - default + +packages: + manager: apt + update: true + cleanup: true + sets: + - packages: + - apt-transport-https + - fuse + - language-pack-en + - openssh-client + - vim + action: install + + - packages: + - cloud-init + action: install + variants: + - cloud + + - packages: + - acpid + action: install + architectures: + - amd64 + - arm64 + types: + - vm + + - packages: + - grub-efi-amd64-signed + - shim-signed + action: install + architectures: + - amd64 + types: + - vm + + - packages: + - grub-efi-arm64-signed + action: install + architectures: + - arm64 + types: + - vm + + - packages: + - shim-signed + action: install + architectures: + - arm64 + releases: + - disco + - eoan + - focal + - groovy + types: + - vm + + - packages: + - linux-virtual-hwe-16.04 + action: install + releases: + - xenial + types: + - vm + + - packages: + - linux-virtual + action: install + releases: + - bionic + - eoan + - focal + - groovy + types: + - vm + + - packages: + - os-prober + action: remove + types: + - vm + + repositories: + - name: sources.list + url: |- + deb http://archive.ubuntu.com/ubuntu {{ image.release }} main restricted universe multiverse + deb http://archive.ubuntu.com/ubuntu {{ image.release }}-updates main restricted universe multiverse + deb http://security.ubuntu.com/ubuntu {{ image.release }}-security main restricted universe multiverse + architectures: + - amd64 + - i386 + + - name: sources.list + url: |- + deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }} main restricted universe multiverse + deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-updates main restricted universe multiverse + deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-security main restricted universe multiverse + architectures: + - armhf + - arm64 + - powerpc + - powerpc64 + - ppc64el + +actions: +- trigger: post-update + action: |- + #!/bin/sh + set -eux + # Create the ubuntu user account + getent group sudo >/dev/null 2>&1 || groupadd --system sudo + useradd --create-home -s /bin/bash -G sudo -U ubuntu + variants: + - default + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + # Enable systemd-networkd + systemctl enable systemd-networkd + releases: + - bionic + - eoan + - focal + - groovy + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + # Make sure the locale is built and functional + locale-gen en_US.UTF-8 + update-locale LANG=en_US.UTF-8 + # Cleanup underlying /run + mount -o bind / /mnt + rm -rf /mnt/run/* + umount /mnt + # Cleanup temporary shadow paths + rm /etc/*- +- trigger: post-files + action: |- + #!/bin/sh + set -eux + TARGET="x86_64" + [ "$(uname -m)" = "aarch64" ] && TARGET="arm64" + update-grub + grub-install --uefi-secure-boot --target="${TARGET}-efi" --no-nvram --removable + update-grub + sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub/grub.cfg + types: + - vm + +mappings: + architecture_map: debian diff --git a/container/readme.md b/container/readme.md new file mode 100644 index 0000000..1af19d5 --- /dev/null +++ b/container/readme.md @@ -0,0 +1,7 @@ +# LXC Container Build + +Requires: `lxc`, `lxc-net`, `packer` (Hashicorp Packer) + +To build: `packer build -var 'apt_mirror=[apt mirror]' -var 'make_threads=[-j flag]' piston.pkr.hcl` + +After roughly 30 minutes (on an i7-4790k), you should have an image built \ No newline at end of file diff --git a/lxc/execute b/lxc/execute index 40d1797..66e1daf 100755 --- a/lxc/execute +++ b/lxc/execute @@ -35,7 +35,7 @@ lxc-attach --clear-env -n piston -- \ # runner timeout -s KILL 20 \ lxc-attach --clear-env -n piston -- \ - /bin/bash -l -c "runuser runner$runner /exec/$language runner$runner $id" + /bin/bash -l -c "runuser runner$runner /exec/$language $id" # process janitor lxc-attach --clear-env -n piston -- \ diff --git a/lxc/executors/awk b/lxc/executors/awk index 395424f..319a64e 100755 --- a/lxc/executors/awk +++ b/lxc/executors/awk @@ -1,4 +1,5 @@ #!/bin/bash -cd /tmp/$2 + +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' awk -f code.code < stdin.stdin diff --git a/lxc/executors/bash b/lxc/executors/bash index 6aeb899..8685011 100755 --- a/lxc/executors/bash +++ b/lxc/executors/bash @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 xargs -a args.args -d '\n' timeout -s KILL 3 bash code.code < stdin.stdin diff --git a/lxc/executors/brainfuck b/lxc/executors/brainfuck index 7ec1bfe..eb9725d 100755 --- a/lxc/executors/brainfuck +++ b/lxc/executors/brainfuck @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' brainfuck code.code < stdin.stdin diff --git a/lxc/executors/c b/lxc/executors/c index 719062a..e0806f3 100755 --- a/lxc/executors/c +++ b/lxc/executors/c @@ -1,5 +1,5 @@ #!/usr/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 10 gcc -std=c11 -o binary -x c code.code timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/cpp b/lxc/executors/cpp index 9f7ef27..0365b00 100755 --- a/lxc/executors/cpp +++ b/lxc/executors/cpp @@ -1,5 +1,5 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 10 g++ -std=c++17 -o binary -x c++ code.code timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/crystal b/lxc/executors/crystal index a3ce996..ec8fe01 100644 --- a/lxc/executors/crystal +++ b/lxc/executors/crystal @@ -1,5 +1,5 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 10 crystal build code.code timeout -s KILL 3 xargs -a args.args -d '\n' ./code < stdin.stdin diff --git a/lxc/executors/csharp b/lxc/executors/csharp index f35c876..684beb9 100755 --- a/lxc/executors/csharp +++ b/lxc/executors/csharp @@ -1,5 +1,5 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary timeout -s KILL 3 xargs -a args.args -d '\n' mono binary < stdin.stdin diff --git a/lxc/executors/d b/lxc/executors/d index 15e155d..8893762 100644 --- a/lxc/executors/d +++ b/lxc/executors/d @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 cp code.code code.d timeout -s KILL 10 dmd code.d timeout -s KILL 3 xargs -a args.args -d '\n' ./code diff --git a/lxc/executors/dash b/lxc/executors/dash index cf20c38..4476310 100644 --- a/lxc/executors/dash +++ b/lxc/executors/dash @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 xargs -a args.args -d '\n' timeout -s KILL 3 dash code.code < stdin.stdin diff --git a/lxc/executors/deno b/lxc/executors/deno index 31132fa..f55e1f4 100755 --- a/lxc/executors/deno +++ b/lxc/executors/deno @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' deno run code.code < stdin.stdin diff --git a/lxc/executors/elixir b/lxc/executors/elixir index 1a8e23f..2f36aa9 100755 --- a/lxc/executors/elixir +++ b/lxc/executors/elixir @@ -2,5 +2,5 @@ export LC_ALL="en_US.UTF-8" -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' elixir code.code < stdin.stdin diff --git a/lxc/executors/emacs b/lxc/executors/emacs index ab41624..efcac97 100755 --- a/lxc/executors/emacs +++ b/lxc/executors/emacs @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' emacs -Q --script code.code < stdin.stdin diff --git a/lxc/executors/go b/lxc/executors/go index 09c1e68..41592f7 100755 --- a/lxc/executors/go +++ b/lxc/executors/go @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 cp code.code interim.go go build interim.go timeout -s KILL 3 xargs -a args.args -d '\n' ./interim < stdin.stdin diff --git a/lxc/executors/haskell b/lxc/executors/haskell index df517d9..ad62cab 100755 --- a/lxc/executors/haskell +++ b/lxc/executors/haskell @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 cp code.code code.hs ghc -dynamic -o binary code.hs > /dev/null 2>&1 timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/java b/lxc/executors/java index 2818d88..c5effb6 100755 --- a/lxc/executors/java +++ b/lxc/executors/java @@ -1,5 +1,5 @@ #!/bin/bash +cd /tmp/$1 cp code.code interim.java timeout -s KILL 10 xargs -a args.args -d '\n' java interim.java < stdin.stdin - diff --git a/lxc/executors/jelly b/lxc/executors/jelly index 945444e..6d83412 100755 --- a/lxc/executors/jelly +++ b/lxc/executors/jelly @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' jelly fu code.code < stdin.stdin diff --git a/lxc/executors/julia b/lxc/executors/julia index e8b4ea5..1d4ba09 100755 --- a/lxc/executors/julia +++ b/lxc/executors/julia @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' julia code.code < stdin.stdin diff --git a/lxc/executors/kotlin b/lxc/executors/kotlin index c304575..a144851 100755 --- a/lxc/executors/kotlin +++ b/lxc/executors/kotlin @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 cp code.code code.kt kotlinc code.kt -include-runtime -d code.jar timeout -s KILL 3 xargs -a args.args -d '\n' java -jar code.jar < stdin.stdin diff --git a/lxc/executors/lisp b/lxc/executors/lisp index 6453985..d65e94a 100644 --- a/lxc/executors/lisp +++ b/lxc/executors/lisp @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' sbcl --script code.code < stdin.stdin diff --git a/lxc/executors/lua b/lxc/executors/lua index 4caa4b6..7c50781 100755 --- a/lxc/executors/lua +++ b/lxc/executors/lua @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' lua code.code < stdin.stdin diff --git a/lxc/executors/nasm b/lxc/executors/nasm index ffe8fd0..8c9b13f 100755 --- a/lxc/executors/nasm +++ b/lxc/executors/nasm @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 nasm -f elf32 -o binary.o code.code ld -m elf_i386 binary.o -o binary timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/nasm64 b/lxc/executors/nasm64 index 98c2aab..44d8aa2 100755 --- a/lxc/executors/nasm64 +++ b/lxc/executors/nasm64 @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 nasm -f elf64 -o binary.o code.code ld -m elf_x86_64 binary.o -o binary timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/nim b/lxc/executors/nim index 8b5b1c1..51c1fee 100644 --- a/lxc/executors/nim +++ b/lxc/executors/nim @@ -1,5 +1,5 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 10 nim --hints:off c code.code timeout -s KILL 3 xargs -a args.args -d '\n' ./code diff --git a/lxc/executors/node b/lxc/executors/node index 3262b53..b69940b 100755 --- a/lxc/executors/node +++ b/lxc/executors/node @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' node code.code < stdin.stdin diff --git a/lxc/executors/osabie b/lxc/executors/osabie index ff8ab84..cb66947 100644 --- a/lxc/executors/osabie +++ b/lxc/executors/osabie @@ -4,5 +4,5 @@ export LC_ALL="en_US.UTF-8" # osabie will break if you try using it with xargs -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 osabie code.code < args.args diff --git a/lxc/executors/paradoc b/lxc/executors/paradoc index f82630a..f4398a3 100755 --- a/lxc/executors/paradoc +++ b/lxc/executors/paradoc @@ -1,5 +1,5 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 export PYTHONPATH=$PYTHONPATH:/opt/paradoc timeout -s KILL 3 python3.8 -m paradoc code.code < args.args diff --git a/lxc/executors/perl b/lxc/executors/perl index 8b65855..af78971 100755 --- a/lxc/executors/perl +++ b/lxc/executors/perl @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' perl code.code < stdin.stdin diff --git a/lxc/executors/php b/lxc/executors/php index 9f21f7b..5c37306 100755 --- a/lxc/executors/php +++ b/lxc/executors/php @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' php code.code < stdin.stdin diff --git a/lxc/executors/python2 b/lxc/executors/python2 index 5fa1c3e..54db44c 100755 --- a/lxc/executors/python2 +++ b/lxc/executors/python2 @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' python code.code < stdin.stdin diff --git a/lxc/executors/python3 b/lxc/executors/python3 index 6cb93f8..9f4bd58 100755 --- a/lxc/executors/python3 +++ b/lxc/executors/python3 @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' python3.8 code.code < stdin.stdin diff --git a/lxc/executors/ruby b/lxc/executors/ruby index ebb9b06..7f64386 100755 --- a/lxc/executors/ruby +++ b/lxc/executors/ruby @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' ruby code.code < stdin.stdin diff --git a/lxc/executors/rust b/lxc/executors/rust index 6be216a..56a7c02 100755 --- a/lxc/executors/rust +++ b/lxc/executors/rust @@ -1,5 +1,5 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 10 rustc -o binary code.code timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/scala b/lxc/executors/scala new file mode 100755 index 0000000..be9c27d --- /dev/null +++ b/lxc/executors/scala @@ -0,0 +1,5 @@ +#!/bin/bash + +cd /tmp/$1 +cp code.code interim.scala +timeout -s KILL 10 xargs -a args.args -d '\n' scala interim.scala < stdin.stdin diff --git a/lxc/executors/swift b/lxc/executors/swift index a8327f7..96c8830 100755 --- a/lxc/executors/swift +++ b/lxc/executors/swift @@ -1,4 +1,4 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 timeout -s KILL 3 xargs -a args.args -d '\n' swift code.code < stdin.stdin diff --git a/lxc/executors/typescript b/lxc/executors/typescript index 8c1873d..b671996 100755 --- a/lxc/executors/typescript +++ b/lxc/executors/typescript @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 mv code.code interim.ts tsc interim.ts rm -f interim.ts diff --git a/lxc/executors/zig b/lxc/executors/zig index 1250342..b046672 100644 --- a/lxc/executors/zig +++ b/lxc/executors/zig @@ -1,6 +1,6 @@ #!/bin/bash -cd /tmp/$2 +cd /tmp/$1 cp code.code main.zig timeout -s KILL 10 zig build-exe main.zig timeout -s KILL 3 xargs -a args.args -d '\n' ./main diff --git a/lxc/tests/_run b/lxc/tests/_run index 676b8cb..e063d4f 100755 --- a/lxc/tests/_run +++ b/lxc/tests/_run @@ -60,6 +60,8 @@ echo -n 'testing ruby = ' ../../cli/execute ruby ruby.rb echo -n 'testing rust = ' ../../cli/execute rust rust.rs +echo -n 'testing scala = ' +../../cli/execute scala scala.scala echo -n 'testing swift = ' ../../cli/execute swift swift.swift echo -n 'testing typescript = ' diff --git a/lxc/tests/scala.scala b/lxc/tests/scala.scala new file mode 100644 index 0000000..4083d74 --- /dev/null +++ b/lxc/tests/scala.scala @@ -0,0 +1,3 @@ +@main def run(): Unit = { + println("good") +} diff --git a/lxc/util/versions b/lxc/util/versions index ee139c8..f280210 100755 --- a/lxc/util/versions +++ b/lxc/util/versions @@ -125,6 +125,10 @@ echo 'rust' lxc-attach --clear-env -n piston -- /bin/bash -l -c "rustc --version" echo '---' +echo 'scala' +lxc-attach --clear-env -n piston -- /bin/bash -l -c "scala -version" +echo '---' + echo 'swift' lxc-attach --clear-env -n piston -- /bin/bash -l -c "swift --version" echo '---' diff --git a/readme.md b/readme.md index 613b980..ea4c0e9 100644 --- a/readme.md +++ b/readme.md @@ -136,17 +136,21 @@ pacman -S lxc libvirt unzip ```sh # clone and enter repo git clone https://github.com/engineer-man/piston -cd piston/lxc ``` #### Installation (simple) -- Coming soon. +- Install additional dependencies python3, pip and distrobuilder +- `cd container && ./build.sh` +- Wait, it may take up to an hour. +- `lxc-create -n piston -t local -- --metadata meta.tar.xz --fstree rootfs.tar.xz` +- `cd lxc && ./start` +- Good to go! + #### Installation (advanced) -- See `var/install.txt` for how to create a new LXC container and install all of the required -software. +- See `var/install.txt` for how to build the container manually #### CLI Usage - `cli/execute [language] [file path] [args]` @@ -284,6 +288,7 @@ Content-Type: application/json `python3`, `ruby`, `rust`, +`scala`, `swift`, `typescript`, `zig`, diff --git a/var/install.txt b/var/install.txt index bc7eae9..396cbae 100644 --- a/var/install.txt +++ b/var/install.txt @@ -5,299 +5,7 @@ lxc-create -t download -n piston -- --dist ubuntu --release bionic --arch amd64 # open a shell to the container ./shell -# install all necessary piston dependencies -echo 'source /opt/.profile' >> /opt/.bashrc -echo 'export HOME=/opt' >> /opt/.profile -echo 'export TERM=linux' >> /opt/.profile -echo 'export PATH=$PATH:/opt/.local/bin' >> /opt/.profile -export HOME=/opt -export TERM=linux -sed -i 's/\/root/\/opt/' /etc/passwd -sed -i \ - 's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' \ - /etc/apt/sources.list -apt-get update -apt-get install -y \ - nano wget build-essential pkg-config libxml2-dev \ - libsqlite3-dev mono-complete curl cmake libpython2.7-dev \ - ruby libtinfo-dev unzip git openssl libssl-dev sbcl libevent-dev - -# install python2 -# final binary: /opt/python2/Python-2.7.17/python -# get version: /opt/python2/Python-2.7.17/python -V -cd /opt && mkdir python2 && cd python2 -wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz -unxz Python-2.7.17.tar.xz -tar -xf Python-2.7.17.tar -cd Python-2.7.17 -./configure -# open Modules/Setup and uncomment zlib line -make -echo 'export PATH=$PATH:/opt/python2/Python-2.7.17' >> /opt/.profile -source /opt/.profile - -# install python3 -# final binary: /opt/python3/Python-3.9.1/python -# get version: /opt/python3/Python-3.9.1/python -V -cd /opt && mkdir python3 && cd python3 -wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz -unxz Python-3.9.1.tar.xz -tar -xf Python-3.9.1.tar -cd Python-3.9.1 -./configure -make -ln -s python python3.9 -echo 'export PATH=$PATH:/opt/python3/Python-3.9.1' >> /opt/.profile -source /opt/.profile - -# install paradoc -# this is not a binary, it is a python module -# therefore it cannot be run directly as it requires python3 to be installed -cd /opt && mkdir paradoc && cd paradoc -git clone https://github.com/betaveros/paradoc.git - -# install node.js -# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -v -cd /opt && mkdir nodejs && cd nodejs -wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz -unxz node-v12.16.1-linux-x64.tar.xz -tar -xf node-v12.16.1-linux-x64.tar -echo 'export PATH=$PATH:/opt/nodejs/node-v12.16.1-linux-x64/bin' >> /opt/.profile -source /opt/.profile - -# install typescript -# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -v -/opt/nodejs/node-v12.16.1-linux-x64/bin/npm i -g typescript - -# install golang -# final binary: /opt/go/go/bin/go -# get version: /opt/go/go/bin/go version -cd /opt && mkdir go && cd go -wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz -tar -xzf go1.14.1.linux-amd64.tar.gz -echo 'export PATH=$PATH:/opt/go/go/bin' >> /opt/.profile -echo 'export GOROOT=/opt/go/go' >> /opt/.profile -echo 'export GOCACHE=/tmp' >> /opt/.profile -source /opt/.profile - -# install php -# final binary: /usr/local/bin/php -# get version: /usr/local/bin/php -v -cd /opt && mkdir php && cd php -wget https://www.php.net/distributions/php-8.0.0.tar.gz -tar -xzf php-8.0.0.tar.gz -cd php-8.0.0 -./configure -make -make install - -# install rust -# final binary: /usr/local/bin/rustc -# get version: /usr/local/bin/rustc --version -cd /opt && mkdir rust && cd rust -wget https://static.rust-lang.org/dist/rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz -tar -xzf rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz -cd rust-1.49.0-x86_64-unknown-linux-gnu -./install.sh - -# install swift -# final binary: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift -# get version: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift --version -cd /opt && mkdir swift && cd swift -wget https://swift.org/builds/swift-5.1.5-release/ubuntu1804/swift-5.1.5-RELEASE/swift-5.1.5-RELEASE-ubuntu18.04.tar.gz -tar -xzf swift-5.1.5-RELEASE-ubuntu18.04.tar.gz -echo 'export PATH=$PATH:/opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin' >> /opt/.profile -source /opt/.profile - -# install nasm -# final binary: /opt/nasm/nasm-2.14.02/nasm -# get version: /opt/nasm/nasm-2.14.02/nasm -v -cd /opt && mkdir nasm && cd nasm -wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz -tar -xzf nasm-2.14.02.tar.gz -cd nasm-2.14.02 -./configure -make -echo 'export PATH=$PATH:/opt/nasm/nasm-2.14.02' >> /opt/.profile -source /opt/.profile - -# install java -# final binary: /opt/java/jdk-14/bin/java -# get version: /opt/java/jdk-14/bin/java -version -cd /opt && mkdir java && cd java -wget https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz -tar -xzf openjdk-14_linux-x64_bin.tar.gz -echo 'export PATH=$PATH:/opt/java/jdk-14/bin' >> /opt/.profile -source /opt/.profile - -# install jelly -cd /opt && mkdir jelly && cd jelly -wget https://github.com/DennisMitchell/jellylanguage/archive/master.zip -unzip master.zip -cd jellylanguage-master -python3.8 -m pip install . -sed -i 's/\/usr\/local\/bin\/python3.8/\/opt\/python3\/Python-3.8.2\/python3.8/' /usr/local/bin/jelly - -# install julia -# final binary: /opt/julia/julia-1.5.0/bin/julia -# get version: /opt/julia/julia-1.5.0/bin/julia --version -cd /opt && mkdir julia && cd julia -wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-linux-x86_64.tar.gz -tar -xzf julia-1.5.0-linux-x86_64.tar.gz -echo 'export PATH=$PATH:/opt/julia/julia-1.5.0/bin' >> /opt/.profile -source /opt/.profile - -# install kotlin -# final binary: /opt/kotlinc/bin/kotlinc -# get version: /opt/kotlinc/bin/kotlinc -version -cd /opt -wget https://github.com/JetBrains/kotlin/releases/download/v1.4.10/kotlin-compiler-1.4.10.zip -unzip kotlin-compiler-1.4.10.zip -rm kotlin-compiler-1.4.10.zip -echo 'export PATH=$PATH:/opt/kotlinc/bin' >> /opt/.profile -source /opt/.profile - -# install elixir and erlang -# final binary: /opt/elixir/bin/elixir -# get version: /opt/elixir/bin/elixir --version -# erlang -cd /opt && mkdir erlang && cd erlang -wget http://erlang.org/download/otp_src_23.0.tar.gz -gunzip -c otp_src_23.0.tar.gz | tar xf - -cd otp_src_23.0 && ./configure -make -echo 'export PATH=$PATH:/opt/erlang/otp_src_23.0/bin' >> /opt/.profile -source /opt/.profile -# elixir -cd /opt && mkdir elixir && cd elixir -wget https://github.com/elixir-lang/elixir/releases/download/v1.10.3/Precompiled.zip -mkdir elixir-1.10.3 && unzip Precompiled.zip -d elixir-1.10.3/ -echo 'export PATH=$PATH:/opt/elixir/elixir-1.10.3/bin' >> /opt/.profile -source /opt/.profile - -# install emacs -# final binary: /opt/emacs/emacs-26.3/src/emacs -# get version: /opt/emacs/emacs-26.3/src/emacs --version -cd /opt && mkdir emacs && cd emacs -wget https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-26.3.tar.xz -tar -xf emacs-26.3.tar.xz -rm emacs-26.3.tar.xz -cd emacs-26.3 -./configure --with-gnutls=no -make -echo 'export PATH=$PATH:/opt/emacs/emacs-26.3/src' >> /opt/.profile -source /opt/.profile - -# install lua -# final binary: /opt/lua/lua54/src/lua -# get version: /opt/lua/lua54/src/lua -v -cd /opt && mkdir lua && cd lua -wget https://sourceforge.net/projects/luabinaries/files/5.4.0/Docs%20and%20Sources/lua-5.4.0_Sources.tar.gz/download -tar -xzf download -cd lua54 -make -echo 'export PATH=$PATH:/opt/lua/lua54/src' >> /opt/.profile -source /opt/.profile - -# install haskell -# final binary: /usr/bin/ghc -# get version: /usr/bin/ghc --version -apt install -y ghc - -# install deno -# final binary: /opt/.deno/bin/deno -# get version: /opt/.deno/bin/deno --version -cd /opt && mkdir deno && cd deno -curl -fsSL https://deno.land/x/install/install.sh | sh -echo 'export DENO_INSTALL="/opt/.deno"' >> /opt/.profile -echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /opt/.profile -source /opt/.profile - -# install brainfuck -cd /opt && mkdir bf && cd bf -git clone https://github.com/texus/Brainfuck-interpreter -cd Brainfuck-interpreter -echo 'export PATH=$PATH:/opt/bf/Brainfuck-interpreter' >> /opt/.profile -source /opt/.profile - -# install crystal -# final binary: /opt/crystal/crystal-0.35.1-1/bin/crystal -# get version: /opt/crystal/crystal-0.35.1-1/bin/crystal -v -cd /opt && mkdir crystal && cd crystal -wget https://github.com/crystal-lang/crystal/releases/download/0.35.1/crystal-0.35.1-1-linux-x86_64.tar.gz -tar -xzf crystal-0.35.1-1-linux-x86_64.tar.gz -echo 'export PATH="$PATH:/opt/crystal/crystal-0.35.1-1/bin:$PATH"' >> /opt/.profile -source /opt/.profile - -# install d -# final binary: /opt/d/dmd2/linux/bin64/dmd -# get version: /opt/d/dmd2/linux/bin64/dmd --version -cd /opt && mkdir d && cd d -wget http://downloads.dlang.org/releases/2.x/2.095.0/dmd.2.095.0.linux.tar.xz -unxz dmd.2.095.0.linux.tar.xz -tar -xf dmd.2.095.0.linux.tar -echo 'export PATH=$PATH:/opt/d/dmd2/linux/bin64' >> /opt/.profile -source /opt/.profile - -# install zig -# final binary: /opt/zig/zig -# get version: /opt/zig/zig version -cd /opt && mkdir zig && cd zig -wget https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz -tar -xf zig-linux-x86_64-0.7.1.tar.xz -mv zig-linux-x86_64-0.7.1 zig -rm zig-linux-x86_64-0.7.1.tar.xz -echo 'export PATH=$PATH:/opt/zig/zig' >> /opt/.profile -source /opt/.profile - -# install nim -# final binary: /opt/nim/bin/nim -# get version: /opt/nim/bin/nim -v -cd /opt && mkdir nim && cd nim -wget https://nim-lang.org/download/nim-1.4.0-linux_x64.tar.xz -unxz nim-1.4.0-linux_x64.tar.xz -tar -xf nim-1.4.0-linux_x64.tar -cd nim-1.4.0 -./install.sh /opt -echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile -source /opt/.profile - -# install 05AB1E -# final binary: /opt/05AB1E/05AB1E/osabie -# requires Elixir to install -cd /opt && mkdir 05AB1E && cd 05AB1E -git clone https://github.com/Adriandmen/05AB1E.git -cd 05AB1E -mix local.hex --force -mix deps.get --force -MIX_ENV=prod mix escript.build --force -echo 'export PATH=$PATH:/opt/05AB1E/05AB1E' >> /opt/.profile -source /opt/.profile - -# create runnable users and apply limits -for i in {1..150}; do - useradd -M runner$i - usermod -d /tmp runner$i - echo "runner$i soft nproc 64" >> /etc/security/limits.conf - echo "runner$i hard nproc 64" >> /etc/security/limits.conf - echo "runner$i soft nofile 2048" >> /etc/security/limits.conf - echo "runner$i hard nofile 2048" >> /etc/security/limits.conf -done - -# remove any lingering write access to others -cd /opt -chown -R root: * -chmod -R o-w * - -# cleanup -rm -rf /home/ubuntu -chmod 777 /tmp - -# disable cron -systemctl stop cron -systemctl disable cron +# run everything located in container/install.sh # leave container exit