-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
deployment.sh
165 lines (122 loc) · 3.8 KB
/
deployment.sh
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#! /usr/bin/env bash
# +----------------------------------------------------------------------------
# |
# | helper functions
# |
# +----------------------------------------------------------------------------
# prepare environment
# See http://www.davidpashley.com/articles/writing-robust-shell-scripts/
set -o nounset
set -o errexit
# catch exits and clean up if any is catched
trap "" INT TERM EXIT
LIBRARY_DIR="/vagrant/deployment/"
LOCALE="de_DE.utf8"
APT_BIN="apt"
function install_puppet {
puppet_source="https://apt.puppetlabs.com/puppetlabs-release-pc1-jessie.deb"
puppet_target="/tmp/puppet.deb"
echo '##########################'
echo '##########################'
echo Downloading puppet from $puppet_source
wget -q -O $puppet_target $puppet_source
echo '##########################'
echo '##########################'
echo Installing puppet from $puppet_target
dpkg -i $puppet_target
aptitude -q update
aptitude install -y puppet-agent
}
function setup_apt {
echo '##########################'
echo '##########################'
echo Determing package management tool
apt-get --allow-releaseinfo-change update
command -v aptitude && {
APT_BIN="aptitude"
}
command -v apt && {
APT_BIN="apt"
}
echo "Using $APT_BIN for package-management";
}
function upgrade_system {
echo '##########################'
echo '##########################'
echo Upgrading system
$APT_BIN update
$APT_BIN -y upgrade
}
function install_tools {
echo '##########################'
echo '##########################'
echo Installing base tools
$APT_BIN install -y htop tree vim git dnsutils telnet cpanminus build-essential curl wget
}
function set_time {
echo '##########################'
echo '##########################'
echo "Setup time & time zone"
# set timezone
echo "Europe/Berlin" > /etc/timezone
ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
# update time via ntp
# aptitude install ntpdate
# ntpdate europe.pool.ntp.org
# activate ntp and set timezone in systemd-mode
timedatectl set-ntp true
timedatectl set-timezone Europe/Berlin
timedatectl
}
function set_locale {
locale="$LOCALE"
echo '##########################'
echo '##########################'
echo Setup locale
echo "${locale} UTF-8" > /etc/locale.gen
sudo locale-gen ${locale}
export LC_ALL="${locale}"
#echo Would export LC_ALL="${locale}"
export LANG="${locale}"
#echo Would export LANG="${locale}"
export LANGUAGE="${locale}"
#echo Would export LANGUAGE="${locale}"
# update locale
echo "LANG=${locale}" > /etc/default/locale
echo "/etc/default/locale:";
cat /etc/default/locale
sudo update-locale LANG="${locale}"
sudo update-locale LANGUAGE="${locale}"
sudo update-locale LC_ALL="${locale}"
sudo DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales
# disable sshd's annoying LC_* copy
sed -e '/AcceptEnv/ s/^#*/#/' -i /etc/ssh/sshd_config
}
function show_ip {
ip address
}
# +----------------------------------------------------------------------------
# |
# | main
# |
# +----------------------------------------------------------------------------
export DEBIAN_FRONTEND=noninteractive
sudo -n su
setup_apt
upgrade_system
install_tools
set_time
set_locale
show_ip
# install application specific library files
echo "Try to install files in library at ${LIBRARY_DIR}"
test -d "${LIBRARY_DIR}" && {
echo "Found a library folder"
for lib_file in $(find ${LIBRARY_DIR} -iname '*.sh');
do
echo "Executing file ${lib_file}"
bash "${lib_file}" "$APT_BIN";
done
}
show_ip