mirror of
https://codeberg.org/bunbun/bunbun.dev
synced 2025-01-22 12:44:29 -08:00
34 lines
767 B
Plaintext
34 lines
767 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
command="fennel main.fnl"
|
||
|
kill_command="pkill -f 'main\.fnl'"
|
||
|
|
||
|
log_file="log"
|
||
|
|
||
|
usage="Usage: start-server [-h] [-l] [--log-file] [-k]
|
||
|
|
||
|
Options:
|
||
|
-h, --help Show this help message and exit
|
||
|
-l, --log Log requests in the log file
|
||
|
--log-file Set the log file
|
||
|
-k, --kill Kill the server and exit
|
||
|
|
||
|
"
|
||
|
|
||
|
for (( i=1; i<=$#; i++ )); do
|
||
|
if [[ "${!i}" == "-h" || "${!i}" == "--help" ]]; then
|
||
|
printf "$usage"
|
||
|
exit 0
|
||
|
elif [[ "${!i}" == "-l" || "${!i}" == "--log" ]]; then
|
||
|
command="${command} | tee ${log_file}"
|
||
|
elif [[ "${!i}" == "--log-file" ]]; then
|
||
|
((i++))
|
||
|
log_file="${!i}"
|
||
|
elif [[ "${!i}" == "-k" || "${!i}" == "--kill" ]]; then
|
||
|
eval "$kill_command"
|
||
|
exit 0
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
eval "${kill_command}; ${command} & disown"
|