-
Notifications
You must be signed in to change notification settings - Fork 1
/
Capfile
42 lines (35 loc) · 933 Bytes
/
Capfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
load 'deploy'
load 'config/deploy'
# Apt Install a package
def apt_install(package, update=false)
apt_cmd = [
"env",
"DEBCONF_TERSE='yes'",
"DEBIAN_PRIORITY='critical'",
"DEBIAN_FRONTEND=noninteractive",
"apt-get --force-yes -qyu"
].join(" ")
sudo_bash([
"if [[ `dpkg -l #{package} 2> /dev/null` ]]; then",
"echo \"#{package} verified\";",
'else',
("#{apt_cmd} update;" if update),
"#{apt_cmd} install #{package};",
'fi'
].compact.join(' '))
end
# run apt update
def apt_update
apt_cmd = [
"env",
"DEBCONF_TERSE='yes'",
"DEBIAN_PRIORITY='critical'",
"DEBIAN_FRONTEND=noninteractive",
"apt-get --force-yes -qyu"
].join(" ")
sudo_bash("#{apt_cmd} update")
end
# exectute a command untirely as sudo in bash
def sudo_bash(cmd, options = {}, &blk)
sudo("/bin/bash -c \'#{cmd}\'", options, &blk)
end