-
Notifications
You must be signed in to change notification settings - Fork 1
/
znc-git-autoinstall-ubuntu.sh
executable file
·252 lines (192 loc) · 7.21 KB
/
znc-git-autoinstall-ubuntu.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash
######## Automate Git Master Build Script - ZNC on Ubuntu 14.04 ########
SCRIPT_VERSION="0.2"
SCRIPT_DESIGNED_FOR_ZNC_VERSION="1.5-git (pre-1.6)"
##### VARIABLES #####
## Location of where the `znc` folder will be made on git clone
GIT_FOLDER_PARENT_LOCATION="/home/$USER/"
GIT_FOLDER_ACTUAL_LOCATION="$GIT_FOLDER_PARENT_LOCATION/znc"
## Feature enablement flags.
ENABLE_TCL=true # True enables modtcl and the Tcl Plugin API for ZNC
ENABLE_CYRUS=true # True enables cyrusauth module.
ENABLE_PERL=true # True enables modperl and the Perl Plugin APi for ZNC
ENABLE_PYTHON=true # True enables modpython and the Python Plugin API for ZNC
## Additional ./configure arguments
PREFIX_DIR="/usr"
LIB_DIR="/usr/lib"
## Ubuntu Version Determining and Checks
# (1) Make sure we're on Ubuntu
LINUX_DISTRIBUTOR_ID=$(lsb_release --short --id)
if (( "$LINUX_DISTRIBUTOR_ID" != "Ubuntu" )); then
echo "This script is for Ubuntu only! Do not use it with other distros!"
echo
echo "Script exited with error, code: 1"
exit -1
fi
# (2) If we are, then if version of Ubuntu OLDER than 12.04, then that is
# too old to be used.
UBUNTU_VERSION=$(lsb_release --short --release)
if [[ "$UBUNTU_VERSION" < "12.04" ]]; then
echo "Your Ubuntu version is too old to work with the git master of ZNC."
echo "Please use this script with Ubuntu 12.04 or newer."
echo
echo "Script exited with error, code: 2"
exit 1
fi
# (3) PPA arch limitations.
ARCHITECTURE=$(uname -m)
if [[ $ARCHITECTURE == arm* ]]; then
IS_ARCH_ARM=true
fi
if [[ "$ARCHITECTURE" != "x86_64" ]] || [[ "$ARCHITECTURE" != "i386" ]] || [[ "$ARCHITECTURE" != "i686" ]] || [[ "$ARCHITECTURE" != "x86" ]]; then
if ! $IS_ARCH_ARM; then
echo "This script and PPAs do not work with anything that is not"
echo "x86 (i386/i686), x86_64 (amd64), or arm (armhf)."
echo
echo "Script exited with error, code: 3"
exit 3
fi
fi
##### Create full configure string #####
CONFIGURE_STRING="--prefix=$PREFIX_DIR --libdir=$LIB_DIR"
if $ENABLE_TCL; then
CONFIGURE_STRING="$CONFIGURE_STRING --enable-tcl"
fi
if $ENABLE_CYRUS; then
CONFIGURE_STRING="$CONFIGURE_STRING --enable-cyrus"
fi
if $ENABLE_PERL; then
CONFIGURE_STRING="$CONFIGURE_STRING --enable-perl"
fi
if $ENABLE_PYTHON; then
CONFIGURE_STRING="$CONFIGURE_STRING --enable-python"
fi
##### Apt Packages List Generation #####
APT_PACKAGES_LIST="gcc-4.7 g++-4.7 build-essential libssl-dev pkg-config libicu-dev hardening-wrapper automake"
## Determine if swig3.0 is needed
if $ENABLE_PERL || $ENABLE_PYTHON; then
APT_PACKAGES_LIST="$APT_PACKAGES_LIST swig3.0"
fi
## Determine if perl development libraries are needed
if $ENABLE_PERL; then
APT_PACKAGES_LIST="$APT_PACKAGES_LIST libperl-dev"
fi
## Determine if python development libraries are needed.
if $ENABLE_PYTHON; then
APT_PACKAGES_LIST="$APT_PACKAGES_LIST python3-dev python-support"
fi
## Determine if Tcl libraries are needed.
if $ENABLE_TCL; then
APT_PACKAGES_LIST="$APT_PACKAGES_LIST tcl8.5-dev"
fi
## Determine if SASL libraries are needed.
if $ENABLE_CYRUS; then
APT_PACKAGES_LIST="$APT_PACKAGES_LIST libsasl2-dev"
fi
##### Install `add-apt-repository` #####
sudo apt-get install -y software-properties-common python-software-properties
##### Determine if extra PPAs are needed. #####
#### gcc-4.7 ####
## If the Ubuntu release is not 14.04 or newer, then we need yet another PPA
## which will provide a version of the gcc (GNU C) compiler that supports
## C++11. As of 2015-01-20, this is gcc-4.7. This is not available in
## pre-14.04 Ubuntu and therefore a separate PPA is needed.
## If the Ubuntu version number is smaller than 14.04, then you need this
## other PPA in order to get gcc-4.7 from it. Trusty (14.04) and newer
## already have gcc-4.7 in the repositories.
if [[ "$UBUNTU_VERSION" < "14.04" ]] && ! $IS_ARCH_ARM; then
echo "Adding PPA for gcc-4.7..."
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
fi
#### libicu-dev ####
## If the Ubuntu release is not 14.04 or newer, then we need the PPA for
## the `icu` source package, for a working libicu-dev.
if [[ "$UBUNTU_VERSION" < "14.04" ]]; then
echo "Adding PPA for libicu-dev..."
sudo add-apt-repository -y ppa:teward/icu-backports
fi
#### swig 3.0 ####
## swig3.0 is needed for the Perl and Python modules. If these are set to be
## built in the boolean flags above, then we need to add a PPA for it.
if $ENABLE_PERL || $ENABLE_PYTHON; then
echo "Adding swig3.0 PPA..."
sudo add-apt-repository -y ppa:teward/swig3.0
fi
echo "Updating apt data..."
sudo apt-get update
#### INSTALL PACKAGES (Dependencies)
echo "Installing build dependencies via \`apt-get\`..."
sudo apt-get install -y $APT_PACKAGES_LIST
echo
echo
#### MANUAL STEPS ####
echo "Now for user actions BEFORE this can work! We have to specify that \`gcc\`"
echo "is actually at a different location and version. So, we have to run the "
echo "following commands MANUALLY in **another terminal window** before we can"
echo "continue on and build the software."
echo
echo "sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 \ "
echo " --slave /usr/bin/g++ g++ /usr/bin/g++-4.7"
echo "sudo update-alternatives --config gcc"
echo
echo "At this window, the system will prompt you to select which compiler to "
echo "use. Choose the number for the \`g++-4.7\` line, and hit 'ENTER'."
echo
echo "REMEMBER THE PREVIOUS ENTRY THOUGH! We need to set it back when done!"
echo
echo "Press the Enter key here in this terminal to continue after you've done "
echo "those steps."
echo
read
##### Check if parent dir exists. Make if not.
if [[ -d $GIT_FOLDER_PARENT_LOCATION ]]; then
mkdir -p $GIT_FOLDER_PARENT_LOCATION
fi
##### Get source code #####
cd $GIT_FOLDER_PARENT_LOCATION
git clone https://github.com/znc/znc.git
## Init the submodules (CSocket) #####
cd $GIT_FOLDER_ACTUAL_LOCATION
git submodule update --init --recursive
echo
##### Since this is from git, we need to run automake.sh.
./autogen.sh
echo
echo
##### Configure time!
## Assumed Configure String:
## If all module flags above are enabled...
# ./configure --prefix=$PREFIX_DIR --libdir=$LIB_DIR --enable-tcl --enable-cyrus --enable-python --enable-perl
echo "Running ./configure $CONFIGURE_STRING ..."
./configure $CONFIGURE_STRING
echo
echo
##### Time to compile!
echo "Building!"
make
echo
echo
## Time to install after compile. Overwrites ZNC on the disk already.
echo "Installing to System Directories!"
sudo make install
echo
##### Reset manual steps back. #####
echo "Now for user actions for cleanup! We have to reset things so that \`gcc\`"
echo "is actually at a different location and version. So, we have to run the "
echo "following commands MANUALLY in **another terminal window** before we can"
echo "continue on and build the software."
echo
echo "sudo update-alternatives --config g++"
echo
echo "At this window, the system will prompt you to select which compiler to "
echo "use. We said to take note of what it was set to before. Set it to what it"
echo "was before."
echo
echo "Press the Enter key here in this terminal to continue after you've done "
echo "those steps."
echo
read
echo
echo
echo "DONE! There may have been errors, so make sure to check!"
exit 0;