Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 7483 - setiathome: Improved init script
Summary: setiathome: Improved init script
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High enhancement (vote)
Assignee: Seth Chandler
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-04 16:57 UTC by delta407
Modified: 2003-04-17 18:39 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description delta407 2002-09-04 16:57:09 UTC
I have modified the setiathome init script to launch multiple processes on
machines with more than one CPU. It deduces CPU count at runtime from
/proc/cpuinfo and shouldn't act differently than the current one when only one
CPU is present. I've not tested it on a single-CPU machine (as I don't have one
readily available) but I am confident it will function properly.

The contents of my /etc/init.d/setiathome follows.
---
#!/sbin/runscript

cpus=`grep -c processor /proc/cpuinfo`

checkconfig() {
        if [ ! -e ${SETIATHOME_DIR} ]
        then
                einfo "Creating ${SETIATHOME_DIR}"
                mkdir ${SETIATHOME_DIR}
        fi

        if [ ! -e ${SETIATHOME_DIR}/user_info.sah ]
        then
                einfo "Setting up SETI@home for the first time"
                cd ${SETIATHOME_DIR}
                ./setiathome -login
        fi

        if [ $cpus != '1' ]; then
                cd ${SETIATHOME_DIR}
                for cpu in `seq 2 $cpus`; do
                        if [ ! -e ${SETIATHOME_DIR}/cpu${cpu} ]; then
                                mkdir ${SETIATHOME_DIR}/cpu${cpu}
                                cp ${SETIATHOME_DIR}/*
${SETIATHOME_DIR}/cpu${cpu} > /dev/null
                                rm ${SETIATHOME_DIR}/cpu${cpu}/*.sah > /dev/null
                                cp ${SETIATHOME_DIR}/user_info.sah
${SETIATHOME_DIR}/cpu${cpu}
                        fi
                done
        fi
}

start() {
        checkconfig


        if [ $cpus = '1' ]; then
                ebegin "Starting SETI@home"
        else
                ebegin "Starting SETI@home ($cpus processors)"
        fi

        for cpu in `seq 1 $cpus`; do
                cd ${SETIATHOME_DIR}
                if [ $cpu != '1' ]; then
                        cd cpu${cpu}
                fi

                ./setiathome ${SETIATHOME_OPTIONS} >&/dev/null&
        done

        eend $?
}

stop() {
        ebegin "Stopping SETI@home"
        killall setiathome
        eend $?
}
Comment 1 Daniel Ahlberg (RETIRED) gentoo-dev 2002-11-04 06:53:06 UTC
Commited, thanks for the contribution!
Comment 2 delta407 2002-11-04 12:25:03 UTC
Dang. I could have sworn I added a comment with changes to fix a couple potential upgrade issues 
(with new executables not being propagated, etc.) Here's a handmade pseudo-diff:

  if [ $cpus 
!= '1' ]; then
    cd ${SETIATHOME_DIR}
    for cpu in `seq 2 $cpus`; do
      if [ ! -e 
${SETIATHOME_DIR}/cpu${cpu} ]; then
        mkdir ${SETIATHOME_DIR}/cpu${cpu}
-       cp 
${SETIATHOME_DIR}/* ${SETIATHOME_DIR}/cpu${cpu} > /dev/null
-       rm 
${SETIATHOME_DIR}/cpu${cpu}/*.sah > /dev/null
        cp 
${SETIATHOME_DIR}/user_info.sah${SETIATHOME_DIR}/cpu${cpu}
      fi
    done
  
fi

...

  for cpu in `seq 1 $cpus`; do
    cd ${SETIATHOME_DIR}
    if [ $cpu != '1' ]; then
      cd 
cpu${cpu}
    fi

    ${SETIATHOME_DIR}/setiathome ${SETIATHOME_OPTIONS} >&/dev/null&
  
done
Comment 3 SpanKY gentoo-dev 2002-11-04 12:34:27 UTC
aliz: i'm gonna go ahead and steal this cause i got 2 other seti@home bugs that 
involve rewriting the current setup ... 
Comment 4 Gustavo Felisberto (RETIRED) gentoo-dev 2003-01-02 07:07:10 UTC
grep -c processor /proc/cpuinfo
0

This setup is borked in PPC
I have no ideas on how to fix this. In PPC you get
cat /proc/cpuinfo
cpu             : 740/750
temperature     : 20-24 C (uncalibrated)
clock           : 400MHz
revision        : 130.1 (pvr 0008 8201)
bogomips        : 796.26
machine         : PowerMac1,1
motherboard     : PowerMac1,1 MacRISC Power Macintosh
detected as     : 66 (Blue&White G3)
pmac flags      : 00000000
L2 cache        : 1024K unified
memory          : 512MB
pmac-generation : NewWorld
Comment 5 delta407 2003-01-02 12:17:03 UTC
Change 
   cpus=`grep -c processor /proc/cpuinfo` 
to 
   cpus=`grep -c bogomips /proc/cpuinfo` 
 
This should work on both platforms. 
Comment 6 Seth Chandler 2003-04-17 18:39:59 UTC
took some stuff from here =)