summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt1
-rw-r--r--athena-start237
-rw-r--r--src/login/login.c2
-rw-r--r--start109
4 files changed, 294 insertions, 55 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 6d1ed241a..ed34bd94c 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -6,6 +6,7 @@ GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALAR
2006/03/26
+ * Added jAthena's new start and athena-start shell scripts. [Lance]
* Changed status_point/skill_point to unsigned short. Adjusted the code as
necessary to prevent overflows. [Skotlex]
* itemdb_exists and itemdb_searchname should now ignore dummy_item matches. [Skotlex]
diff --git a/athena-start b/athena-start
index f21dccf71..85cc18bc2 100644
--- a/athena-start
+++ b/athena-start
@@ -1,11 +1,14 @@
#!/bin/sh
# athena starting script by rowla
+# chkconfig: 345 99 01
+# description: start and stop athena service
+
PATH=./:$PATH
-L_SRV=login-server
-C_SRV=char-server
-M_SRV=map-server
+L_SRV=./bin/login-server
+C_SRV=./bin/char-server
+M_SRV=./bin/map-server
L_SRV_C=./conf/login_athena.conf
C_SRV_C=./conf/char_athena.conf
C_SRV_C2=./conf/inter_athena.conf
@@ -30,12 +33,82 @@ echo "checking..."
}
check_account() {
+ if [ ! -d ./save ]; then
+ mkdir ./save
+ fi
+
+ if [ ! -d ./log ]; then
+ mkdir ./log
+ fi
+
+ if [ ! -d ./conf/import ]; then
+ mkdir ./conf/import
+ fi
+
if [ ! -f ./save/account.txt ]; then
- echo "0 s1 p1 - S 0" > save/account.txt
- echo "1 s2 p2 - S 0" >>save/account.txt
- echo "2 s3 p3 - S 0" >>save/account.txt
- echo "3 s4 p4 - S 0" >>save/account.txt
- echo "4 s5 p5 - S 0" >>save/account.txt
+ i=0
+ while [ $i -le 4 ];
+ do
+ echo -e "$i\ts`expr $i + 1`\tp`expr $i + 1`\t-\tS\t0\t0\r" >> save/account.txt
+ i=`expr $i + 1`
+ done
+ fi
+
+ if [ ! -f ./save/athena.txt ]; then
+ echo -n > save/athena.txt
+ fi
+
+ if [ ! -f ./save/bank.txt ]; then
+ echo -n > save/bank.txt
+ fi
+
+ if [ ! -f ./save/guild.txt ]; then
+ echo -n > save/guild.txt
+ fi
+
+ if [ ! -f ./save/party.txt ]; then
+ echo -n > save/party.txt
+ fi
+
+ if [ ! -f ./save/pet.txt ]; then
+ echo -n > save/pet.txt
+ fi
+
+ if [ ! -f ./save/storage.txt ]; then
+ echo -n > save/storage.txt
+ fi
+
+ if [ ! -f ./save/castle.txt ]; then
+ i=0
+ while [ $i -le 19 ];
+ do
+ echo -e "$i,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r" >> save/castle.txt
+ i=`expr $i + 1`
+ done
+ fi
+
+ if [ ! -f ./conf/import/atcommand_conf.txt ]; then
+ echo -n > conf/import/atcommand_conf.txt
+ fi
+
+ if [ ! -f ./conf/import/battle_conf.txt ]; then
+ echo -n > conf/import/battle_conf.txt
+ fi
+
+ if [ ! -f ./conf/import/char_conf.txt ]; then
+ echo -n > conf/import/char_conf.txt
+ fi
+
+ if [ ! -f ./conf/import/inter_conf.txt ]; then
+ echo -n > conf/import/inter_conf.txt
+ fi
+
+ if [ ! -f ./conf/import/login_conf.txt ]; then
+ echo -n > conf/import/login_conf.txt
+ fi
+
+ if [ ! -f ./conf/import/map_conf.txt ]; then
+ echo -n > conf/import/map_conf.txt
fi
}
@@ -55,30 +128,150 @@ echo "Check done."
echo "Looks good, have a nice athena!"
#EOF
}
-
+
+process_check() {
+ # check login server
+ if [ ! -f ${L_SRV}.pid ]; then
+ login=0
+ else
+ login=`cat ${L_SRV}.pid`
+ login=$(ps ax | grep "${L_SRV}" | grep "${login}" | wc -l)
+ fi
+
+ # check char server
+ if [ ! -f ${C_SRV}.pid ]; then
+ char=0
+ else
+ char=`cat ${C_SRV}.pid`
+ char=$(ps ax | grep "${C_SRV}" | grep "${char}" | wc -l)
+ fi
+
+ # check map server
+ if [ ! -f ${M_SRV}.pid ]; then
+ map=0
+ else
+ map=`cat ${M_SRV}.pid`
+ map=$(ps ax | grep "${M_SRV}" | grep "${map}" | wc -l)
+ fi
+
+ # echo "check: ${login} ${char} ${map}"
+ echo `expr ${login} + ${char} + ${map}`
+}
case $1 in
'start')
- print_start
- check_account
- check_files
+ if [ `process_check` -eq 0 ]; then
+ print_start
+ check_account
+ check_files
- exec ./${L_SRV} ${L_SRV_C}&
-# exec ./${C_SRV} ${C_SRV_C} ${C_SRV_C2} > /dev/null&
-# exec ./${M_SRV} ${M_SRV_C} ${M_SRV_C2} > /dev/null&
- exec ./${C_SRV} ${C_SRV_C} ${C_SRV_C2}&
- exec ./${M_SRV} ${M_SRV_C} ${M_SRV_C2} ${M_SRV_C3} ${M_SRV_C4} ${M_SRV_C5} ${M_SRV_C6}&
+ exec ${L_SRV} ${L_SRV_C}&
+# exec ${C_SRV} ${C_SRV_C} ${C_SRV_C2} > /dev/null&
+# exec ${M_SRV} ${M_SRV_C} ${M_SRV_C2} > /dev/null&
+ exec ${C_SRV} ${C_SRV_C} ${C_SRV_C2}&
+# exec nice -n -20 ${M_SRV} ${M_SRV_C} ${M_SRV_C2} ${M_SRV_C3} ${M_SRV_C4} ${M_SRV_C5} ${M_SRV_C6}&
+ exec ${M_SRV} ${M_SRV_C} ${M_SRV_C2} ${M_SRV_C3} ${M_SRV_C4} ${M_SRV_C5} ${M_SRV_C6}&
- echo "Now Started Athena."
+ echo "Now Started Athena."
+ else
+ echo "Athena is already running..."
+ fi
;;
'stop')
- ps ax | grep -E "${L_SRV}|${C_SRV}|${M_SRV}" | awk '{print $1}' | xargs kill -9
+ # check map server
+ if [ -f ${M_SRV}.pid ]; then
+ map=`cat ${M_SRV}.pid`
+ map=$(ps ax | grep "${M_SRV}" | grep "${map}" | wc -l)
+ if [ ${map} -ne 0 ]; then
+ kill `cat ${M_SRV}.pid`
+ fi
+ fi
+
+ # check char server
+ if [ -f ${C_SRV}.pid ]; then
+ char=`cat ${C_SRV}.pid`
+ char=$(ps ax | grep "${C_SRV}" | grep "${char}" | wc -l)
+ if [ ${char} -ne 0 ]; then
+ kill `cat ${C_SRV}.pid`
+ fi
+ fi
+
+ # check login server
+ if [ -f ${L_SRV}.pid ]; then
+ login=`cat ${L_SRV}.pid`
+ login=$(ps ax | grep "${L_SRV}" | grep "${login}" | wc -l)
+ if [ ${login} -ne 0 ]; then
+ kill `cat ${L_SRV}.pid`
+ fi
+ fi
+ ;;
+ 'kill')
+ # check map server
+ if [ -f ${M_SRV}.pid ]; then
+ map=`cat ${M_SRV}.pid`
+ map=$(ps ax | grep "${M_SRV}" | grep "${map}" | wc -l)
+ if [ ${map} -ne 0 ]; then
+ kill -9 `cat ${M_SRV}.pid`
+ fi
+ fi
+
+ # check char server
+ if [ -f ${C_SRV}.pid ]; then
+ char=`cat ${C_SRV}.pid`
+ char=$(ps ax | grep "${C_SRV}" | grep "${char}" | wc -l)
+ if [ ${char} -ne 0 ]; then
+ kill -9 `cat ${C_SRV}.pid`
+ fi
+ fi
+
+ # check login server
+ if [ -f ${L_SRV}.pid ]; then
+ login=`cat ${L_SRV}.pid`
+ login=$(ps ax | grep "${L_SRV}" | grep "${login}" | wc -l)
+ if [ ${login} -ne 0 ]; then
+ kill -9 `cat ${L_SRV}.pid`
+ fi
+ fi
;;
'restart')
- $0 stop
- $0 start
+ if [ `process_check` -eq 0 ]; then
+ $0 start
+ else
+ # check login server
+ if [ ! -f ${L_SRV}.pid ]; then
+ login=0
+ else
+ login=`cat ${L_SRV}.pid`
+ login=$(ps ax | grep "${L_SRV}" | grep "${login}" | wc -l)
+ fi
+ if [ ${login} -eq 0 ]; then
+ exec ${L_SRV} ${L_SRV_C}&
+ fi
+
+ # check char server
+ if [ ! -f ${C_SRV}.pid ]; then
+ char=0
+ else
+ char=`cat ${C_SRV}.pid`
+ char=$(ps ax | grep "${C_SRV}" | grep "${char}" | wc -l)
+ fi
+ if [ ${char} -eq 0 ]; then
+ exec ${C_SRV} ${C_SRV_C} ${C_SRV_C2}&
+ fi
+
+ # check map server
+ if [ ! -f ${M_SRV}.pid ]; then
+ map=0
+ else
+ map=`cat ${M_SRV}.pid`
+ map=$(ps ax | grep "${M_SRV}" | grep "${map}" | wc -l)
+ fi
+ if [ ${map} -eq 0 ]; then
+ exec ${M_SRV} ${M_SRV_C} ${M_SRV_C2} ${M_SRV_C3} ${M_SRV_C4} ${M_SRV_C5} ${M_SRV_C6}&
+ fi
+ fi
;;
*)
- echo "Usage: athena-start { start | stop | restart }"
+ echo "Usage: athena-start { start | stop | kill | restart }"
;;
esac
diff --git a/src/login/login.c b/src/login/login.c
index 4ecdd2b80..797fbd0b6 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -3088,7 +3088,7 @@ int parse_login(int fd) {
WFIFOHEAD(fd, 23);
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 3; // 3 = Rejected from Server
- WFIFOSET(fd,23);
+ WFIFOSET(fd,3);
RFIFOSKIP(fd,(RFIFOW(fd,0) == 0x64) ? 55 : 47);
break;
}
diff --git a/start b/start
index 2a9dfd060..82cfb7a40 100644
--- a/start
+++ b/start
@@ -1,32 +1,77 @@
-#!/bin/bash
-
-./athena-start start
-sleep 30
-
-while [ true ] ; do
-if [ " 0" = "$(ps | grep -e login | wc -l)" ] ||
- [ " 0" = "$(ps | grep -e char | wc -l)" ] ||
- [ " 0" = "$(ps | grep -e map | wc -l)" ]; then
-printf "Error:"
-date
- sleep 10
- printf "Checking:"
- date
- if [ " 0" = "$(ps | grep -e login | wc -l)" ] ||
- [ " 0" = "$(ps | grep -e char | wc -l)" ] ||
- [ " 0" = "$(ps | grep -e map | wc -l)" ]; then
- printf "Error Confirmation:"
- date
- printf "Restoration:"
- date
- ./athena-start start
- else
- printf "Check Miss Sorry:"
- date
- fi
-#else
-#printf "Check OK:"
-#date
-fi
-sleep 10
-done \ No newline at end of file
+#!/bin/sh
+
+# Athena自動再起動スクリプト
+#
+# [USAGE] ./start
+#
+# 既にAthenaを起動した状態では実行しないで下さい。
+# サーバーの状態を確認するスクリプトが動作するので、シェルに戻りません。
+# Athenaを止めたいときは Ctrl+C で終了してください。
+# 
+# もしくは ./start & としてバックグラウンドで起動すると
+# シェルに戻ってきますが、サーバーの停止が少し面倒です。
+
+L_SRV=./bin/login-server
+C_SRV=./bin/char-server
+M_SRV=./bin/map-server
+
+process_check() {
+ # check login server
+ if [ ! -f ${L_SRV}.pid ]; then
+ login=0
+ else
+ login=`cat ${L_SRV}.pid`
+ login=$(ps ax | grep "${L_SRV}" | grep "${login}" | wc -l)
+ fi
+
+ # check char server
+ if [ ! -f ${C_SRV}.pid ]; then
+ char=0
+ else
+ char=`cat ${C_SRV}.pid`
+ char=$(ps ax | grep "${C_SRV}" | grep "${char}" | wc -l)
+ fi
+
+ # check map server
+ if [ ! -f ${M_SRV}.pid ]; then
+ map=0
+ else
+ map=`cat ${M_SRV}.pid`
+ map=$(ps ax | grep "${M_SRV}" | grep "${map}" | wc -l)
+ fi
+
+ # echo "check: ${login} ${char} ${map}"
+ echo `expr ${login} + ${char} + ${map}`
+}
+
+if [ `process_check` -ne 0 ]; then
+ echo "Athena is already running..."
+else
+ ./athena-start start
+ sleep 30
+
+ while true
+ do
+ if [ `process_check` -lt 3 ]; then
+ printf "Error:"
+ date
+ sleep 10
+ printf "Checking:"
+ date
+ if [ `process_check` -lt 3 ]; then
+ printf "Error Confirmation:"
+ date
+ printf "Restoration:"
+ date
+ ./athena-start restart
+ else
+ printf "Check Miss Sorry:"
+ date
+ fi
+ #else
+ # printf "Check OK:"
+ # date
+ fi
+ sleep 10
+ done
+fi