#!/bin/bash # # Start diaspora websocket and main services # # Is someone listening on the port already? (ipv4 only test ?) PORT=3000 while getopts ":p:" OPTION do if [ $OPTION == 'p' ] then PORT=$OPTARG fi done services=$( netstat -nl | grep ":$PORT[ \t]") test -n "$services" && { echo "Warning: something is already using port "$PORT echo " $services" exit } # Check if Mongo is running if ! ps ax | grep -v grep | grep mongod >/dev/null then echo "Mongod not started" else mkdir -p -v log/thin/ #force AGPL test -w public -a ! -e public/source.tar && tar cf public/source.tar --exclude='source.tar' -X .gitignore * test -e public/source.tar || { echo "Can't find, or even create, public/source.tar. Giving up" exit 2 } bundle exec ruby ./script/websocket_server.rb& bundle exec thin start $@ fi