class ActiveScripts::Base

Private Instance Methods

assert_valid_user!() click to toggle source

INFO: ActiveScripts::Base contains code that is

shared between all base files.
# File lib/active_scripts/base.rb, line 9
def assert_valid_user!
  unless user?
    raise SecurityError,
      "The following commands cannot be executed as root. Switch to a non-root user."
  end
end
notify_command_todo!() click to toggle source
# File lib/active_scripts/base.rb, line 22
def notify_command_todo!
  say_warning("   [!] CommandError")
  say_warning("     - TODO: The command is not yet developed.")
end
notify_command_unavailable!() click to toggle source
# File lib/active_scripts/base.rb, line 27
def notify_command_unavailable!
  say_warning("   [!] CommandError")
  say_warning("     - The command is not available.")
end
notify_command_user!() click to toggle source
# File lib/active_scripts/base.rb, line 32
def notify_command_user!
  say_warning("   [!] CommandError")
  say_warning("     - The command cannot be executed as root. Please switch user.")
end
user?() click to toggle source
# File lib/active_scripts/base.rb, line 16
def user?
  output, error, status = Open3.capture3("whoami")
  output = output.squish
  return(output != "root")
end