Log in

No account? Create an account
entries friends calendar profile adric.net Previous Previous Next Next
restart.rb - nil.enroll(aetheric_username, quantum_class_id)
yljatlhQo'! QIch lo'laltbebej!
## restart given service with eg /etc/init.d/$thing restart
## syntactic sugar, practice, Artistic License (C) 2008

## Debian and most use /etc/init.d/
@initscripts = '/etc/init.d/'

## Usage
def usage
 p 'restart.rb: Take one argument, a service name from /etc/init.d . '

## if number of args is not 1, show usage
if ARGV.length != 1

## check configuration
if ! File.directory?(@initscripts)
  p 'No such directory: ' + @initscripts

## get arg
@service = ARGV.pop

## if arg service is not in /etc/init.d , point that out and usage.
# if ![ -x '/etc/init.d/#{@service}']
if ! File.exist?(@initscripts + @service)
  p 'reboot.rb: ' + @initscripts + @service + ' not found.'

## And finally, cycle something
system(@initscripts + @service + ' restart')

iTunes: Played this haunting GITS track while I was posting, then a quick Origa track, and now back to Liz Phair for "Shitloads Of Money" from whitechocolatespaceegg. Out of 1315 songs, 3.3 days of music. And then Origa again. And now Liz Phair "May Queen", from Whip Smart. Now Origa - –Ø –ø–æ–¥–∞—Ä—é –¢–µ–±–µ –ú—É–∑—ã–∫—É which did not paste well at all, now did it.

Current Music: Scott Matthew - Beauty Is Within Us

3 comments or Leave a comment
sh1v From: sh1v Date: March 19th, 2008 01:34 pm (UTC) (Link)
Looking at Ruby usually makes me vomit, but this makes sense-- cool!
sh1v From: sh1v Date: March 19th, 2008 04:06 pm (UTC) (Link)
Also, is there a reason you didn't write this in BASH?
adric From: adric Date: March 20th, 2008 04:13 am (UTC) (Link)


I'm (still) trying to learn some Ruby. I write bash at work and for some of my own crap but it's ugly and inflexible. *shrug*

There's some of my bash around too. I spent more time on site_update last night than the ruby, by far, fixing and cleaning. You can gawk by pulling:

svn export http://dev.atlbbs.com/svn/adricnet/branches/configs

if you really want to. I guess I should finish the header on tha one if I'm going to link to it :) Artistic License copyleft, then.

3 comments or Leave a comment