module ActiveScripts module Preparations class Linux < ActiveScripts::Preparations::Base # INFO: ActiveScripts::Preparations::Linux contains code that is # pertaining to the Linux operating system. private def setup execute_command!("sudo apt-get -y update") execute_command!("sudo apt-get -y upgrade") execute_command!("sudo aptitude -y safe-upgrade") execute_command!("sudo apt-get -y autoremove") execute_command!("sudo apt-get -y install build-essential curl git m4 ruby texinfo vim flex bison \ make cmake scons gettext autoconf automake autoconf-archive \ libbz2-dev libffi-dev libcurl4-openssl-dev libexpat-dev libssl-dev \ libyaml-dev libncurses-dev libtool libreadline6-dev libncurses5-dev \ python-setuptools zlib1g-dev") username = ask(" [?] Username? ") { |q| q.validate = /^[A-Za-z0-9]+$/i } output = execute_command!("sudo adduser #{username}") say_warning(" [!] #{output.squish}") unless option_dry_run? || preparation_output?(output, includes: "adduser:") output = execute_command!("sudo adduser #{username} sudo") say_warning(" [!] #{output.squish}") unless option_dry_run? || preparation_output?(output, includes: "adduser:") if agree(" [?] Setup project directory? ", true) output = ask(" [?] Project name? ") { |q| q.validate = /^[A-Za-z0-9_-.+]+$/i } execute_command!("mkdir /var/www") execute_command!("mkdir /var/www/#{output}") execute_command!("chown -R root /var/www/#{output}") say(" Project directory path: '/var/www/#{output}'") end say_ok(" Setup complete!") say_ok(" - Please switch to the following user to complete the installation: '#{username}'") end def update execute_command!("sudo apt-get -y update") execute_command!("sudo apt-get -y upgrade") execute_command!("sudo aptitude -y safe-upgrade") execute_command!("sudo apt-get -y autoremove") say_ok(" Update complete!") end end end end