vlad_freebsd 1.0.0 → 1.0.1
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.
- data/History.txt +3 -0
- data/README.txt +14 -8
- data/lib/vlad/freebsd.rb +35 -5
- data/lib/vlad_freebsd.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
= vlad_freebsd
|
2
2
|
|
3
|
-
*
|
3
|
+
* http://www.bitbucket.org/mml/vlad_freebsd
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
|
7
|
+
A few simple functions to ease provisioning FreeBSD systems.
|
8
8
|
|
9
9
|
== FEATURES/PROBLEMS:
|
10
10
|
|
11
|
-
*
|
11
|
+
* Create users
|
12
|
+
* Update ports tree
|
13
|
+
* Install ports with custom flags.
|
12
14
|
|
13
15
|
== SYNOPSIS:
|
14
16
|
|
15
|
-
|
17
|
+
Simply
|
18
|
+
|
19
|
+
require 'vlad/freebsd' in your rakefile to gain access to the functions.
|
16
20
|
|
17
21
|
== REQUIREMENTS:
|
18
22
|
|
19
|
-
*
|
23
|
+
* portupgrade package
|
24
|
+
* sudo
|
25
|
+
* a login with sudo access on the FreeBSD system
|
20
26
|
|
21
27
|
== INSTALL:
|
22
28
|
|
23
|
-
*
|
29
|
+
* gem install vlad_freebsd
|
24
30
|
|
25
31
|
== DEVELOPERS:
|
26
32
|
|
27
|
-
|
33
|
+
See rdoc for more information on available functions
|
28
34
|
|
29
35
|
$ rake newb
|
30
36
|
|
@@ -35,7 +41,7 @@ and generate the RDoc.
|
|
35
41
|
|
36
42
|
(The MIT License)
|
37
43
|
|
38
|
-
Copyright (c) 2010
|
44
|
+
Copyright (c) 2010 McClain Looney
|
39
45
|
|
40
46
|
Permission is hereby granted, free of charge, to any person obtaining
|
41
47
|
a copy of this software and associated documentation files (the
|
data/lib/vlad/freebsd.rb
CHANGED
@@ -1,15 +1,37 @@
|
|
1
|
+
#This file defines a number of methods for manipulating a FreeBSD system. Simply require this file into your vlad rakefile.
|
2
|
+
#
|
3
|
+
#Some examples:
|
4
|
+
#
|
5
|
+
# remote_task :on_app, :roles => :app do
|
6
|
+
# pass_ruby = "/usr/local/bin/ruby"
|
7
|
+
# put_template 'etc/nginx.conf.erb', '/usr/local/etc/nginx/nginx.conf', binding
|
8
|
+
# install_port "devel/ruby-gems"
|
9
|
+
# install_port "www/nginx" do |cmdar|
|
10
|
+
# cmdar.last << "-M 'WITH_HTTP_UPLOAD_PROGRESS=1 WITH_HTTP_UPLOAD_MODULE=1 WITH_PASSENGER_MODULE=1'"
|
11
|
+
# end
|
12
|
+
# install_port "databases/postgresql84-client" do |cmdar|
|
13
|
+
# cmdar.last << "-M 'WITHOUT_NLS=1 WITHOUT_XML=1 WITHOUT_LDAP=1 WITH_TZDATA=1 WITH_INTDATE=1'"
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
|
17
|
+
# Uploads file as a public key
|
18
|
+
# [user] username
|
19
|
+
# [keyfile] keyfile to upload (.ssh/id_dsa.pub is a popular choice)
|
1
20
|
def upload_pubkey(user, keyfile)
|
2
21
|
run sudo "mkdir -pvm 755 ~#{user}/.ssh"
|
3
|
-
put_template keyfile, '
|
4
|
-
run "chown #{user}:#{user} ~#{user}/.authorized_keys"
|
22
|
+
put_template keyfile, '~/#{user}/.ssh/authorized_keys', binding
|
23
|
+
run "chown #{user}:#{user} ~#{user}/.ssh/.authorized_keys"
|
5
24
|
end
|
6
25
|
|
26
|
+
# Updates ports, uses portsnap update.
|
7
27
|
def update_ports
|
8
28
|
sudo "portsnap update"
|
9
29
|
end
|
10
30
|
|
11
|
-
#
|
12
|
-
#will only add a user if it doesn't exist
|
31
|
+
# This is a driver for the pw command. pass arguments in as a hash of k-v. simple flags map to nil.
|
32
|
+
# will only add a user if it doesn't exist
|
33
|
+
# You can pass arbitrary arguments to pw using the args hash in the form:
|
34
|
+
# {'-flag'=>'value'}. See the pw man page for extensive documentation.
|
13
35
|
def adduser(username, args={})
|
14
36
|
args = { '-s' => '/usr/local/bin/bash', "-c"=>"'service user'", "-n"=>username, "-m"=>nil, '-w'=>'no'}.merge(args)
|
15
37
|
slug = "if [ $(id -u sophia > /dev/null) ];then \n"
|
@@ -22,7 +44,9 @@ def adduser(username, args={})
|
|
22
44
|
sudo slug
|
23
45
|
end
|
24
46
|
|
25
|
-
|
47
|
+
# Installs a port. Uses the portinstall command in --batch mode. Note that if a block is passed, an array is yielded
|
48
|
+
# allowing the caller to manipulate the actually executed command; handy for setting make args and the like. See
|
49
|
+
# portinstall manpage for extensive documentation.
|
26
50
|
def install_port(port)
|
27
51
|
commands = []
|
28
52
|
commands << "portinstall --batch #{port} "
|
@@ -32,6 +56,12 @@ def install_port(port)
|
|
32
56
|
commands.each {|x| sudo x}
|
33
57
|
end
|
34
58
|
|
59
|
+
# Upload a file and copy it into a final location. Uses sudo to copy after uploading. Templating
|
60
|
+
# is done via ERB, the user passes in the desired binding.
|
61
|
+
#
|
62
|
+
# [tmpl] template file
|
63
|
+
# [dest] destination path
|
64
|
+
# [b] binding
|
35
65
|
def put_template(tmpl, dest, b)
|
36
66
|
tmpl = File.read(tmpl)
|
37
67
|
buf = ERB.new(tmpl).result(b)
|
data/lib/vlad_freebsd.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vlad_freebsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- McClain Looney
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 2.5.0
|
44
44
|
version:
|
45
|
-
description:
|
45
|
+
description: A few simple functions to ease provisioning FreeBSD systems.
|
46
46
|
email:
|
47
47
|
- m@loonsoft.com
|
48
48
|
executables: []
|
@@ -85,6 +85,6 @@ rubyforge_project: vlad_freebsd
|
|
85
85
|
rubygems_version: 1.3.5
|
86
86
|
signing_key:
|
87
87
|
specification_version: 3
|
88
|
-
summary:
|
88
|
+
summary: A few simple functions to ease provisioning FreeBSD systems.
|
89
89
|
test_files: []
|
90
90
|
|