Whoops, let's leave the configure script in, and the linux scripts too for now
This commit is contained in:
parent
6ae46a7bf8
commit
48b0b082b6
10
.gitignore
vendored
10
.gitignore
vendored
@ -140,12 +140,10 @@ Thumbs.db
|
||||
/navigenerator.bat
|
||||
|
||||
# Linux script tools
|
||||
/athena-start
|
||||
/configure
|
||||
/configure.ac
|
||||
/function.sh
|
||||
/install.sh
|
||||
/uninstall.sh
|
||||
# /athena-start
|
||||
# /function.sh
|
||||
# /install.sh
|
||||
# /uninstall.sh
|
||||
|
||||
# dlls
|
||||
/libmysql.dll
|
||||
|
||||
227
athena-start
Executable file
227
athena-start
Executable file
@ -0,0 +1,227 @@
|
||||
#!/bin/sh
|
||||
|
||||
#source var/function
|
||||
. ./function.sh
|
||||
inst_launch_workaround
|
||||
|
||||
PATH=./:$PATH
|
||||
LOG_DIR="./log"
|
||||
|
||||
print_start() {
|
||||
# more << EOF
|
||||
echo "rAthena is starting..."
|
||||
echo " (c) 2021 rAthena Project"
|
||||
echo ""
|
||||
echo ""
|
||||
echo "checking..."
|
||||
#EOF
|
||||
}
|
||||
|
||||
get_status(){
|
||||
PIDFILE=.$1.pid
|
||||
if [ -e ${PIDFILE} ]; then
|
||||
PSRUN=$(pgrep -F ${PIDFILE})
|
||||
fi
|
||||
#return ${PSRUN} #seems to cause an issue for some os
|
||||
}
|
||||
|
||||
#checking if already started, launch and mark in log
|
||||
start_serv(){
|
||||
get_status $1
|
||||
if [ $2 ]; then #is logging on ?
|
||||
LOGFILE="$LOG_DIR/$1.launch.log"
|
||||
LOGRUN="$LOG_DIR/$1.log"
|
||||
FIFO="$1_fifo"
|
||||
echo "stat_serv, log is enabled"
|
||||
echo "My logfile=${LOGFILE}"
|
||||
if [ -z ${PSRUN} ]; then
|
||||
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
|
||||
mkfifo "$FIFO"; tee "$LOGRUN" < "$FIFO" & "./$1" > "$FIFO" 2>&1 & PID=$!
|
||||
#"./$1" > >(tee "$LOGRUN") 2>&1 & PID=$! #bash only
|
||||
echo "$PID" > .$1.pid
|
||||
echo "Server '$1' started at $(date +"%m-%d-%H:%M-%S")" | tee ${LOGFILE}
|
||||
else
|
||||
echo "Cannot start '$1', because it is already running p${PSRUN}" | tee ${LOGFILE}
|
||||
fi
|
||||
else
|
||||
if [ -z ${PSRUN} ]; then
|
||||
./$1&
|
||||
echo "$!" > .$1.pid
|
||||
echo "Server '$1' started at $(date +"%m-%d-%H:%M-%S")"
|
||||
else
|
||||
echo "Cannot start '$1', because it is already running p${PSRUN}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
watch_serv(){
|
||||
ulimit -Sc unlimited
|
||||
|
||||
#now checking status and looping
|
||||
count=0;
|
||||
while true; do
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
LOGFILE="$LOG_DIR/$i.launch.log"
|
||||
LOGRUN="$LOG_DIR/$i.log"
|
||||
FIFO=$i"_fifo"
|
||||
|
||||
get_status ${i}
|
||||
#echo "Echo id of $i is ${PSRUN}"
|
||||
if [ -z ${PSRUN} ]; then
|
||||
count=$((count+1))
|
||||
#echo "fifo=$FIFO"
|
||||
echo "server '$i' is down"
|
||||
echo "server '$i' is down" >> ${LOGFILE}
|
||||
echo "restarting server at time at $(date +"%m-%d-%H:%M-%S")"
|
||||
echo "restarting server at time at $(date +"%m-%d-%H:%M-%S")" >> ${LOGFILE}
|
||||
if [ -e $FIFO ]; then rm $FIFO; fi
|
||||
mkfifo "$FIFO"; tee "$LOGRUN" < "$FIFO" & "./$i" > "$FIFO" 2>&1 & PID=$!
|
||||
echo "$PID" > .$i.pid
|
||||
if [ $2 ] && [ $2 -lt $count ]; then break; fi
|
||||
fi
|
||||
done
|
||||
sleep $1
|
||||
done
|
||||
}
|
||||
|
||||
restart(){
|
||||
$0 stop
|
||||
if [ $1 ]; then sleep $1; fi
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
FIFO="$1_fifo"
|
||||
while true; do
|
||||
get_status ${i}
|
||||
if [ ${PSRUN} ]; then echo "'${i}' is still running p${PSRUN} waiting for the process to end"; sleep 2;
|
||||
else
|
||||
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
$0 start
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'start')
|
||||
print_start
|
||||
check_files
|
||||
echo "Check complete."
|
||||
echo "Looks like a good, nice rAthena!"
|
||||
if [ "$2" = "--enlog" ]; then
|
||||
ENLOG=1
|
||||
if [ ! -d "$LOG_DIR" ]; then mkdir -p $LOG_DIR; fi
|
||||
echo "Logging is enabled in $LOG_DIR"
|
||||
else
|
||||
echo "Logging is disabled"
|
||||
fi
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
start_serv $i $ENLOG
|
||||
done
|
||||
echo "rAthena was started."
|
||||
;;
|
||||
'watch')
|
||||
if [ ! -d "$LOG_DIR" ]; then mkdir -p $LOG_DIR; fi
|
||||
if [ -z $2 ]; then Restart_count=10; else Restart_count=$2; fi
|
||||
if [ -z $3 ]; then Restart_sleep=3; else Restart_sleep=$3; fi
|
||||
echo "Going to watch rAthena for restart_count = $Restart_count, restart_sleep = $Restart_sleep"
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
start_serv $i 1
|
||||
done
|
||||
watch_serv $Restart_count $Restart_sleep
|
||||
echo "Watching rAthena now."
|
||||
;;
|
||||
'stop')
|
||||
for i in ${W_SRV} ${M_SRV} ${C_SRV} ${L_SRV}
|
||||
do
|
||||
PIDFILE=.${i}.pid
|
||||
if [ -e ./${PIDFILE} ]; then
|
||||
kill $(cat ${PIDFILE})
|
||||
|
||||
while true; do
|
||||
get_status ${i}
|
||||
if [ ${PSRUN} ]; then echo "'${i}' is still running p${PSRUN} waiting for the process to end"; sleep 2;
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
rm ${PIDFILE}
|
||||
fi
|
||||
done
|
||||
;;
|
||||
'restart')
|
||||
restart "$@"
|
||||
;;
|
||||
'status')
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
get_status ${i}
|
||||
if [ ${PSRUN} ]; then echo "'${i}' is running p${PSRUN}"; else echo "'${i}' seems to be down"; fi
|
||||
done
|
||||
;;
|
||||
'val_runonce')
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./$i --run-once > "log/$i.runonce.leak"
|
||||
done
|
||||
;;
|
||||
'valchk')
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./$i > "log/$i.runonce.leak"
|
||||
done
|
||||
;;
|
||||
'help')
|
||||
case $2 in
|
||||
'start')
|
||||
echo "syntax: 'start {--enlog}'"
|
||||
echo "This option will start the servers"
|
||||
echo "--enlog will write all terminal output into a log/\$servname.log file"
|
||||
;;
|
||||
'stop')
|
||||
echo "This option will shut the servers down"
|
||||
;;
|
||||
'restart')
|
||||
echo "syntax: 'restart {<delay>}'"
|
||||
echo "This option will wait for the given delay and will attempt to restart the servers afterwards"
|
||||
echo "Note: Even if the delay is over it will wait until the pid is finished before attempting to restart the servers"
|
||||
;;
|
||||
'status')
|
||||
echo "syntax: 'status'"
|
||||
echo "This option will let you know whether the server are running or not"
|
||||
echo "Note: This option is based on PID and requires that you have launched the servers with this script too"
|
||||
echo "If this was not the case please use something like 'ps ax | grep server' to check their status"
|
||||
;;
|
||||
'watch')
|
||||
echo "syntax: 'watch {<restart_interval> <restart_count>}'"
|
||||
echo "The watch option allows you to automatically restart the servers when one of them was stopped"
|
||||
echo "<restart_interval> delay in seconds before rechecking if a server is down (default 10) "
|
||||
echo "<restart_count> how many times the servers should be restarted (default 3), (-1=indefinitly)"
|
||||
;;
|
||||
'val_runonce')
|
||||
echo "syntax: 'val_runonce'"
|
||||
echo "This option will run valgrind with run-once to check the servers"
|
||||
;;
|
||||
'valchk')
|
||||
echo "syntax: 'valchk'"
|
||||
echo "This option will run valgrind with the servers"
|
||||
;;
|
||||
*)
|
||||
echo "Please specify a command you would like more info on { start | stop | restart | status | watch }"
|
||||
read -p "Enter a valid command: " readEnterKey
|
||||
$0 "help" $readEnterKey
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: athena-start { start | stop | restart | status | watch | help | val_runonce | valchk }"
|
||||
read -p "Enter a valid option: " readEnterKey
|
||||
$0 $readEnterKey
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
1374
configure.ac
Normal file
1374
configure.ac
Normal file
File diff suppressed because it is too large
Load Diff
27
function.sh
Executable file
27
function.sh
Executable file
@ -0,0 +1,27 @@
|
||||
L_SRV=login-server
|
||||
C_SRV=char-server
|
||||
M_SRV=map-server
|
||||
W_SRV=web-server
|
||||
INST_PATH=/opt
|
||||
PKG=rathena
|
||||
PKG_PATH="${INST_PATH}/${PKG}"
|
||||
|
||||
check_files() {
|
||||
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
|
||||
do
|
||||
if [ ! -f ./$i ]; then
|
||||
echo "$i does not exist... exiting..."
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
check_inst_right(){
|
||||
if [ ! -w "${INST_PATH}" ]; then echo "You must have sudo right to use this install (write/read permission in ${INST_PATH}/ )" && exit; fi
|
||||
}
|
||||
|
||||
inst_launch_workaround(){
|
||||
if [ -d "${PKG_PATH}" ]; then
|
||||
if [ "$(pwd)" != "${PKG_PATH}" ]; then cd "${PKG_PATH}"; fi
|
||||
fi
|
||||
}
|
||||
45
install.sh
Executable file
45
install.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#source var/function
|
||||
. ./function.sh
|
||||
|
||||
#read -p "WARNING: This script is experimental. Press Ctrl+C to cancel or Enter to continue." readEnterKey
|
||||
|
||||
# NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this
|
||||
# separately; see below.
|
||||
TEMP=$(getopt -o d: -l destdir: -- "$@")
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${TEMP}"
|
||||
|
||||
eval set -- "${TEMP}"
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
(-d | --destdir) PKG_PATH="$2"; shift;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "destdir = ${PKG_PATH} "
|
||||
check_inst_right
|
||||
check_files
|
||||
mkdir -p "${PKG_PATH}/bin/"
|
||||
mkdir -p "${PKG_PATH}/etc/${PKG}/"
|
||||
mkdir -p "${PKG_PATH}/usr/${PKG}/"
|
||||
mkdir -p "${PKG_PATH}/var/${PKG}/log"
|
||||
|
||||
#we copy all file into opt/ dir and treat dir like normal unix arborescence
|
||||
cp -r db/ "${PKG_PATH}/var/${PKG}/db"
|
||||
if [ -d log ]; then cp -r log/* "${PKG_PATH}/var/${PKG}/log/"; fi
|
||||
cp -r conf/ "${PKG_PATH}/etc/${PKG}/conf"
|
||||
cp -r npc/ "${PKG_PATH}/usr/${PKG}/npc"
|
||||
cp athena-start "${PKG_PATH}/"
|
||||
cp *-server* "${PKG_PATH}/bin/"
|
||||
|
||||
ln -fs "${PKG_PATH}/var/${PKG}/db/" "${PKG_PATH}/db"
|
||||
ln -fs "${PKG_PATH}/var/${PKG}/log/" "${PKG_PATH}/log"
|
||||
ln -fs "${PKG_PATH}/etc/${PKG}/conf/" "${PKG_PATH}/conf"
|
||||
ln -fs "${PKG_PATH}/usr/${PKG}/npc/" "${PKG_PATH}/npc"
|
||||
ln -fs "${PKG_PATH}/athena-start" "/usr/bin/${PKG}"
|
||||
for f in $(ls "${PKG_PATH}/bin/") ; do ln -fs "${PKG_PATH}/bin/${f}" "${PKG_PATH}/${f}"; done
|
||||
echo "Installation is done. You can now control the server with '${PKG} start'"
|
||||
22
uninstall.sh
Executable file
22
uninstall.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
#source var/function
|
||||
. ./function.sh
|
||||
echo "My pkg path is ${PKG_PATH}"
|
||||
|
||||
check_inst_right
|
||||
read -p "WARNING: This script is experimental. Press Ctrl+C to cancel or Enter to continue." readEnterKey
|
||||
case $1 in
|
||||
'bin')
|
||||
echo "Starting binary cleanup"
|
||||
rm -rf "${PKG_PATH:?}"/bin/*
|
||||
echo "Binary files have been deleted"
|
||||
;;
|
||||
'all')
|
||||
echo "Starting uninstall"
|
||||
rm -rf "${PKG_PATH:?}"
|
||||
rm -rf "/usr/bin/${PKG:?}"
|
||||
echo "Uninstallation has succeed"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: Please enter a target './uninstall { all | bin }'"
|
||||
esac
|
||||
Loading…
x
Reference in New Issue
Block a user