Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
/etc/init.d/pants . . . now with ebuild!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
Praxxus
Apprentice
Apprentice


Joined: 26 Nov 2002
Posts: 193
Location: Indiana, US

PostPosted: Wed May 21, 2003 8:59 pm    Post subject: /etc/init.d/pants . . . now with ebuild! Reply with quote

I stumbled across this script through ThinkGeek's Fortunes page, and it amused me.

I have hacked it to work on Gentoo, though in order to suppress some of Gentoo's rc script output, it is using /bin/bash as the interpreter instead of /sbin/runscript. I think it still behaves pretty much like a Gentoo init script, though.

I also added a "No Pants $DAY" option, just for fun.

It is recommended that everyone download this script (or ebuild) & put it in your "default" runlevel, lest you catch cold!

Hope some of you get a chuckle out of this.

NEW A "pants" ebuild!"

Just download this file and unpack it into $PORTDIR_OVERLAY/app-misc/ or wherever. This is for those of you who refuse to put anything on your systems that doesn't have an ebuild. It's also for those of you who think typing "emerge pants" is funny.

Also on edit: Tweaked the script some to behave more like the original.

Code:
#!/bin/bash
source /etc/init.d/functions.sh
NUMPROC=`grep -c "^cpu[0-9]" /proc/stat`
PANTLOCK="/var/lock/subsys/pants"
NOPANTS=`/bin/date +%A`
DAY="Thursday"
start() {
        if [ "$NOPANTS" == "$DAY" ] ; then
           ewarn "It's No Pants $DAY!  Woo-hoo!"
           if [ -f $PANTLOCK ] ; then
              $0 stop
           fi
        else
           einfon "Putting on pants"
           if [ "$NUMPROC" -gt "1" ] ; then
              echo -n ", one leg at a time"
           fi
           echo "..."
           if [ -f $PANTLOCK ] ; then
              /bin/false
              eend $?
              eerror "Looks like we've still got some old pants on.  They'll do."
           else
              touch $PANTLOCK
              eend $?
           fi
        fi
}

stop() {
        if [  -f $PANTLOCK ] ; then
           ebegin "Taking off pants"
           rm -f $PANTLOCK
           eend $?
        else
           eerror "We're not wearing any pants!"
           /bin/false
           eend $?

        fi
}

restart() {
        echo ""
        ebegin "Time for a change of pants"
        $0 stop
        $0 start
        eend $?
}

status() {
        if [ "$NOPANTS" == "$DAY" ] ; then
           ewarn "It's No Pants $DAY!  Woo-hoo!"
              $0 stop
        elif [ -f $PANTLOCK ] ; then
           einfo "Pants are ON . . . "
        else
           eerror "We're not wearing any pants!"
           eend 1
        fi
}


case "$1" in

  start)
     start
     ;;
  stop)
     stop
     ;;
  restart)
     restart
     ;;
  status)
     status
     ;;
  *|"")
     einfo "Acceptable uses for pants:  $0 {start|stop|restart|status}"
esac
exit 0

_________________
My glaucoma just got worse!


Last edited by Praxxus on Thu May 22, 2003 6:38 pm; edited 4 times in total
Back to top
View user's profile Send private message
nrl
Guru
Guru


Joined: 27 Mar 2003
Posts: 446
Location: Glasgow, UK

PostPosted: Wed May 21, 2003 9:11 pm    Post subject: Reply with quote

Code:

# /etc/init.d/pants start
 * Putting on pants...                                                    [ ok ]
# /etc/init.d/pants start
 * Looks like we've still got some old pants on.  They'll do....
#

:lol: btw I could not get what you posted to work but messed about with the one from the link you gave.

When I run what you posted I get:
Code:

# /etc/init.d/pants start
/etc/init.d/pants: line 68: syntax error near unexpected token `)'
/etc/init.d/pants: line 68: `  *)'


Last edited by nrl on Wed May 21, 2003 9:47 pm; edited 2 times in total
Back to top
View user's profile Send private message
Praxxus
Apprentice
Apprentice


Joined: 26 Nov 2002
Posts: 193
Location: Indiana, US

PostPosted: Wed May 21, 2003 9:22 pm    Post subject: Reply with quote

