module ActiveScripts module Packages class Wkhtmltopdf < ActiveScripts::Packages::Base # INFO: ActiveScripts::Packages::Wkhtmltopdf contains code that # execute the wkhtmltopdf package. private def install if package_installed?(command: "which wkhtmltopdf", includes: "wkhtmltopdf") case $operating_system when :linux execute_command!("sudo apt-get -y install xvfb") execute_command!("wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb") execute_command!("sudo apt-get -y -f install") execute_command!("sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb") execute_command!("cat #{addendum_path!('wkhtmltopdf.txt')} > wkhtmltopdf.sh") execute_command!("sudo chmod a+x wkhtmltopdf.sh") execute_command!("sudo mv wkhtmltopdf.sh /usr/local/bin/") say_ok(" Installation complete!") else notify_package_unavailable! end else notify_package_missing! end end def upgrade if package_installed?(command: "which wkhtmltopdf", includes: "wkhtmltopdf") case $operating_system when :linux execute_command!("sudo apt-get -y upgrade xvfb") execute_command!("sudo apt-get -y -f upgrade") execute_command!("wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb") execute_command!("sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb") say_ok(" Installation complete!") else notify_package_unavailable! end else notify_package_missing! end end def uninstall if package_installed?(command: "which wkhtmltopdf", includes: "wkhtmltopdf") case $operating_system when :linux execute_command!("sudo apt-get -y --purge remove xvfb") execute_command!("sudo apt-get -y autoremove") say_ok(" Installation complete!") else notify_package_unavailable! end else notify_package_missing! end end end end end