2024-06-18 21:01:18 -04:00
#!/usr/bin/env bash
2024-09-17 15:00:22 -04:00
SCRIPT_DIR = $( cd -- " $( dirname -- " ${ BASH_SOURCE [0] } " ) " & > /dev/null && pwd )
2024-06-18 21:01:18 -04:00
for i in node npm git; do
if ! command -v $i & > /dev/null; then
echo " >> $i could not be found, please install "
exit
fi
done
# http-server not pulled, pulling
2024-09-17 15:00:22 -04:00
if [ ! -d " $SCRIPT_DIR /http-server " ] ; then
2024-06-18 21:01:18 -04:00
echo ">> This script will pull a lightweight nodejs http-server from https://github.com/http-party/http-server and make ./public avaiable as local http service, are you okay with this?"
read -p "Continue (y/n)?" choice
case " $choice " in
y| Y ) echo "yes" ; ;
n| N ) echo "no" ; ;
* ) echo "invalid" ; ;
esac
git clone https://github.com/http-party/http-server
fi
# http-server depends not pulled, pulling
2024-09-17 15:00:22 -04:00
if [ ! -d " $SCRIPT_DIR /http-server/node_modules/ " ] ; then
2024-06-18 21:01:18 -04:00
echo ">> http-server dependencies not pulled, pulling"
2024-09-17 15:00:22 -04:00
npm --prefix " $SCRIPT_DIR " /http-server i
2024-06-18 21:01:18 -04:00
fi
# website not built, building
2024-09-17 15:00:22 -04:00
if [ ! -d " $SCRIPT_DIR /../public " ] ; then
2024-06-18 21:01:18 -04:00
echo ">> website not build, building"
2024-09-17 15:00:22 -04:00
pushd " $SCRIPT_DIR " /..
2024-06-18 21:01:18 -04:00
ikiwiki --setup ./ikiwiki.setup
2024-09-17 15:00:22 -04:00
popd
2024-06-18 21:01:18 -04:00
fi
# starting server
echo ">> starting http server"
2024-09-17 15:00:22 -04:00
node " $SCRIPT_DIR " /http-server/bin/http-server -c-1 " $SCRIPT_DIR " /../public