GithubHelp home page GithubHelp logo

Comments (10)

Ahtenus avatar Ahtenus commented on July 27, 2024

Have you set the right permissions? try chmod 755 /etc/init.d/minecraft
Den 16 jan 2012 19:26 skrev "littleclaz" <
[email protected]

:

Hello there.
Im having some issues with getting the script to work on OpenSUSE 12.1.
ive followed the instructions to the letter... Im having a problem getting
the script to activate and when it does it gives me a permission denied
even under root.. here is the output of my ssh:

linux-pcbl:/home/minecraft # ln -s minecraft /etc/init.d/
linux-pcbl:/home/minecraft # chkconfig --set minecraft on
minecraft: unknown service
linux-pcbl:/home/minecraft # insserv minecraft
insserv: minecraft: Too many levels of symbolic links
linux-pcbl:/home/minecraft #

and also:

linux-pcbl:/home/minecraft # ln /home/minecraft/minecraft
/etc/init.d/minecraft
linux-pcbl:/home/minecraft # chkconfig --set minecraft on
insserv: script minecraft is not an executable regular file, skipped!
insserv: Service network is missed in the runlevels 2 to use service webmin
linux-pcbl:/home/minecraft # /etc/init.d/minecraft start
-bash: /etc/init.d/minecraft: Permission denied

I cannot understand whats going on to be honest.. im not really a noob
when it comes to linux or opensuse to that fact as the last start script i
used from this one:
#!/bin/bash

/etc/init.d/minecraft

BEGIN INIT INFO

Provides: minecraft

Required-Start: $local_fs $remote_fs

Required-Stop: $local_fs $remote_fs

Should-Start: $network

Should-Stop: $network

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Minecraft server

Description: Init script for minecraft/bukkit server, with rolling

logs and use of ramdisk for less lag.

END INIT INFO

Created by Ahtenus

Based on http://www.minecraftwiki.net/wiki/Server_startup_script

Support for multiworld by Benni-chan

Log rolls without needing restarts by Solorvox

#############################
######### SETTINGS ##########
#############################

Name of server.jar file

SERVICE="craftbukkit-1.0.1-R1.jar"

Name to use for the screen instance

SCREEN="minecraft"

User that should run the server

USERNAME="minecraft"

Path to minecraft directory

MCPATH="/home/${USERNAME}/Server"

Number of CPUs/cores to use

CPU_COUNT=4

Initial memory usage

INITMEM="2048M"

Maximum amount of memory to use

MAXMEM="3072M"

Remember: give the ramdisk enough space, subtract from the total amount

of RAM available the size of your map and the RAM-consumption of your

base system.
INVOCATION="java -Xmx$MAXMEM -Xms$INITMEM -XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT
-XX:+AggressiveOpts -jar $SERVICE nogui"

Where the world backups should go

BACKUPPATH="/home/${USERNAME}/minebak"

Where the logs are copied with log-roll

LOGPATH="${MCPATH}/logs"

Where the whole minecraft directory is copied when whole-backup is

executed
WHOLEBACKUP="/home/${USERNAME}/serverbak"

Where the worlds are located on the disk. Can not be the same as MCPATH.

WORLDSTORAGE="${MCPATH}/worldstorage"

Path to the the mounted ramdisk default in Ubuntu: /dev/shm

RAMDISK="/dev/shm"

use tar or zip files for world backup

BACKUPFORMAT="tar"

ME=whoami
as_user() {
if [ $ME == $USERNAME ] ; then
bash -c "$1"
else
su - $USERNAME -c "$1"
fi
}
datepath() {
# datepath path filending-to-check returned-filending
if [ -e $1date +%F$2 ]
then
echo $1date +%FT%T$3
else
echo $1date +%F$3
fi
}
mc_start() {
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE >
/dev/null
then
echo "Tried to start but $SERVICE was already running!"
else
echo "$SERVICE was not running... starting."
cd $MCPATH
as_user "cd $MCPATH && screen -dmS $SCREEN $INVOCATION"
sleep 7
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE

/dev/null
then
echo "$SERVICE is now running."
else
echo "Could not start $SERVICE."
fi
fi
}

