Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## Fix permissions of server directory
- if [ ! "$USER" = "" ]; then
- chown -R "$USER":"$USER" "$SERVER_DIR" &
- chmod 770 "$SERVER_DIR" &
- fi
- ## Comment the following line out to let the script check if the server port
- ## is occupied and kill the occupying proccess if required
- exit 0
- if [ ! "`which lsof`" = "" ]; then
- #Convert IP to a format accepted by lsof
- if [ "$IP" = "0.0.0.0" ]; then
- IP=""
- elif [ ! "$IP" = "" ]; then
- IP="@$IP"
- fi
- #Check for running processes on the same IP/port
- PID="`lsof -t -i$IP:$PORT`"
- if [ ! "$PID" = "" ]; then
- echo "Warning: Found running process using the same IP/port ($PID)"
- EXE="`file /proc/$PID/exe`"
- if [ ! "`echo $EXE | grep java`" = "" ]; then
- echo "Seems to be a Java process, killing $PID"
- kill -9 "$PID"
- else
- echo "Not a Java process, not killing $PID ($EXE)"
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment