#!/bin/sh ROOT=/usr/share/paheko/www #ROOT=~/fossil/paheko/src/www ROUTER=${ROOT}/_route.php PORT=8081 ADDRESS="127.0.0.1" VERBOSE=0 PID_FILE="${XDG_RUNTIME_DIR}/paheko/pid" [ ! -d `dirname $PID_FILE` ] && mkdir -p `dirname $PID_FILE` # Execute getopt ARGS=`getopt -o "pb:vh" -l "port:,bind:,verbose,help" -n "paheko" -- "$@"` # Bad arguments if [ $? -ne 0 ]; then exit 1 fi # A little magic eval set -- "$ARGS" # Now go through all the options while true; do case "$1" in -p|--port) PORT=$2 shift;; -b|--bind) ADDRESS=$2 shift;; -v|--verbose) VERBOSE=1 shift;; -h|--help) cat < /dev/null 2>&1 && rm -f $PID_FILE PHP_CLI_SERVER_WORKER=2 [ $VERBOSE = 1 ] && { php -S ${ADDRESS}:${PORT} -t ${ROOT} -d variables_order=EGPCS ${ROUTER} & } || { php -S ${ADDRESS}:${PORT} -t ${ROOT} -d variables_order=EGPCS ${ROUTER} > /dev/null 2>&1 & } php_pid=$! echo $php_pid > $PID_FILE sleep .5 [ "$CMD" = "ui" ] && { URL="http://${ADDRESS}:${PORT}/admin/" [ "$DISPLAY" != "" ] && { sensible-browser ${URL} & } || { www-browser ${URL} & } } || { wait $php_pid }