From 1cb85c8e4a7b813c7fcd86e3e44ec8251dfa8cd5 Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Mon, 6 Dec 2021 13:18:57 +0100 Subject: [PATCH] + basic packaging support, WiP --- http.sh | 8 ++--- pack.sh | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 4 deletions(-) create mode 100755 pack.sh diff --git a/http.sh b/http.sh index 7688bcd..c5303cf 100755 --- a/http.sh +++ b/http.sh @@ -57,10 +57,10 @@ function ctrl_c() { echo -e "Cleaned up, exitting.\nHave an awesome day!!" } -if [[ ! -f "$(pwd)/http.sh" ]]; then - echo -e "Please run HTTP.sh inside it's designated directory\nRunning the script from arbitrary locations isn't supported." - exit 1 -fi +if [[ ! -f "$(pwd)/http.sh" ]]; then # packer-exclude + echo -e "Please run HTTP.sh inside it's designated directory\nRunning the script from arbitrary locations isn't supported." # packer-exclude + exit 1 # packer-exclude +fi # packer-exclude for i in $(cat src/dependencies.required); do diff --git a/pack.sh b/pack.sh new file mode 100755 index 0000000..f90083a --- /dev/null +++ b/pack.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# todo: +# - dependencies.optional dependencies.required +# - set namespace to '.' + + +function pack() { + echo "function __main() {" + cat http.sh + echo "}" + + echo "function __account() {" + cat src/account.sh + echo "}" + + echo "function __mail() {" + cat src/mail.sh + echo "}" + + echo "function __mime() {" + cat src/mime.sh + echo "}" + + echo "function __misc() {" + cat src/misc.sh + echo "}" + + echo "function __route() {" + cat src/route.sh + echo "}" + + echo "function __server() {" + cat src/server.sh + echo "}" + + echo "function __template() {" + cat src/template.sh + echo "}" + + echo "function __worker() {" + cat src/worker.sh + echo "}" + + #echo "function __res_101 {" + #cat src/response/101.sh + #echo "}" + + echo "function __res_200() {" + cat src/response/200.sh + echo "}" + + echo "function __res_401() {" + cat src/response/401.sh + echo "}" + + echo "function __res_403() {" + cat src/response/403.sh + echo "}" + + echo "function __res_404() {" + cat src/response/404.sh + echo "}" + + echo "function __res_listing() {" + cat src/response/listing.sh + echo "}" + + echo "function __res_proxy() {" + cat src/response/proxy.sh + echo "}" + + echo "function __template_head() {" + cat templates/head.sh + echo "}" + + #echo "function __ws() {" + #cat src/ws.sh + #echo "}" + echo '[[ "$1" == "server_int" ]] && __server + [[ "$1" == "debug" ]] && __main debug + [[ "$1" == "init" ]] && __main init + [[ "$1" == "" ]] && __main' +} + +pack | grep -v "packer-exclude" \ + | sed -E 's@source "*src/response/@__res_@g; + s@source "*src/@__@; + s@__.*@&MaeIsCuteUwU@; + s@\.sh"*MaeIsCuteUwU@@; + s@source "*templates/head.sh@__template_head@; + s@MaeIsCuteUwU@@g; + s@exit .*@return@; + s@-c src/server.sh@-c "$0 server_int"@g'