Mercurial > hg > batmud > maputils
view scripts/mapsearch.sysvinit @ 2833:d0e186348cb2 default tip
Add mention of soft level limitation to 'Eightleg woods'.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 26 May 2024 20:33:53 +0300 |
parents | 72a3b687e6ce |
children |
line wrap: on
line source
#! /bin/sh ### BEGIN INIT INFO # Provides: mapsearch # Required-Start: $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: PupuMaps map search server ### END INIT INFO # SysV init script for MapSearch set -e MAPSEARCH_CFG="/etc/default/mapsearch" MAPSEARCH_BIN="/usr/sbin/mapsearch" MAPSEARCH_PIDFILE="/var/run/mapsearch.pid" if test ! -x "$MAPSEARCH_BIN"; then echo "$MAPSEARCH_BIN does not exist or is not executable." exit 0 fi umask 022 if test -f "$MAPSEARCH_CFG"; then . "$MAPSEARCH_CFG" else echo "$MAPSEARCH_CFG does not exist." exit 0 fi if test "x$MAPSEARCH_DIR" = "x"; then echo "MAPSEARCH_DIR not configured." exit 0 fi if test ! -d "$MAPSEARCH_DIR"; then echo "$MAPSEARCH_DIR does not exist." exit 0 fi . /lib/lsb/init-functions THLIBS_DIR="${MAPSEARCH_DIR}/th-libs/" update_map_data() { if test ! -d "$MAPSEARCH_DIR/.hg"; then hg clone "$MAPSEARCH_REPO" "$MAPSEARCH_DIR" else cd "$MAPSEARCH_DIR" && hg pull && hg update fi } update_daemon() { if test ! -d "$THLIBS_DIR/.hg"; then hg clone "$THLIBS_REPO" "$THLIBS_DIR" fi cd "$THLIBS_DIR" && hg pull && hg update cd "$MAPSEARCH_DIR" && make clean && make "bin/mapsearch" -j4 && cp "bin/mapsearch" "$MAPSEARCH_BIN" } case "$1" in start) update_daemon update_map_data log_daemon_msg "Starting PupuMaps map search server" "mapsearch" || true if start-stop-daemon --start --quiet --oknodo -m --background --pidfile "$MAPSEARCH_PIDFILE" --exec "$MAPSEARCH_BIN" -- $MAPSEARCH_ARGS $MAPSEARCH_OPTS; then log_end_msg 0 || true else log_end_msg 1 || true fi ;; stop) log_daemon_msg "Stopping PupuMaps map search server" "mapsearch" || true if start-stop-daemon --stop --quiet --oknodo --remove-pidfile --pidfile "$MAPSEARCH_PIDFILE"; then log_end_msg 0 || true else log_end_msg 1 || true fi ;; reload|force-reload) update_map_data log_daemon_msg "Reloading PupuMaps map search server's configuration" "mapsearch" || true if start-stop-daemon --stop --signal 1 --quiet --oknodo --remove-pidfile --pidfile "$MAPSEARCH_PIDFILE" --exec "$MAPSEARCH_BIN"; then log_end_msg 0 || true else log_end_msg 1 || true fi ;; restart) log_daemon_msg "Restarting PupuMaps map search server" "mapsearch" || true start-stop-daemon --stop --quiet --oknodo --retry 30 --remove-pidfile --pidfile "$MAPSEARCH_PIDFILE" update_map_data update_daemon if start-stop-daemon --start --quiet --oknodo -m --background --pidfile "$MAPSEARCH_PIDFILE" --exec "$MAPSEARCH_BIN" -- $MAPSEARCH_ARGS $MAPSEARCH_OPTS; then log_end_msg 0 || true else log_end_msg 1 || true fi ;; try-restart) log_daemon_msg "Restarting PupuMaps map search server" "mapsearch" || true RET=0 start-stop-daemon --stop --quiet --retry 30 --remove-pidfile --pidfile "$MAPSEARCH_PIDFILE" || RET="$?" update_map_data update_daemon case $RET in 0) # old daemon stopped if start-stop-daemon --start --quiet --oknodo -m --background --pidfile "$MAPSEARCH_PIDFILE" --exec "$MAPSEARCH_BIN" -- $MAPSEARCH_ARGS $MAPSEARCH_OPTS; then log_end_msg 0 || true else log_end_msg 1 || true fi ;; 1) # daemon not running log_progress_msg "(not running)" || true log_end_msg 0 || true ;; *) # failed to stop log_progress_msg "(failed to stop)" || true log_end_msg 1 || true ;; esac ;; status) status_of_proc -p "$MAPSEARCH_PIDFILE" "$MAPSEARCH_BIN" mapsearch && exit 0 || exit $? ;; *) log_action_msg "Usage: /etc/init.d/mapsearch {start|stop|reload|force-reload|restart|try-restart|status}" || true exit 1 esac exit 0