mc_saveoff() {
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE >
/dev/null
then
echo "$SERVICE is running... suspending saves"
as_user "screen -p 0 -S $SCREEN -X eval 'stuff
"save-off"\015'"
as_user "screen -p 0 -S $SCREEN -X eval 'stuff
"save-all"\015'"
sync
sleep 10
else
echo "$SERVICE was not running. Not suspending saves."
fi
}

mc_saveon() {
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE >
/dev/null
then
echo "$SERVICE is running... re-enabling saves"
as_user "screen -p 0 -S $SCREEN -X eval 'stuff
"save-on"\015'"
else
echo "$SERVICE was not running. Not resuming saves."
fi
}

mc_stop() {
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE >
/dev/null
then
echo "$SERVICE is running... stopping."
as_user "screen -p 0 -S $SCREEN -X eval 'stuff
"save-all"\015'"
sleep 10
as_user "screen -p 0 -S $SCREEN -X eval 'stuff
"stop"\015'"
sleep 7
else
echo "$SERVICE was not running."
fi
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE >
/dev/null
then
echo "$SERVICE could not be shut down... still running."
else
echo "$SERVICE is shut down."
fi
}
log_roll() {
if [ ! -d $LOGPATH ]; then
as_user "mkdir -p $LOGPATH"
fi
path=datepath $LOGPATH/server_ .log.gz .log
as_user "cp $MCPATH/server.log $path && gzip $path"
# only if previous command was successful
if [ $? -eq 0 ]; then
# turnacate the existing log without restarting server
as_user "cp /dev/null $MCPATH/server.log"
as_user "echo "Previous logs rolled to $path" >
$MCPATH/server.log "
else
echo "Failed to rotate logs to $LOGPATH/server_$path.log.gz"
fi

}
get_worlds() {
a=1
for NAME in $(ls $WORLDSTORAGE)
do
if [ -d $WORLDSTORAGE/$NAME ]
then
WORLDNAME[$a]=$NAME
if [ -e $WORLDSTORAGE/$NAME/ramdisk ]
then
WORLDRAM[$a]=true
else
WORLDRAM[$a]=false
fi
a=$a+1
fi
done
}
mc_whole_backup() {
as_user "mkdir -p $WHOLEBACKUP"
path=datepath $WHOLEBACKUP/mine_
as_user "cp -rP $MCPATH $path"
}
mc_world_backup() {
get_worlds
today="date +%F" # If you don't want a folder for each day change
to today=""
for INDEX in ${!WORLDNAME[@]}
do
echo "Backing up minecraft ${WORLDNAME[$INDEX]}"
as_user "mkdir -p $BACKUPPATH${today}"

           case "$BACKUPFORMAT" in
                   tar)
                           path=`datepath

$BACKUPPATH${today}/${WORLDNAME[$INDEX]}_ .tar.bz2 .tar.bz2 as_user "tar -hcjf $path $MCPATH/${WORLDNAME[$INDEX]}" ;; zip) path=datepath
$BACKUPPATH${today}/${WORLDNAME[$INDEX]}_ .zip .zip as_user "zip -rq $path $MCPATH/${WORLDNAME[$INDEX]}" ;; *) echo "$BACKUPFORMAT is no supported backup format" ;; esac done } check_links() { get_worlds for INDEX in ${!WORLDNAME[@]} do if [[ -L $MCPATH/${WORLDNAME[$INDEX]} || ! -a $MCPATH/${WORLDNAME[$INDEX]} ]] then link=ls -l $MCPATH/${WORLDNAME[$INDEX]} | awk
'{print $11}' if ${WORLDRAM[$INDEX]} then if [ "$link" != "$RAMDISK/${WORLDNAME[$INDEX]}" ] then as_user "rm -f $MCPATH/${WORLDNAME[$INDEX]}" as_user "ln -s $RAMDISK/${WORLDNAME[$INDEX]} $MCPATH/${WORLDNAME[$INDEX]}" echo "created link for ${WORLDNAME[$INDEX]}" fi else if [ "$link" != "${WORLDSTORAGE}/${WORLDNAME[$INDEX]}" ] then as_user "rm -f $MCPATH/${WORLDNAME[$INDEX]}" as_user "ln -s ${WORLDSTORAGE}/${WORLDNAME[$INDEX]} $MCPATH/${WORLDNAME[$INDEX]}" echo "created link for ${WORLDNAME[$INDEX]}" fi fi else echo "could not process ${WORLDNAME[$INDEX]}. please move all worlds to ${WORLDSTORAGE}." exit 1 fi done echo "links checked" } to_ram() { get_worlds for INDEX in ${!WORLDNAME[@]} do if ${WORLDRAM[$INDEX]} then if [ -L $MCPATH/${WORLDNAME[$INDEX]} ] then as_user "rsync -rt --exclude 'ramdisk' ${WORLDSTORAGE}/${WORLDNAME[$INDEX]}/ $RAMDISK/${WORLDNAME[$INDEX]}" echo "${WORLDNAME[$INDEX]} copied to ram" fi fi done } to_disk() { get_worlds for INDEX in ${!WORLDNAME[@]} do as_user "rsync -rt --exclude 'ramdisk' $MCPATH/${WORLDNAME[$INDEX]}/ ${WORLDSTORAGE}/${WORLDNAME[$INDEX]}" echo "${WORLDNAME[$INDEX]} copied to disk" done } mc_update() { if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null then echo "$SERVICE is running! Will not start update." else ### update minecraft_server.jar echo "Updating minecraft_server.jar...." MC_SERVER_URL=http://minecraft.net/wget -q -O -
http://www.minecraft.net/download.jsp | grep minecraft_server.jar |
cut -d " -f 2 as_user "cd $MCPATH && wget -q -O $MCPATH/minecraft_server.jar.update $MC_SERVER_URL" if [ -f $MCPATH/minecraft_server.jar.update ] then ifdiff $MCPATH/minecraft_server.jar
$MCPATH/minecraft_server.jar.update >/dev/null`
then
echo "You are already running the latest
version of the Minecraft server."
as_user "rm
$MCPATH/minecraft_server.jar.update"
else
as_user "mv
$MCPATH/minecraft_server.jar.update $MCPATH/minecraft_server.jar"
echo "Minecraft successfully updated."
fi
else
echo "Minecraft update could not be downloaded."
fi

           ### update craftbukkit

           echo "Updating craftbukkit...."
           as_user "cd $MCPATH && wget -q -O

