Skip to content

Commit 4e1f0bb

Browse files
the-djmazem hagoortjaapmarcus
authored
Integrate SnappyMail and Drop support Rainloop (hestiacp#3590)
* Integrate SnappyMail * Drop support Rainloop + Update docs to remove rainloop * Minor changes installer * Set port during install --------- Co-authored-by: djmaze <> Co-authored-by: m hagoort <djmaze@laptop.mhxs> Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 5581300 commit 4e1f0bb

33 files changed

+359
-492
lines changed

.github/ISSUE_TEMPLATE/BUG-REPORT.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ body:
4444
- Let's Encrypt SSL
4545
- Mail (Exim, Dovecot)
4646
- Mail Security (Antivirus, Antispam)
47-
- Webmail (Roundcube, Rainloop)
47+
- Webmail (Roundcube, SnappyMail)
4848
- Firewall (Iptables, Fail2ban)
4949
validations:
5050
required: true

bin/v-add-mail-domain-ssl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ if [ "$WEBMAIL" == "roundcube" ]; then
9292
if [ "$WEB_SYSTEM" = "nginx" ]; then
9393
WEBMAIL_TEMPLATE="web_system"
9494
fi
95+
elif [ "$WEBMAIL" == "snappymail" ]; then
96+
WEBMAIL_TEMPLATE="snappymail"
97+
if [ -n "$PROXY_SYSTEM" ]; then
98+
PROXY_TEMPLATE="default_snappymail"
99+
fi
95100
elif [ "$WEBMAIL" == "rainloop" ]; then
96101
WEBMAIL_TEMPLATE="rainloop"
97102
if [ -n "$PROXY_SYSTEM" ]; then

bin/v-add-mail-domain-webmail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# options: USER DOMAIN [WEBMAIL] [RESTART] [QUIET]
44
#
55
# example: v-add-sys-webmail user domain.com
6-
# example: v-add-sys-webmail user domain.com rainloop
6+
# example: v-add-sys-webmail user domain.com snappymail
77
# example: v-add-sys-webmail user domain.com roundcube
88
#
99
# This function enables webmail client for a mail domain.

bin/v-add-sys-rainloop

Lines changed: 0 additions & 177 deletions
This file was deleted.

bin/v-add-sys-snappymail

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/bin/bash
2+
# info: Install SnappyMail webmail client
3+
# options: [MODE]
4+
#
5+
# This function installs the SnappyMail webmail client.
6+
7+
#----------------------------------------------------------#
8+
# Variables & Functions #
9+
#----------------------------------------------------------#
10+
11+
# Includes
12+
# shellcheck source=/etc/hestiacp/hestia.conf
13+
source /etc/hestiacp/hestia.conf
14+
# shellcheck source=/usr/local/hestia/func/main.sh
15+
source $HESTIA/func/main.sh
16+
# load config file
17+
source_conf "$HESTIA/conf/hestia.conf"
18+
# upgrade config file
19+
source "$HESTIA/install/upgrade/upgrade.conf"
20+
21+
MODE=$1
22+
UPDATE="no"
23+
# Version and Download paths
24+
# Version to be moved to upgrade script
25+
SM_FILE="snappymail-latest.tar.gz"
26+
# For removal of folder
27+
SM_EXTRACT_MAIN="snappymail"
28+
29+
# Downloading full version
30+
SM_URL="https://snappymail.eu/repository/latest.tar.gz"
31+
32+
# Folder paths
33+
SM_INSTALL_DIR="/var/lib/snappymail"
34+
SM_CONFIG_DIR="/etc/snappymail"
35+
SM_LOG="/var/log/snappymail"
36+
37+
#----------------------------------------------------------#
38+
# Verifications #
39+
#----------------------------------------------------------#
40+
41+
# Checking root permissions
42+
if [ "x$(id -u)" != 'x0' ]; then
43+
echo "ERROR: v-add-sys-snappymail can only be executed by the root user"
44+
exit 10
45+
fi
46+
47+
# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
48+
if [ -z "$HESTIA" ]; then
49+
HESTIA="/usr/local/hestia"
50+
fi
51+
52+
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
53+
echo "ERROR: Environment variables not present, installation aborted."
54+
exit 2
55+
fi
56+
57+
if [ -z "$(echo "$DB_SYSTEM" | grep -w 'mysql')" ]; then
58+
echo "ERROR: Mysql not available. Installation aborted"
59+
exit 2
60+
fi
61+
62+
# Get current version
63+
if [ -f "/var/lib/snappymail/data/VERSION" ]; then
64+
version=$(cat $SM_INSTALL_DIR/data/VERSION)
65+
if [ "$version" == "$sm_v" ]; then
66+
echo "Error: Installed version ($version) is equal to the available version ($sm_v)"
67+
exit 2
68+
else
69+
UPDATE="yes"
70+
fi
71+
fi
72+
73+
# Perform verification if read-only mode is enabled
74+
check_hestia_demo_mode
75+
76+
#----------------------------------------------------------#
77+
# Action #
78+
#----------------------------------------------------------#
79+
80+
if [ "$UPDATE" == "no" ]; then
81+
rm -f -r $SM_INSTALL_DIR
82+
rm -f -r $SM_CONFIG_DIR
83+
84+
mkdir $SM_INSTALL_DIR
85+
mkdir $SM_CONFIG_DIR
86+
87+
cd "$SM_INSTALL_DIR"
88+
[ ! -f "${SM_INSTALL_DIR}/${SM_FILE}" ] && wget "$SM_URL" --retry-connrefused --quiet -O "${SM_INSTALL_DIR}/${SM_FILE}"
89+
90+
if [ ! -f "${SM_INSTALL_DIR}/${SM_FILE}" ]; then
91+
echo "ERROR: Download failed, installation aborted."
92+
exit 2
93+
fi
94+
95+
# Get current version
96+
97+
key=$(openssl rand -hex 4)
98+
99+
admin_account="admin_$key"
100+
admin_password=$(generate_password)
101+
102+
echo "Username: admin_$key" > ~/.snappymail
103+
echo "Password: $admin_password" >> ~/.snappymail
104+
echo "Secret key: admin_$key" >> ~/.snappymail
105+
106+
tar -xzf ${SM_INSTALL_DIR}/${SM_FILE}
107+
108+
mv ./data $SM_CONFIG_DIR/
109+
ln -s $SM_CONFIG_DIR/data/ ./data
110+
111+
if [ -f '/usr/bin/mariadb' ]; then
112+
mariadb -e "CREATE DATABASE snappymail" 2>&1
113+
r=$(generate_password)
114+
mariadb -e "GRANT ALL ON snappymail.*
115+
TO snappymail@localhost IDENTIFIED BY '$r'"
116+
else
117+
mysql -e "CREATE DATABASE snappymail" 2>&1
118+
r=$(generate_password)
119+
mysql -e "GRANT ALL ON snappymail.*
120+
TO snappymail@localhost IDENTIFIED BY '$r'"
121+
fi
122+
php -f $HESTIA_COMMON_DIR/snappymail/install.php "admin_$key" "$admin_password" "$r" "$BACKEND_PORT"
123+
124+
chown -R www-data:www-data ./data
125+
chown -R www-data:www-data $SM_CONFIG_DIR/
126+
127+
rm ${SM_INSTALL_DIR}/${SM_FILE}
128+
# Add robots.txt
129+
echo "User-agent: *" > $SM_INSTALL_DIR/robots.txt
130+
echo "Disallow: /" >> $SM_INSTALL_DIR/robots.txt
131+
132+
# Updating hestia.conf
133+
if [ -z "$(grep WEBMAIL_SYSTEM $HESTIA/conf/hestia.conf)" ]; then
134+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' 'snappymail'
135+
else
136+
if [ -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'snappymail')" ]; then
137+
if [ -n "$WEBMAIL_SYSTEM" ]; then
138+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "snappymail,$WEBMAIL_SYSTEM"
139+
else
140+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "snappymail"
141+
fi
142+
fi
143+
fi
144+
145+
else
146+
[ ! -f "${SM_INSTALL_DIR}/${SM_FILE}" ] && wget "$SM_URL" --quiet -O "${SM_INSTALL_DIR}/${SM_FILE}"
147+
version=$(cat $SM_INSTALL_DIR/data/VERSION)
148+
149+
tar -xzf snappymail-latest.tar.gz "data/VERSION" $SM_INSTALL_DIR/
150+
version_source=$(cat $SM_INSTALL_DIR/VERSION)
151+
152+
# Check version inside .tar.gz file in case hestia didn't update yet
153+
if [ "$version" != "$version_source" ]; then
154+
tar -xzf ${SM_INSTALL_DIR}/${SM_FILE}
155+
rm $SM_INSTALL_DIR/$SM_FILE
156+
fi
157+
rm ${SM_INSTALL_DIR}/VERSION
158+
fi
159+
160+
#----------------------------------------------------------#
161+
# Hestia #
162+
#----------------------------------------------------------#
163+
164+
if [ "$UPDATE" = "yes" ]; then
165+
$BIN/v-log-action "system" "Info" "Plugins" "SnappyMail updated (Version: $version)."
166+
else
167+
$BIN/v-log-action "system" "Info" "Plugins" "SnappyMail enabled (Version: $version)."
168+
fi
169+
log_event "$OK" "$ARGUMENTS"

bin/v-change-sys-hostname

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ fi
5858
if [ -d /etc/rainloop/ ]; then
5959
sed -i "/hestia_host/c\hestia_host = \"$domain\"" /etc/rainloop/data/_data_/_default_/configs/plugin-hestia-change-password.ini
6060
fi
61+
if [ -d /etc/snappymail/ ]; then
62+
sed -i "/\"hestia_host\":/c\\\"hestia_host\": \"$domain\"," /etc/snappymail/data/_data_/_default_/configs/plugin-change-password.json
63+
fi
6164

6265
if [ -f /etc/hosts ]; then
6366
if ! cat /etc/hosts | grep $domain > /dev/null; then

0 commit comments

Comments
 (0)