Skip to content

Instantly share code, notes, and snippets.

@arbales
Created January 10, 2011 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbales/773292 to your computer and use it in GitHub Desktop.
Save arbales/773292 to your computer and use it in GitHub Desktop.
module Mycroft
module Action
class Base
def initialize(options)
@options = options
end
def self.create(options)
self.new(options).save
end
def perform
end
def log
end
def save
# Writes a file to /var/mycroft/actions/#{type}.#{uuid}.act
end
end
end
end
module Mycroft
module Action
class Nginx < Base
def self.restart
self.create({'action': 'restart'})
end
def self.reload
self.create({'action': 'reload'})
end
def perform
system "/usr/local/bin/nginx -s #{@options['action']}"
end
end
end
end
module Mycroft
module Action
class PasswordChange < Base
def initialize(options)
@options = options
@options['shadow'] = Mycroft::Utils.shadow @options['password']
@options['password'] = nil
end
def perform
system "usermod -p #{@options['shadow']} #{@options['username']}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment