module ActiveScripts module Packages class Postgresql < ActiveScripts::Packages::Base # INFO: ActiveScripts::Packages::Postgresql contains code that # execute the PostgreSQL package. private def install if package_installed?(includes: "postgresql") notify_package_exists! else case $operating_system when :macosx execute_command!("brew install postgresql") say_ok(" Installation complete!") when :linux if agree(" [?] PostgreSQL client only? ", true) execute_command!("sudo apt-get -y install postgresql-dev-9.4") else execute_command!("sudo apt-get -y install postgresql postgresql-contrib libpq-dev") end say_ok(" Installation complete!") else notify_package_unavailable! end end end def upgrade if package_installed?(includes: "postgresql") case $operating_system when :macosx output = execute_command!("brew upgrade postgresql") say_warning(" [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:") say_ok(" Upgrade complete!") when :linux execute_command!("sudo apt-get -y upgrade postgresql postgresql-contrib libpq-dev") say_ok(" Upgrade complete!") else notify_package_unavailable! end else notify_package_missing! end end def uninstall if package_installed?(includes: "postgresql") case $operating_system when :macosx execute_command!("brew remove postgresql") say_ok(" Uninstallation complete!") when :linux execute_command!("sudo apt-get -y --purge remove postgresql postgresql-contrib libpq-dev") execute_command!("sudo apt-get -y autoremove") say_ok(" Uninstallation complete!") else notify_package_unavailable! end else notify_package_missing! end end end end end