Archive for July, 2011

Seventeen or Bust; a gentoo daemon script

Tuesday, July 12th, 2011

Seventeen or Bust

It’s been a while since I’ve just my available CPU cycles for vanity, but I’m a sucker for stats. Normally, you’d just start the binary mprime in some terminal and let it be, I didn’t like that for my servers (basically, I’d have to run SoB under some user, in some screen, and whenever something happens I’d have to manually interfere to kill it or restart it). So I wrote a very simple rc script to handle it for me.

The script

/etc/init.d/seventeenorbust

#!/sbin/runscript
 
depend() {
        use net
}
 
start() {
        PWHOME="$(getent passwd $USER | awk -F: '{ print $6 }')"
 
        ebegin "Starting SeventeenOrBust"
        env TERM="xterm" \
                start-stop-daemon \
                        --start \
                        --user $USER \
                        --env HOME="${PWHOME:-/home/$USER}" \
                        --name sob \
                        --exec /usr/bin/screen -- -dmS sob /home/sob/mprime -d
        eend $?
}
 
stop() {
        ebegin "Stopping SeventeenOrBust"
        start-stop-daemon --stop --signal 2 --name sob
        eend $?
}

/etc/conf.d/seventeenorbust

USER="sob"

Setup

  1. Copy the above files to your filesystem
  2. $ useradd -m -p "sob" sob
  3. Add a DenyUsers entry in your sshd_config for the sob account, don’t want people getting access to your box with a default user
  4. Login as the sob user, download and install the SoB binaries in your homedir and configure SoB accordingly (usually, this is just setting up your username in prime.txt
  5. (Optional); $ rc-update add seventeenorbust default

Like to view progress?

If you like to keep tabs on your instance, completion percentage and such, you can log in as the sob-user and run $ screen -dr sob to attach to te daemon’s screen session.