-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·91 lines (78 loc) · 2.78 KB
/
install.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
#!/bin/bash
#
# This script will perform the installation of the mod_unread ejabberd
# module. It has the same requirements as described on the readme file. We
# download the module and install it to your systems ejabberd files.
#
# This script was tested on Ubuntu Bionic (18), and works just on
# Ubuntu/Debian.
#
# This script should be called like this:
#
# $ curl -L 'https://bit.ly/3esKfvM' | bash
#
# Used Ubuntu packages: wget
#
# @author Hermann Mayer <[email protected]>
# Fail on any errors
set -eE
# Specify the module/ejabberd version
MOD_VERSION=1.0.4
SUPPORTED_EJABBERD_VERSION=18.01
# Check for Debian/Ubuntu, otherwise die
if ! grep -P 'Ubuntu|Debian' /etc/issue >/dev/null 2>&1; then
echo 'Looks like you are not running Debian/Ubuntu.'
echo 'This installer is only working for them.'
echo 'Sorry.'
exit 1
fi
# Discover the installed ejabberd version
EJABBERD_VERSION=$(dpkg -l ejabberd | grep '^ii' \
| awk '{print $3}' | cut -d- -f1)
# Check for the ejabberd ebin repository, otherwise die
if [ -z "${EJABBERD_VERSION}" ]; then
echo 'ejabberd is currently not installed via apt.'
echo 'Suggestion: sudo apt-get install ejabberd'
exit 1
fi
# Check for the correct ejabberd version is available
if [ "${EJABBERD_VERSION}" != "${SUPPORTED_EJABBERD_VERSION}" ]; then
echo "The installed ejabberd version (${EJABBERD_VERSION}) is not supported."
echo "We just support ejabberd ${SUPPORTED_EJABBERD_VERSION}."
echo 'Sorry.'
exit 1
fi
# Discover the ejabberd ebin repository on the system
EBINS_PATH=$(dirname $(dpkg -L ejabberd \
| grep 'ejabberd.*/ebin/.*\.beam$' | head -n1))
# Check for the ejabberd ebin repository, otherwise die
if [ ! -d "${EBINS_PATH}" ]; then
echo 'No ejabberd ebin repository path was found.'
echo 'Sorry.'
exit 1
fi
# Download the module binary distribution and install it
URL="https://github.com/hausgold/ejabberd-unread/releases/"
URL+="download/${MOD_VERSION}/ejabberd-unread-${MOD_VERSION}.tar.gz"
cd /tmp
rm -rf ejabberd-unread ejabberd-unread.tar.gz
mkdir ejabberd-unread
wget -O ejabberd-unread.tar.gz "${URL}"
tar xf ejabberd-unread.tar.gz \
--no-same-owner --no-same-permissions -C ejabberd-unread
echo "Install ejabberd-unread to ${EBINS_PATH} .."
sudo chown root:root ejabberd-unread/{sql,ebin}/*
sudo chmod 0644 ejabberd-unread/{sql,ebin}/*
sudo cp -far ejabberd-unread/ebin/* "${EBINS_PATH}"
sudo mkdir -p "${EBINS_PATH}/../sql"
sudo cp -far ejabberd-unread/sql/* \
"${EBINS_PATH}/../sql/mod_unread.sql"
rm -rf ejabberd-unread ejabberd-unread.tar.gz
echo -e "\n\n"
echo -n 'The SQL migration file was installed to: '
echo $(realpath "${EBINS_PATH}/../sql/mod_unread.sql")
echo -n 'Take care of the configuration of mod_unread on '
echo '/etc/ejabberd/ejabberd.yml'
echo 'Restart the ejabberd server afterwards.'
echo
echo 'Done.'