$MCPATH/craftbukkit.jar.update
http://ci.bukkit.org/job/dev-CraftBukkit/promotion/latest/Recommended/artifact/target/craftbukkit-1.0.1-R1.jar
"
if [ -f $MCPATH/craftbukkit.jar.update ]
then
if diff $MCPATH/craftbukkit-1.0.1-R1.jar $MCPATH/craftbukkit.jar.update > /dev/null
then
echo "You are already running the latest
version of CraftBukkit."
as_user "rm $MCPATH/craftbukkit.jar.update"
else
as_user "mv $MCPATH/craftbukkit.jar.update
$MCPATH/craftbukkit-1.0.1-R1.jar"
echo "CraftBukkit successfully updated."
fi
else
echo "CraftBukkit update could not be downloaded."
fi
fi
}
change_ramdisk_state() {
if [ ! -e $WORLDSTORAGE/$1 ]
then
echo "World "$1" not found."
exit 1
fi

   if [ -e $WORLDSTORAGE/$1/ramdisk ]
   then
           rm $WORLDSTORAGE/$1/ramdisk
           echo "removed ramdisk flag from \"$1\""
   else
           touch $WORLDSTORAGE/$1/ramdisk
           echo "added ramdisk flag to \"$1\""
   fi
   echo "changes will only take effect after server is restarted."

}

case "$1" in
start)
# Starts the server
check_links
to_ram
mc_start
;;
stop)
# Stops the server
as_user "screen -p 0 -S $SCREEN -X eval 'stuff "say SERVER
SHUTTING DOWN!"\015'"
mc_stop
to_disk
;;
restart)
# Restarts the server
as_user "screen -p 0 -S $SCREEN -X eval 'stuff "say SERVER
REBOOT IN 10 SECONDS."\015'"
mc_stop
to_disk
check_links
to_ram
mc_start
;;
backup)
# Backups world
as_user "screen -p 0 -S $SCREEN -X eval 'stuff "say
Backing up world."\015'"
mc_saveoff
to_disk
mc_world_backup
mc_saveon
as_user "screen -p 0 -S $SCREEN -X eval 'stuff "say Backup
complete."\015'"
;;
whole-backup)
# Backup everything
mc_whole_backup
;;
update)
#update minecraft_server.jar and craftbukkit.jar (thanks
karrth)
as_user "screen -p 0 -S $SCREEN -X eval 'stuff "say SERVER
UPDATE IN 10 SECONDS."\015'"
mc_stop
to_disk
mc_whole_backup
mc_update
check_links
mc_start
;;
to-disk)
# Writes from the ramdisk to disk, in case the server
crashes.
# Using ramdisk speeds things up a lot, especially if you
allow
# teleportation on the server.
mc_saveoff
to_disk
mc_saveon
;;
connected)
# Lists connected users
as_user "screen -p 0 -S $SCREEN -X eval 'stuff list\015'"
sleep 3s
tac $MCPATH/server.log | grep -m 1 "Connected"
;;
log-roll)
# Moves and Gzips the logfile, a big log file slows down the
# server A LOT (what was notch thinking?)
# The existing log is turnacated to 0 file size.

           log_roll
           ;;
   last)
           # greps for recently logged in users
           echo Recently logged in users:
           cat $MCPATH/server.log | awk '/entity|conn/

{sub(/lost/,"disconnected");print $1,$2,$4,$5}'
;;
status)
# Shows server status
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE

/dev/null
then
echo "$SERVICE is running."
else
echo "$SERVICE is not running."
fi
;;
version)
echo Craftbukkit version awk '/Craftbukkit/ {sub(/\)/, ""); print $12}' $MCPATH/server.log
;;
links)
check_links
;;
ramdisk)
change_ramdisk_state $2
;;
worlds)
get_worlds
for INDEX in ${!WORLDNAME[@]}
do
if ${WORLDRAM[$INDEX]}
then
echo "${WORLDNAME[$INDEX]} (ramdisk)"
else
echo ${WORLDNAME[$INDEX]}
fi
done
;;
help)
echo "Usage: /etc/init.d/minecraft command"
echo
echo "start - Starts the server"
echo "stop - stops the server"
echo "restart - restarts the server"
echo "backup - backups the worlds defined in the script"
echo "whole-backup - backups the entire server folder"
echo "update - fetches the latest version of minecraft.jar
server and Bukkit"
echo "log-roll - Moves and gzips the logfile"
echo "to-disk - copies the worlds from the ramdisk to
worldstorage"
echo "connected - lists connected users"
echo "status - Shows server status"
echo "version - returs Bukkit version"
echo "links - creates nessesary symlinks"
echo "last - shows recently connected users"
echo "worlds - shows a list of available worlds"
echo "ramdisk WORLD - toggles ramdisk configuration for
WORLD"
;;
*)
echo "No such command see /etc/init.d/minecraft help"
exit 1
;;
esac

