changeset 2495:72a3b687e6ce

Update mapsearch SysV init scripts.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 19 Jun 2023 01:33:05 +0300
parents 28f3bf45d5d7
children 4b4ea2829e7e
files scripts/mapsearch.sysvinit scripts/mapsearch.sysvinit.cfg
diffstat 2 files changed, 77 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/mapsearch.sysvinit	Mon Jun 19 01:05:28 2023 +0300
+++ b/scripts/mapsearch.sysvinit	Mon Jun 19 01:33:05 2023 +0300
@@ -46,6 +46,7 @@
 
 THLIBS_DIR="${MAPSEARCH_DIR}/th-libs/"
 
+
 update_map_data()
 {
   if test ! -d "$MAPSEARCH_DIR/.hg"; then
@@ -66,93 +67,84 @@
 }
 
 
-MAPSEARCH_ARGS=""
-for SPEC in ${MAPSEARCH_MAPLIST}; do
-  MAP=$(echo "$SPEC"|cut -d : -f 1)
-  WXC=$(echo "$SPEC"|cut -d : -f 2)
-  WYC=$(echo "$SPEC"|cut -d : -f 3)
-  MAPSEARCH_ARGS="$MAPSEARCH_ARGS ${MAPSEARCH_DIR}/world/${MAP}.map:${MAPSEARCH_DIR}/world/${MAP}.loc:${MAP}:$WXC:$WYC"
-done
-
-
-#export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
-
 case "$1" in
   start)
-  	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
-	;;
+    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
-	;;
+    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
-	;;
+    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)
-  	update_map_data
-	log_daemon_msg "Restarting PupuMaps map search server" "mapsearch" || true
-	start-stop-daemon --stop --quiet --oknodo --retry 30 --remove-pidfile --pidfile "$MAPSEARCH_PIDFILE"
-  	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
-	;;
+    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)
-  	update_map_data
-	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_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
-	;;
+    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 $?
-	;;
+    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
+    log_action_msg "Usage: /etc/init.d/mapsearch {start|stop|reload|force-reload|restart|try-restart|status}" || true
+    exit 1
 esac
 
 exit 0
--- a/scripts/mapsearch.sysvinit.cfg	Mon Jun 19 01:05:28 2023 +0300
+++ b/scripts/mapsearch.sysvinit.cfg	Mon Jun 19 01:33:05 2023 +0300
@@ -26,8 +26,14 @@
 #MAPSEARCH_PIDFILE="/var/run/mapsearch.pid"
 
 
-# Set world center / origin
-MAPSEARCH_OPTS="$MAPSEARCH_OPTS -w 8192:8192"
-
-# List of maps with offsets to world origin
-MAPSEARCH_MAPLIST="laenor:1:1 rothikgen:1311:-1255 lucentium:-634:2345 furnachia:1211:1155 desolathya:-1210:820 renardy:2070:-910"
+# Set world center / origin and maps
+MAPSEARCH_OPTS="$MAPSEARCH_OPTS
+	-D ${MAPSEARCH_DIR}/world/
+	-w 8192:8192
+	laenor.map:laenor.loc:laenor:1:1
+	rothikgen.map:rothikgen.loc:rothikgen:1311:-1255
+	lucentium.map:lucentium.loc:lucentium:-634:2345
+	furnachia.map:furnachia.loc:furnachia:1211:1155
+	desolathya.map:desolathya.loc:desolathya:-1210:820
+	renardy.map:renardy.loc:renardy:2070:-910
+"