lfs-execline-scripts

Repository for execline scripts used in my linux-from-scratch builds
Log | Files | Refs

minecraft (971B)


      1 #!/usr/bin/execlineb -S1
      2 # Use execlineb -WS1 for debug/testing (errors out on bad syntax)
      3 
      4 # i did indeed write this script. however, i don't recommend using this for a server you're not just testing, as i personally recommend having a supervisor daemon, such as s6-supervise.
      5 
      6 envfile /etc/svc.d/default/minecraft.conf
      7 
      8 case -N -- $1
      9 {
     10 	"-s" { # start case:
     11 		foreground { printf "Starting minecraft server...\n" }
     12 		cd ${serverdir}
     13 		background { s6-setuidgid ${serveruser} java -jar ${serverdir}/${jarfile} ${javaflags} }
     14 		# save pid(s) to pidfile
     15 		redirfd -w 1 /run/minecraft.pid { pidof -o %PPID java }
     16 	}
     17 	"-k" { # kill case:
     18 		# set PID to pid of running process (may (not) exist)
     19 		#backtick PID { pidof -o %PPID dropbear }
     20 		backtick PID { cat /run/minecraft.pid }
     21 		foreground { printf "Stopping dropbear daemon...\n" }
     22 		forx x { $PID }
     23 		{
     24 			foreground { kill -9 $x }
     25 		}
     26 	}
     27 } # default case:
     28 foreground { /usr/bin/printf "usage: %s -s|-k\n" "$0" } exit 1