exit 0
That one...
works just fine


Reply to this email directly or view it on GitHub:
#29

from minecraft-init.

littleclaz avatar littleclaz commented on July 27, 2024

right i did the command you suggested and i just came back with an error and refusing to do it.. so i just went on a wim and then did yast > system > System Services (Run level) > minecraft >disable then enable
and its seems to be working but now gives:

linux-pcbl:~ # /etc/init.d/minecraft
/etc/init.d/minecraft: line 14: logs: command not found
/etc/init.d/minecraft: line 30: /etc/init.d/config: No such file or directory
Couldn't load config file, please edit config.example and
rename it to config

it is a symlink :L oddly enough so i think ill just copy the config file into the folder and see what happens unless youve got a differen suggestion?

from minecraft-init.

Ahtenus avatar Ahtenus commented on July 27, 2024

Yeah, the script doesn't really handle hard links, so you could replace
if [ -L $0 ]
then
source readlink $0 | sed "s:[^/]*$:config:"
else
source echo $0 | sed "s:[^/]*$:config:"
fi
with something like this

source /home/minecraft/minecraft-init/config

from minecraft-init.

littleclaz avatar littleclaz commented on July 27, 2024

ill give that a go and paste my result.

from minecraft-init.

littleclaz avatar littleclaz commented on July 27, 2024

linux-pcbl:~ # /etc/init.d/minecraft ramdisk world
/etc/init.d/minecraft: line 14: logs: command not found
/home/minecraft/config: line 12: syntax error near unexpected token )' /home/minecraft/config: line 12:craftbukkit and vice versa)'
Couldn't load config file, please edit config.example and
rename it to config

from minecraft-init.

Ahtenus avatar Ahtenus commented on July 27, 2024

Seem like you have a syntax error in your config file

from minecraft-init.

littleclaz avatar littleclaz commented on July 27, 2024

right ive just redone the whole lot. and put the config in the /etc/init.d folder and ive got this error now this is without changing anything in the config:

linux-pcbl:~ # /etc/init.d/minecraft ramdisk world
/etc/init.d/minecraft: line 314: syntax error near unexpected token newline' /etc/init.d/minecraft: line 314: as_user "python $OVPATH/overviewer.py --settings $OVCONFIGPATH/$OVCONFIGNAME $WORLDSTORAGE/$1 $OUTPUTMAP" > '
linux-pcbl:~ #

from minecraft-init.

Ahtenus avatar Ahtenus commented on July 27, 2024

Humm, that's weird, can't find any syntax errors myself. I guess you could remove everything inside start_overviewer() just to see if that works.

from minecraft-init.

wboubi avatar wboubi commented on July 27, 2024

Hi
I just tested the script under opensuse and it's work perfectly.

I installed the package git, screen and java.
This is my command line :

As user

 git clone https://github.com/Ahtenus/minecraft-init.git
 mkdir -p minecraft/worldstorage
 cd minecraft-init
 chmod 755 minecraft
 cp config.exemple config

As root

 ln -s /home/username/minecraft-init/minecraft /etc/init.d/minecraft
 chkconfig --set minecraft on
 service minecraft update

The script download the jar and launch it. It's work perfectly for me under the OpenSuse 12.1

from minecraft-init.

littleclaz avatar littleclaz commented on July 27, 2024

Hello Guys!

Right..Sorry for not getting back sooner. but ive been without Power for all of yesterday and the most part of today..

righty...

This is how im doing it.. i think its wrong.. but im more of an Debian person than a OpenSUSE but my server's RAID Array isnt supported by Debian ATM..

nano ./minecraft
paste all of the script into nano
ctrl+o
Ctrl+x
nano ./config
paste and edit the config contents into nano
ctrl+o
ctrl+x
ln minecraft /etc/init.d/minecraft
chmod 755 /etc/init.d/minecraft
chkconfig --set minecraft on

from minecraft-init.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.