+ basic packaging support, WiP

pack
Dominika Liberda 2021-12-06 13:18:57 +01:00
parent 0793241a3b
commit 1cb85c8e4a
2 changed files with 97 additions and 4 deletions

View File

@ -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

93
pack.sh Executable file
View File

@ -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'