<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>7483</bug_id>
          
          <creation_ts>2002-09-04 16:57 0000</creation_ts>
          <short_desc>setiathome: Improved init script</short_desc>
          <delta_ts>2003-04-17 18:39:59 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Ebuilds</component>
          <version>1.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>delta407@lerfjhax.com</reporter>
          <assigned_to>sethbc@wpi.edu</assigned_to>
          <cc>vapier@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>delta407@lerfjhax.com</who>
            <bug_when>2002-09-04 16:57:09 0000</bug_when>
            <thetext>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&apos;t act differently than the current one when only one
CPU is present. I&apos;ve not tested it on a single-CPU machine (as I don&apos;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 &quot;Creating ${SETIATHOME_DIR}&quot;
                mkdir ${SETIATHOME_DIR}
        fi

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

        if [ $cpus != &apos;1&apos; ]; 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} &gt; /dev/null
                                rm ${SETIATHOME_DIR}/cpu${cpu}/*.sah &gt; /dev/null
                                cp ${SETIATHOME_DIR}/user_info.sah
${SETIATHOME_DIR}/cpu${cpu}
                        fi
                done
        fi
}

start() {
        checkconfig


        if [ $cpus = &apos;1&apos; ]; then
                ebegin &quot;Starting SETI@home&quot;
        else
                ebegin &quot;Starting SETI@home ($cpus processors)&quot;
        fi

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

                ./setiathome ${SETIATHOME_OPTIONS} &gt;&amp;/dev/null&amp;
        done

        eend $?
}

stop() {
        ebegin &quot;Stopping SETI@home&quot;
        killall setiathome
        eend $?
}</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>aliz@gentoo.org</who>
            <bug_when>2002-11-04 06:53:06 0000</bug_when>
            <thetext>Commited, thanks for the contribution!</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>delta407@lerfjhax.com</who>
            <bug_when>2002-11-04 12:25:03 0000</bug_when>
            <thetext>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&apos;s a handmade pseudo-diff:

  if [ $cpus 
!= &apos;1&apos; ]; 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} &gt; /dev/null
-       rm 
${SETIATHOME_DIR}/cpu${cpu}/*.sah &gt; /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 != &apos;1&apos; ]; then
      cd 
cpu${cpu}
    fi

    ${SETIATHOME_DIR}/setiathome ${SETIATHOME_OPTIONS} &gt;&amp;/dev/null&amp;
  
done</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2002-11-04 12:34:27 0000</bug_when>
            <thetext>aliz: i&apos;m gonna go ahead and steal this cause i got 2 other seti@home bugs that 
involve rewriting the current setup ... </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>humpback@gentoo.org</who>
            <bug_when>2003-01-02 07:07:10 0000</bug_when>
            <thetext>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&amp;White G3)
pmac flags      : 00000000
L2 cache        : 1024K unified
memory          : 512MB
pmac-generation : NewWorld
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>delta407@lerfjhax.com</who>
            <bug_when>2003-01-02 12:17:03 0000</bug_when>
            <thetext>Change 
   cpus=`grep -c processor /proc/cpuinfo` 
to 
   cpus=`grep -c bogomips /proc/cpuinfo` 
 
This should work on both platforms. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>sethbc@wpi.edu</who>
            <bug_when>2003-04-17 18:39:59 0000</bug_when>
            <thetext>took some stuff from here =)</thetext>
          </long_desc>
      
    </bug>

</bugzilla>