Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 97 lines (85 sloc) 2.403 kb
9b54a97 Remove old incremental stuff, fix backup
Marc Lagrange authored
1 #!/usr/bin/env bash
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
2 # Minecraft CraftBukkit script tool
3 # Created by Marc 'rhaamo' Lagrange <rhaamo@gruik.at>
4 # Under http://sam.zoy.org/wtfpl/
5
6 ### EDIT HERE ###
7 # Lang for errors, currently supported: fr, en
8 MCS_OUTPUT_LANG=fr
9
10 MC_PATH=/usr/minecraft/home
11 MC_SCRIPT_PATH_LIB=${MC_PATH}/bin/minecraft_tool
12 MC_JAR_NAME="craftbukkit-0.0.1-SNAPSHOT.jar"
13 SCREEN_NAME="minecraft"
14 MEMALOC=2048
15 DISPLAY_ON_LAUNCH=0
16
17 WORLD_NAME="world"
18
19 BKUP_PATH=/usr/minecraft/www/nux/backup
20 BKUP_FULL_LINK=${BKUP_PATH}/${WORLD_NAME}_full.tgz
21 BKUP_URL="http://nux.no-ip.org/nux/backup/" # With trailing "/" !
22
22eb50d Improve rotation log; add cleanlogs target
Marc Lagrange authored
23 LOGS_DIR=${MC_PATH}/logs
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
24 LOGS_DAYS=7
22eb50d Improve rotation log; add cleanlogs target
Marc Lagrange authored
25 LOGS_OTHER_FILENAMES="worldedit.log" # Other logs in $MC_PATH
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
26 ### END OF EDIT ###
27
28 ### DONT TOUCH HERE NOW ###
29
30 MTOOL_BIN_NAME_BASENAME=`basename $0`
31 MTOOL_BIN_NAME_FULLPATH=$0
32
33 . ${MC_SCRIPT_PATH_LIB}/lang.${MCS_OUTPUT_LANG}.sh
34 . ${MC_SCRIPT_PATH_LIB}/check_config.sh
35 check_configuration
36 . ${MC_SCRIPT_PATH_LIB}/utils.sh
37 . ${MC_SCRIPT_PATH_LIB}/start_stop.sh
38 . ${MC_SCRIPT_PATH_LIB}/logs.sh
39 . ${MC_SCRIPT_PATH_LIB}/backups.sh
40
41 usage() {
42 echo "Usage: $0 opts"
43 echo " Options:"
44 echo " status ${MCS_LANG_MSCRIPT_OPT_STATUS}"
45 echo " start [force] ${MCS_LANG_MSCRIPT_OPT_START}"
46 echo " stop ${MCS_LANG_MSCRIPT_OPT_STOP}"
47 echo " restart [warn] ${MCS_LANG_MSCRIPT_OPT_RESTART}"
22eb50d Improve rotation log; add cleanlogs target
Marc Lagrange authored
48 echo " rotatelogs ${MCS_LANG_MSCRIPT_OPT_ROTATELOGS}"
49 echo " cleanlogs ${MCS_LANG_MSCRIPT_OPT_CLEANLOGS} server.log ${LOGS_OTHER_FILENAMES}"
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
50 echo " backup ${MCS_LANG_MSCRIPT_OPT_BACKUP}"
c5a70c8 Add screen target: screen -x
Marc Lagrange authored
51 echo " screen ${MCS_LANG_MSCRIPT_OPT_SCREEN}"
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
52 exit 1
53 }
54
55 if ! [ $# -gt 0 ]; then
56 if [ $ONLINE -eq 1 ]; then
57 if [ ${DISPLAY_ON_LAUNCH} -eq 1 ]; then
58 display # the minecraft screen
59 else
60 usage # display usage
61 fi
62 else
63 echo ${MCS_LANG_LIB_UTILS_SERVER_SEEMS_OFFLINE}
64 fi
65 fi
66
67 case $1 in
68 status)
69 display_minecraft_status # Show minecraft status
70 ;;
71 start)
72 opts_minecraft_start # Start minecraft server
73 ;;
74 stop)
503c1e7 Fix typo
Marc Lagrange authored
75 server_stop $2 # Stop minecraft server
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
76 ;;
77 restart)
fe28486 Fix restart warning
Marc Lagrange authored
78 opts_minecraft_restart $2 $3 # Restart minecraft server
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
79 ;;
80 rotatelogs)
81 opts_minecraft_rotatelogs # Rotate logs
82 ;;
22eb50d Improve rotation log; add cleanlogs target
Marc Lagrange authored
83 cleanlogs)
84 opts_minecraft_cleanlogs # Clean current log
85 ;;
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
86 backup)
87 opts_minecraft_backup # Create world backup
c5a70c8 Add screen target: screen -x
Marc Lagrange authored
88 ;;
89 screen)
90 opts_minecraft_screen # Attach minecraft screen
91 ;;
fe28486 Fix restart warning
Marc Lagrange authored
92 *)
93 usage
94 ;;
c6e0866 First import, can status, start, stop, restart, rotatelog and backups
Marc Lagrange authored
95 esac
503c1e7 Fix typo
Marc Lagrange authored
96 exit 0
Something went wrong with that request. Please try again.