Yup. My posted code had gotten out of sync with the script (I added the "*)" option as I was posting the message), and I forgot the ";;" after "status."

Thanks!
_________________
My glaucoma just got worse!
Back to top
View user's profile Send private message
guy
Apprentice
Apprentice


Joined: 31 Mar 2003
Posts: 286
Location: USA

PostPosted: Wed May 21, 2003 11:27 pm    Post subject: Reply with quote

what's that smell?... I think it's an ebuild..
Back to top
View user's profile Send private message
noff
Guru
Guru


Joined: 11 Nov 2002
Posts: 388
Location: College Park, Maryland

PostPosted: Thu May 22, 2003 5:39 am    Post subject: Reply with quote

Woo-hoo! It's No Pants Thursday!
_________________
What Larry was saying is that if you make it too easy for programmers, then poor programmers will be able to do things best left to good programmers, and will inevitably do them poorly. Everyone will suffer in the long term as a result." - Tom Chance
Back to top
View user's profile Send private message
frippz
Guru
Guru


Joined: 22 Aug 2002
Posts: 460
Location: Sweden

PostPosted: Thu May 22, 2003 9:45 am    Post subject: Reply with quote

Damn!
I can't get my pants on and I gotta go to a lecture soon...! :D
Back to top
View user's profile Send private message
Ralphus Maximus
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jul 2002
Posts: 148
Location: At Large

PostPosted: Thu May 22, 2003 7:51 pm    Post subject: Reply with quote

I just loaded this on our main server and showed the boss. I think he needs new pants. :lol:

Excellent!

Cheers,
RM
_________________
Hero for hire. Dragons rescued, Virgins slain.

You say "Cheesy" like it's a bad thing!

In a society that is drug infested, violence-wracked and polluted by chemical greed, no one has ever died from an overdose of pornography.
Back to top
View user's profile Send private message
nrl
Guru
Guru


Joined: 27 Mar 2003
Posts: 446
Location: Glasgow, UK

PostPosted: Thu May 22, 2003 8:01 pm    Post subject: Reply with quote

Today is no pants thursday so I think I will wait till tommorow to emerge pants ;).
Back to top
View user's profile Send private message
Praxxus
Apprentice
Apprentice


Joined: 26 Nov 2002
Posts: 193
Location: Indiana, US

PostPosted: Thu May 22, 2003 8:02 pm    Post subject: Reply with quote

Ahh, but "No Pants $DAY" is easily configurable, right at the top of the init script. So if you're one of those "three day weekend" types, you can make it No Pants Friday instead. :wink:
_________________
My glaucoma just got worse!
Back to top
View user's profile Send private message
Oopsz
Guru
Guru


Joined: 08 Oct 2002
Posts: 340

PostPosted: Thu May 22, 2003 8:40 pm    Post subject: Reply with quote

Code:
emerge pants


*giggles*
_________________
Pop-before-SMTP with the Gentoo Virtual Mailhosting Guide
Back to top
View user's profile Send private message
nerdbert
l33t
l33t


Joined: 09 Feb 2003
Posts: 981
Location: Berlin

PostPosted: Sun Sep 07, 2003 7:19 pm    Post subject: Reply with quote

is there something wrong about the ebuild or am I missing something?

Code:
--- No package manifest found: /usr/local/portage/app-misc/pants/Manifest
>>> md5 src_uri ;-) pants
>>> Unpacking source...
>>> Unpacking pants to /var/tmp/portage/pants-0.7/work
unpack pants: file format not recognized. Ignoring.
>>> Source unpacked.

>>> Install pants-0.7 into /var/tmp/portage/pants-0.7/image/ category app-misc
install: cannot stat `pants': No such file or directory
man:
prepallstrip:
strip:
>>> Completed installing into /var/tmp/portage/pants-0.7/image/
Back to top
View user's profile Send private message
solatis
Apprentice
Apprentice


Joined: 06 Nov 2002
Posts: 214
Location: University of Twente, The Netherlands

PostPosted: Sun Sep 07, 2003 10:19 pm    Post subject: Reply with quote

gotta love the "rc-update add pants default" statement :)
_________________
Grtz,

Leon Mergen
http://www.solatis.com/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum