active_scripts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +9 -0
  4. data/.rspec +4 -0
  5. data/.travis.yml +13 -0
  6. data/CODE_OF_CONDUCT.md +13 -0
  7. data/COMMANDS.md +43 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +39 -0
  11. data/Rakefile +1 -0
  12. data/active_scripts.gemspec +29 -0
  13. data/bin/console +14 -0
  14. data/bin/rake +16 -0
  15. data/bin/setup +7 -0
  16. data/exe/active_scripts +82 -0
  17. data/lib/active_scripts.rb +16 -0
  18. data/lib/active_scripts/addendums/linuxbrew.txt +4 -0
  19. data/lib/active_scripts/addendums/rbenv.txt +3 -0
  20. data/lib/active_scripts/addendums/wkhtmltopdf.txt +2 -0
  21. data/lib/active_scripts/base.rb +38 -0
  22. data/lib/active_scripts/operating_system.rb +57 -0
  23. data/lib/active_scripts/package.rb +39 -0
  24. data/lib/active_scripts/packages/all.rb +34 -0
  25. data/lib/active_scripts/packages/base.rb +107 -0
  26. data/lib/active_scripts/packages/homebrew.rb +49 -0
  27. data/lib/active_scripts/packages/imagemagick.rb +62 -0
  28. data/lib/active_scripts/packages/jpegoptim.rb +55 -0
  29. data/lib/active_scripts/packages/mysql.rb +73 -0
  30. data/lib/active_scripts/packages/nginx.rb +24 -0
  31. data/lib/active_scripts/packages/optipng.rb +55 -0
  32. data/lib/active_scripts/packages/postgresql.rb +69 -0
  33. data/lib/active_scripts/packages/rails.rb +27 -0
  34. data/lib/active_scripts/packages/rbenv.rb +62 -0
  35. data/lib/active_scripts/packages/redis.rb +78 -0
  36. data/lib/active_scripts/packages/ruby.rb +58 -0
  37. data/lib/active_scripts/packages/ruby_build.rb +55 -0
  38. data/lib/active_scripts/packages/wkhtmltopdf.rb +64 -0
  39. data/lib/active_scripts/preparation.rb +37 -0
  40. data/lib/active_scripts/preparations/base.rb +81 -0
  41. data/lib/active_scripts/preparations/freebsd.rb +20 -0
  42. data/lib/active_scripts/preparations/linux.rb +49 -0
  43. data/lib/active_scripts/preparations/macosx.rb +20 -0
  44. data/lib/active_scripts/preparations/unix.rb +20 -0
  45. data/lib/active_scripts/preparations/windows.rb +20 -0
  46. data/lib/active_scripts/recipe.rb +52 -0
  47. data/lib/active_scripts/recipes/all.rb +14 -0
  48. data/lib/active_scripts/recipes/base.rb +62 -0
  49. data/lib/active_scripts/recipes/rails.rb +26 -0
  50. data/lib/active_scripts/version.rb +3 -0
  51. metadata +178 -0
@@ -0,0 +1,55 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Optipng < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Optipng contains code that
6
+ # execute the OptiPNG package.
7
+
8
+ private
9
+
10
+ def install
11
+ if package_installed?(includes: "optipng")
12
+ notify_package_exists!
13
+ else
14
+ case $operating_system
15
+ when :macosx, :linux
16
+ execute_command!("brew install optipng")
17
+ say_ok(" Installation complete!")
18
+ else
19
+ notify_package_unavailable!
20
+ end
21
+ end
22
+ end
23
+
24
+ def upgrade
25
+ if package_installed?(includes: "optipng")
26
+ case $operating_system
27
+ when :macosx, :linux
28
+ output = execute_command!("brew upgrade optipng")
29
+ say_warning(" [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:")
30
+ say_ok(" Upgrade complete!")
31
+ else
32
+ notify_package_unavailable!
33
+ end
34
+ else
35
+ notify_package_missing!
36
+ end
37
+ end
38
+
39
+ def uninstall
40
+ if package_installed?(includes: "optipng")
41
+ case $operating_system
42
+ when :macosx, :linux
43
+ execute_command!("brew remove optipng")
44
+ say_ok(" Uninstallation complete!")
45
+ else
46
+ notify_package_unavailable!
47
+ end
48
+ else
49
+ notify_package_missing!
50
+ end
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,69 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Postgresql < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Postgresql contains code that
6
+ # execute the PostgreSQL package.
7
+
8
+ private
9
+
10
+ def install
11
+ if package_installed?(includes: "postgresql")
12
+ notify_package_exists!
13
+ else
14
+ case $operating_system
15
+ when :macosx
16
+ execute_command!("brew install postgresql")
17
+ say_ok(" Installation complete!")
18
+ when :linux
19
+ if agree(" [?] PostgreSQL client only? ", true)
20
+ execute_command!("sudo apt-get -y install postgresql-dev-9.4")
21
+ else
22
+ execute_command!("sudo apt-get -y install postgresql postgresql-contrib libpq-dev")
23
+ end
24
+ say_ok(" Installation complete!")
25
+ else
26
+ notify_package_unavailable!
27
+ end
28
+ end
29
+ end
30
+
31
+ def upgrade
32
+ if package_installed?(includes: "postgresql")
33
+ case $operating_system
34
+ when :macosx
35
+ output = execute_command!("brew upgrade postgresql")
36
+ say_warning(" [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:")
37
+ say_ok(" Upgrade complete!")
38
+ when :linux
39
+ execute_command!("sudo apt-get -y upgrade postgresql postgresql-contrib libpq-dev")
40
+ say_ok(" Upgrade complete!")
41
+ else
42
+ notify_package_unavailable!
43
+ end
44
+ else
45
+ notify_package_missing!
46
+ end
47
+ end
48
+
49
+ def uninstall
50
+ if package_installed?(includes: "postgresql")
51
+ case $operating_system
52
+ when :macosx
53
+ execute_command!("brew remove postgresql")
54
+ say_ok(" Uninstallation complete!")
55
+ when :linux
56
+ execute_command!("sudo apt-get -y --purge remove postgresql postgresql-contrib libpq-dev")
57
+ execute_command!("sudo apt-get -y autoremove")
58
+ say_ok(" Uninstallation complete!")
59
+ else
60
+ notify_package_unavailable!
61
+ end
62
+ else
63
+ notify_package_missing!
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,27 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Rails < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Rails contains code that
6
+ # execute the Rails package.
7
+
8
+ private
9
+
10
+ def install
11
+ execute_command!("sudo apt-add-repository -y ppa:chris-lea/node.js")
12
+ execute_command!("sudo apt-get -y install libssl-dev libreadline-dev libyaml-dev python-software-properties libxslt1-dev libxml2-dev nodejs checkinstall")
13
+
14
+ say_ok(" Installation complete!")
15
+ end
16
+
17
+ def upgrade
18
+ notify_command_todo!
19
+ end
20
+
21
+ def uninstall
22
+ notify_command_todo!
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,62 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Rbenv < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Rbenv contains code that
6
+ # execute the rbenv package.
7
+
8
+ private
9
+
10
+ def install
11
+ if package_installed?(includes: "rbenv")
12
+ notify_package_exists!
13
+ else
14
+ case $operating_system
15
+ when :macosx
16
+ execute_command!("brew install rbenv")
17
+ execute_command!("cat #{addendum_path!('rbenv.txt')} >> ~/.bash_profile")
18
+ execute_command!("source ~/.bash_profile")
19
+ say_ok(" Installation complete!")
20
+ when :linux
21
+ execute_command!("brew install rbenv")
22
+ execute_command!("cat #{addendum_path!('rbenv.txt')} >> ~/.bashrc")
23
+ execute_command!("source ~/.bashrc")
24
+ say_ok(" Installation complete!")
25
+ else
26
+ notify_package_unavailable!
27
+ end
28
+ end
29
+ end
30
+
31
+ def upgrade
32
+ if package_installed?(includes: "rbenv")
33
+ case $operating_system
34
+ when :macosx, :linux
35
+ output = execute_command!("brew upgrade rbenv")
36
+ say_warning(" [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:")
37
+ say_ok(" Upgrade complete!")
38
+ else
39
+ notify_package_unavailable!
40
+ end
41
+ else
42
+ notify_package_missing!
43
+ end
44
+ end
45
+
46
+ def uninstall
47
+ if package_installed?(includes: "rbenv")
48
+ case $operating_system
49
+ when :macosx, :linux
50
+ execute_command!("brew remove rbenv")
51
+ say_ok(" Uninstallation complete!")
52
+ else
53
+ notify_package_unavailable!
54
+ end
55
+ else
56
+ notify_package_missing!
57
+ end
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,78 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Redis < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Redis contains code that
6
+ # execute the Redis package.
7
+
8
+ private
9
+
10
+ def install
11
+ if package_installed?(includes: "redis") || package_installed?(command: "which redis", includes: "redis")
12
+ notify_package_exists!
13
+ else
14
+ case $operating_system
15
+ when :macosx
16
+ execute_command!("brew install redis")
17
+ say_ok(" Installation complete!")
18
+ when :linux
19
+ if agree(" [?] Redis-CLI only? ", true)
20
+ execute_command!("git clone http://github.com/antirez/redis.git")
21
+ execute_command!("cd redis && git checkout 3.0.2")
22
+ execute_command!("cd redis && make redis-cli")
23
+ execute_command!("cd redis && sudo cp src/redis-cli /usr/local/bin")
24
+ execute_command!("sudo touch /var/lib/redis/6379/dump.rdb")
25
+ else
26
+ execute_command!("sudo apt-get -y install tcl8.5")
27
+ execute_command!("wget http://download.redis.io/releases/redis-3.0.2.tar.gz")
28
+ execute_command!("tar xzf redis-3.0.2.tar.gz")
29
+ execute_command!("cd redis-3.0.2 && make")
30
+ execute_command!("cd redis-3.0.2 && make test")
31
+ execute_command!("cd redis-3.0.2 && sudo make install")
32
+ execute_command!("cd redis-3.0.2/utils && sudo ./install_server.sh")
33
+ execute_command!("cd redis-3.0.2/utils && sudo update-rc.d redis_6379 defaults")
34
+ execute_command!("echo 1 > /proc/sys/vm/overcommit_memory") if agree(" [?] Dedicated Redis server? ", true)
35
+ end
36
+ say_ok(" Installation complete!")
37
+ else
38
+ notify_package_unavailable!
39
+ end
40
+ end
41
+ end
42
+
43
+ def upgrade
44
+ if package_installed?(includes: "redis") || package_installed?(command: "which redis", includes: "redis")
45
+ case $operating_system
46
+ when :macosx
47
+ output = execute_command!("brew upgrade redis")
48
+ say_warning(" [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:")
49
+ say_ok(" Upgrade complete!")
50
+ else
51
+ notify_package_unavailable!
52
+ end
53
+ else
54
+ notify_package_missing!
55
+ end
56
+ end
57
+
58
+ def uninstall
59
+ if package_installed?(includes: "redis") || package_installed?(command: "which redis", includes: "redis")
60
+ case $operating_system
61
+ when :macosx
62
+ execute_command!("brew remove redis")
63
+ say_ok(" Uninstallation complete!")
64
+ when :linux
65
+ execute_command!("sudo rm -rf redis-3.0.2")
66
+ execute_command!("sudo rm -rf redis")
67
+ say_ok(" Uninstallation complete!")
68
+ else
69
+ notify_package_unavailable!
70
+ end
71
+ else
72
+ notify_package_missing!
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,58 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Ruby < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Ruby contains code that
6
+ # execute the ruby package.
7
+
8
+ private
9
+
10
+ def install
11
+ output = ask(" [?] Which version? ") { |q| q.default = "2.2.2" }
12
+
13
+ if package_installed?("ruby -v", includes: output)
14
+ notify_package_exists!
15
+ else
16
+ case $operating_system
17
+ when :macosx, :linux
18
+ begin
19
+ Timeout::timeout(600) do
20
+ execute_command!("rbenv install #{output}") unless package_installed?("rbenv versions", includes: output)
21
+ end
22
+ rescue Timeout::Error => e
23
+ ##
24
+ ensure
25
+ execute_command!("rbenv rehash")
26
+ execute_command!("rbenv global #{output}")
27
+ execute_command!("echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc")
28
+ execute_command!("gem update --system")
29
+ say_ok(" Installation complete!")
30
+ end
31
+ else
32
+ notify_package_unavailable!
33
+ end
34
+ end
35
+ end
36
+
37
+ def upgrade
38
+ if package_installed?("ruby -v")
39
+ execute_command!("gem update --system")
40
+ say_ok(" Upgrade complete!")
41
+ else
42
+ notify_package_missing!
43
+ end
44
+ end
45
+
46
+ def uninstall
47
+ if package_installed?("ruby -v")
48
+ output = ask(" [?] Which version? ") { |q| q.default = "2.2.2" }
49
+ execute_command!("rbenv uninstall #{output}")
50
+ say_ok(" Uninstallation complete!")
51
+ else
52
+ notify_package_missing!
53
+ end
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,55 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class RubyBuild < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::RubyBuild contains code that
6
+ # execute the ruby-build package.
7
+
8
+ private
9
+
10
+ def install
11
+ if package_installed?(includes: "ruby-build")
12
+ notify_package_exists!
13
+ else
14
+ case $operating_system
15
+ when :macosx, :linux
16
+ execute_command!("brew install ruby-build")
17
+ say_ok(" Installation complete!")
18
+ else
19
+ notify_package_unavailable!
20
+ end
21
+ end
22
+ end
23
+
24
+ def upgrade
25
+ if package_installed?(includes: "ruby-build")
26
+ case $operating_system
27
+ when :macosx, :linux
28
+ output = execute_command!("brew upgrade ruby-build")
29
+ say_warning(" [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:")
30
+ say_ok(" Upgrade complete!")
31
+ else
32
+ notify_package_unavailable!
33
+ end
34
+ else
35
+ notify_package_missing!
36
+ end
37
+ end
38
+
39
+ def uninstall
40
+ if package_installed?(includes: "ruby-build")
41
+ case $operating_system
42
+ when :macosx, :linux
43
+ execute_command!("brew remove ruby-build")
44
+ say_ok(" Uninstallation complete!")
45
+ else
46
+ notify_package_unavailable!
47
+ end
48
+ else
49
+ notify_package_missing!
50
+ end
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,64 @@
1
+ module ActiveScripts
2
+ module Packages
3
+ class Wkhtmltopdf < ActiveScripts::Packages::Base
4
+
5
+ # INFO: ActiveScripts::Packages::Wkhtmltopdf contains code that
6
+ # execute the wkhtmltopdf package.
7
+
8
+ private
9
+
10
+ def install
11
+ if package_installed?(command: "which wkhtmltopdf", includes: "wkhtmltopdf")
12
+ case $operating_system
13
+ when :linux
14
+ execute_command!("sudo apt-get -y install xvfb")
15
+ execute_command!("wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb")
16
+ execute_command!("sudo apt-get -y -f install")
17
+ execute_command!("sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb")
18
+ execute_command!("cat #{addendum_path!('wkhtmltopdf.txt')} > wkhtmltopdf.sh")
19
+ execute_command!("sudo chmod a+x wkhtmltopdf.sh")
20
+ execute_command!("sudo mv wkhtmltopdf.sh /usr/local/bin/")
21
+ say_ok(" Installation complete!")
22
+ else
23
+ notify_package_unavailable!
24
+ end
25
+ else
26
+ notify_package_missing!
27
+ end
28
+ end
29
+
30
+ def upgrade
31
+ if package_installed?(command: "which wkhtmltopdf", includes: "wkhtmltopdf")
32
+ case $operating_system
33
+ when :linux
34
+ execute_command!("sudo apt-get -y upgrade xvfb")
35
+ execute_command!("sudo apt-get -y -f upgrade")
36
+ execute_command!("wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb")
37
+ execute_command!("sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb")
38
+ say_ok(" Installation complete!")
39
+ else
40
+ notify_package_unavailable!
41
+ end
42
+ else
43
+ notify_package_missing!
44
+ end
45
+ end
46
+
47
+ def uninstall
48
+ if package_installed?(command: "which wkhtmltopdf", includes: "wkhtmltopdf")
49
+ case $operating_system
50
+ when :linux
51
+ execute_command!("sudo apt-get -y --purge remove xvfb")
52
+ execute_command!("sudo apt-get -y autoremove")
53
+ say_ok(" Installation complete!")
54
+ else
55
+ notify_package_unavailable!
56
+ end
57
+ else
58
+ notify_package_missing!
59
+ end
60
+ end
61
+
62
+ end
63
+ end
64
+ end