module ActiveScripts class Base # INFO: ActiveScripts::Base contains code that is # shared between all base files. private def assert_valid_user! unless user? raise SecurityError, "The following commands cannot be executed as root. Switch to a non-root user." end end def user? output, error, status = Open3.capture3("whoami") output = output.squish return(output != "root") end def notify_command_todo! say_warning(" [!] CommandError") say_warning(" - TODO: The command is not yet developed.") end def notify_command_unavailable! say_warning(" [!] CommandError") say_warning(" - The command is not available.") end def notify_command_user! say_warning(" [!] CommandError") say_warning(" - The command cannot be executed as root. Please switch user.") end end end