-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-cfengine-community-375-lts.sh
More file actions
executable file
·95 lines (65 loc) · 2.86 KB
/
install-cfengine-community-375-lts.sh
File metadata and controls
executable file
·95 lines (65 loc) · 2.86 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
#
# install cfengine community 3.7.5
#
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
msg() {
echo "$1"
}
die() {
echo "$1" >&2
exit 1
}
check_prereqs() {
[ -f /etc/debian_version ] || die "FATAL: not a debian system"
which wget >/dev/null 2>&1 || die "FATAL: unable to find wget in \$PATH"
which apt-get >/dev/null 2>&1 || die "FATAL: unable to find apt-get in \$PATH"
which systemctl >/dev/null 2>&1 || die "FATAL: unable to find systemctl in \$PATH"
}
handle_error() {
if [ $1 -ne 0 ]; then
die "FATAL: error while $2 (retval=$1)"
else
msg "INFO: completed $2"
fi
}
install_packages() {
apt-get --no-install-recommends --assume-yes install apt-transport-https python >/dev/null 2>&1
handle_error $? "installation of: apt-transport-https python"
}
install_vim() {
apt-get --no-install-recommends --assume-yes install vim >/dev/null 2>&1
handle_error $? "installation of: vim"
vim_dir=$(find /usr/share/vim -type d -regex '^/usr/share/vim/vim[0-9][0-9]$')
if [ -d "$vim_dir" ]; then
wget -O $vim_dir/syntax/cf3.vim https://raw.githubusercontent.com/neilhwatson/vim_cf3/master/syntax/cf3.vim >/dev/null 2>&1
handle_error $? "installation of syntax file for cfengine3"
chmod 0644 $vim_dir/syntax/cf3.vim
wget -O $vim_dir/ftplugin/cf3.vim https://raw.githubusercontent.com/neilhwatson/vim_cf3/master/ftplugin/cf3.vim >/dev/null 2>&1
handle_error $? "installation of ftplugin for cfengine3"
chmod 0644 $vim_dir/ftplugin/cf3.vim >/dev/null 2>&1
fi
}
install_cfengine() {
wget -qO- https://cfengine-package-repos.s3.amazonaws.com/pub/gpg.key | apt-key add - >/dev/null 2>&1
handle_error $? "installation of cfengine package signing key"
echo "deb https://cfengine-package-repos.s3.amazonaws.com/pub/apt/packages stable main" > /etc/apt/sources.list.d/cfengine-community.list
handle_error $? "installation of cfengine package repository"
apt-get update >/dev/null 2>&1
handle_error $? "update of local package cache"
LATEST_LTS=$(apt-cache show cfengine-community | grep ^Version:.3.7 | sort | cut -d' ' -f 2 | tail -n1)
apt-get --no-install-recommends --assume-yes install cfengine-community=${LATEST_LTS} >/dev/null 2>&1
handle_error $? "installation of: cfengine-community=${LATEST_LTS}"
systemctl stop cfengine3 >/dev/null 2>&1
handle_error $? "stopping of service cfengine3"
echo "RUN_CF_SERVERD=1" > /etc/default/cfengine3
echo "RUN_CF_EXECD=1" >> /etc/default/cfengine3
echo "RUN_CF_MONITORD=1" >> /etc/default/cfengine3
echo "RUN_CF_HUB=0" >> /etc/default/cfengine3
#systemctl start cfengine3 >/dev/null 2>&1
#handle_error $? "starting of service cfengine3"
}
check_prereqs
install_packages
install_vim
install_cfengine