Skip to content

Instantly share code, notes, and snippets.

@nullkal
Created Aug 22, 2013
Embed
What would you like to do?
FreeBSD向けのMinecraft(bukkit)鯖 起動スクリプト。 必要なもの: Java, tmux, 鯖を配置した各ディレクトリに一つstart.sh(bukkit Wikiに書いてあるLinux用craftbukkit.shそのままでOK)
#!/bin/sh
# PROVIDE: mc-servers
# REQUIRE: LOGIN
. /etc/rc.subr
name="mc_servers"
rcval=mc_servers_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
load_rc_config $name
: ${mc_servers_enable:=no}
: ${mc_servers_dir:=/usr/local/share/mc_servers}
: ${mc_servers_user:=mc_servers}
mc_servers_start()
{
for dir in `find $mc_servers_dir -type d -depth 1`
do
su -l $mc_servers_user -c "tmux -CC new -d -s mc_`basename $dir` $dir/start.sh" > /dev/null
done
}
mc_servers_stop()
{
for dir in `find $mc_servers_dir -type d -depth 1`
do
su -l $mc_servers_user -c "tmux -CC send-keys -t mc_`basename $dir` 'stop' Enter" > /dev/null
su -l $mc_servers_user -c "tmux -CC attach -t mc_`basename $dir`" > /dev/null
done
}
load_rc_config $name
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment