Commits

Jack Frost committed 1d8c1fb

creeper custom config

  • Participants
  • Parent commits e385b1e

Comments (0)

Files changed (1)

 backup_dir="$HOME/backup"
 tmp_dir="/tmp/$USER/creeper"
 
+java_exec=`which java`
 java_heapsize='1G'
 
 srv_jar_url='https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar'
 }
 
 creeper.start() {
-	srv_start_cmd="java -jar -Xmx${java_heapsize} -Xms${java_heapsize} minecraft_server.jar"
+	srv_start_cmd="$java_exec -jar -Xmx${java_heapsize} -Xms${java_heapsize} minecraft_server.jar"
 	cd "$srv_dir/$srv_name"
 	$srv_start_cmd > "$log_dir/$srv_name.log" 2>"$log_dir/$srv_name.err"
 }
 
 creeper.daemon() {
+	[[ "$java_exec" ]] || { java_exec=`which java`; }
+	[[ "$java_exec" ]] || {
+		creeper.err "Could not find java"
+		return 1
+	}
+
+	[[ "$flag_verbose" ]] && {
+		[[ `which java` ]] && [[ "$java_exec" == `which java` ]] || {
+			creeper.msg "(debug) Using an alternative java executable: $java_exec"
+		}
+	}
+
 	[[ "$srv_pid" ]] && {
 		blib.sys.pid_check "$srv_pid" && {
 			creeper.err "$srv_name is already running with PID: $srv_pid"
 
 # /functions
 
-while getopts "f" option; do
+while getopts "f:v" option; do
 	case "$option" in
 		f) foo="$OPTARG";;
+		v) export flag_verbose='1';;
 	esac
 done
 
 [[ "$srv_name" ]] || { creeper.usage; creeper.die 16; }
 [[ "$action" ]] || { action='status'; }
 
+[[ -f "$srv_dir/$srv_name/creeperrc" ]] && { 
+	source "$srv_dir/$srv_name/creeperrc"
+}
+
 srv_pidfile="$run_dir/$srv_name.pid"
 [[ -f "$srv_pidfile" ]] && { srv_pid=`cat "$srv_pidfile"`; }