#!/usr/bin/env bash COLOR_RED="\e[0;31m" COLOR_GREEN="\e[0;32m" COLOR_NONE="\e[0m" function log_info() { echo -e "${COLOR_GREEN}$*${COLOR_NONE}" 1>&2; } function log_error() { echo -e "${COLOR_RED}$*${COLOR_NONE}" 1>&2; } function build_woj_launcher { rm -rf woj-sandbox git clone https://git.0x7f.app/WOJ/woj-sandbox.git woj-sandbox >/dev/null 2>&1 || { log_error "Failed to clone woj-sandbox"; exit 1; } cd woj-sandbox || { log_error "Failed to enter woj-sandbox"; exit 1; } ./build_libseccomp.sh || { log_error "Failed to build libseccomp"; exit 1; } mkdir -p build || { log_error "Failed to create build directory"; exit 1; } cd build || { log_error "Failed to enter build directory"; exit 1; } cmake .. -DCMAKE_BUILD_TYPE=Release || { log_error "Failed to configure woj-sandbox"; exit 1; } make -j || { log_error "Failed to build woj-sandbox"; exit 1; } cd ../.. rm -f woj_launcher cp woj-sandbox/build/woj_launcher . rm -rf woj-sandbox } function build_nsjail { rm -rf nsjail-src git clone https://git.0x7f.app/woj/nsjail nsjail-src >/dev/null 2>&1 || { log_error "Failed to clone nsjail"; exit 1; } cd nsjail-src || { log_error "Failed to enter nsjail"; exit 1; } make -j || { log_error "Failed to build nsjail"; exit 1; } cd .. rm -f nsjail cp nsjail-src/nsjail . rm -rf nsjail-src } log_info "Building woj_launcher..." build_woj_launcher log_info "Building nsjail..." build_nsjail