Skip to content

Commit e18e37e

Browse files
authored
Feature/2021 01 roundcube disconnect atp (hestiacp#1537)
* Remove Roundcoube from installer + create v-add-sys-roundcube * Roundcube installer working * Upgrade script ATP to non atp version roundcube * Fix minor bug while upgrading manualy * Update installers to install roundcube on default
1 parent 7edd04b commit e18e37e

File tree

9 files changed

+438
-962
lines changed

9 files changed

+438
-962
lines changed

bin/v-add-sys-roundcube

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#!/bin/bash
2+
# info: Install RoundCube for Nginx/Apache2
3+
# options: [MODE]
4+
# labels: hestia
5+
#
6+
# The function installs Round Cube
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Includes
13+
source $HESTIA/func/main.sh
14+
source $HESTIA/conf/hestia.conf
15+
source $HESTIA/install/upgrade/upgrade.conf
16+
17+
MODE=$2
18+
UPDATE="no"
19+
# Version and Download paths
20+
RC_FILE="roundcubemail-$rc_v-complete.tar.gz"
21+
RC_EXTRACT="roundcubemail-$rc_v"
22+
# Downloading full version
23+
RC_URL="https://github.com/roundcube/roundcubemail/releases/download/$rc_v/roundcubemail-$rc_v-complete.tar.gz"
24+
25+
# Folder paths
26+
RC_INSTALL_DIR="/var/lib/roundcube"
27+
RC_CONFIG_DIR="/etc/roundcube"
28+
RC_LOG="/var/log/roundcube"
29+
30+
#----------------------------------------------------------#
31+
# Verifications #
32+
#----------------------------------------------------------#
33+
34+
# Checking root permissions
35+
if [ "x$(id -u)" != 'x0' ]; then
36+
echo "ERROR: v-add-sys-roundcube can be run executed only by root user"
37+
exit 10
38+
fi
39+
40+
# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
41+
if [ -z "$HESTIA" ]; then
42+
HESTIA="/usr/local/hestia"
43+
fi
44+
45+
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
46+
echo "ERROR: Environment variables not present, installation aborted."
47+
exit 2
48+
fi
49+
50+
if [ -z "$(echo "$DB_SYSTEM" | grep -w 'mysql')" ]; then
51+
echo "ERROR: Mysql not available. Instalation aborted"
52+
exit 2
53+
fi
54+
55+
if [ -d "/usr/share/roundcube" ]; then
56+
echo "ERROR: Install done from atp source unable to continue"
57+
exit 2;
58+
fi
59+
60+
# Get current version
61+
if [ -f "/var/lib/roundcube/index.php" ]; then
62+
version=$(cat $RC_INSTALL_DIR/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
63+
if [ "$version" == "$rc_v" ]; then
64+
echo "Error: Installed version ($version) is equal as the availble version ($rc_v)"
65+
exit 2;
66+
else
67+
UPDATE="yes"
68+
fi
69+
fi
70+
71+
# Perform verification if read-only mode is enabled
72+
check_hestia_demo_mode
73+
74+
#----------------------------------------------------------#
75+
# Action #
76+
#----------------------------------------------------------#
77+
78+
if [ "$UPDATE" == "no" ]; then
79+
rm -f -r $RC_INSTALL_DIR
80+
rm -f -r $RC_CONFIG_DIR
81+
82+
mkdir -p $RC_INSTALL_DIR/
83+
mkdir -p $RC_CONFIG_DIR/
84+
85+
cd "$RC_INSTALL_DIR"
86+
[ ! -f "${RC_INSTALL_DIR}/${RC_FILE}" ] && wget "$RC_URL" --quiet -O "${RC_INSTALL_DIR}/${RC_FILE}"
87+
88+
tar xzf $RC_FILE
89+
cp -rf $RC_EXTRACT/* $RC_INSTALL_DIR
90+
91+
# Delete old config folder
92+
cp $RC_INSTALL_DIR/config/defaults.inc.php $RC_CONFIG_DIR/defaults.inc.php
93+
rm -f -r $RC_INSTALL_DIR/config/
94+
ln -s $RC_CONFIG_DIR/ ./config
95+
# Replace with Hestia config
96+
cp -f $HESTIA_INSTALL_DIR/roundcube/main.inc.php $RC_CONFIG_DIR/config.inc.php
97+
cp -f $HESTIA_INSTALL_DIR/roundcube/mimetypes.php $RC_CONFIG_DIR/mimetypes.php
98+
99+
cp -f $HESTIA_INSTALL_DIR/roundcube/hestia.php $RC_INSTALL_DIR/plugins/password/drivers/
100+
mkdir -p $RC_CONFIG_DIR/plugins/password
101+
mkdir -p $RC_CONFIG_DIR/plugins/newmail_notifier
102+
mkdir -p $RC_CONFIG_DIR/plugins/zipdownload
103+
104+
# Allow changes to the respective config / Create symlinks to /etc/roundcube/
105+
cp -f $HESTIA_INSTALL_DIR/roundcube/config.inc.php $RC_CONFIG_DIR/plugins/password/config.inc.php
106+
ln -s $RC_CONFIG_DIR/plugins/password/config.inc.php ./plugins/password/config.inc.php
107+
cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_newmail_notifier.inc.php $RC_CONFIG_DIR/plugins/newmail_notifier/config.inc.php
108+
ln -s $RC_CONFIG_DIR/plugins/newmail_notifier/config.inc.php ./plugins/newmail_notifier/config.inc.php
109+
cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_zipdownload.inc.php $RC_CONFIG_DIR/plugins/zipdownload/config.inc.php
110+
ln -s $RC_CONFIG_DIR/plugins/zipdownload/config.inc.php ./plugins/zipdownload/config.inc.php
111+
112+
113+
chmod 640 $RC_CONFIG_DIR/config.inc.php
114+
chown root:www-data $RC_CONFIG_DIR/config.inc.php
115+
116+
# Log file
117+
if [ ! -d $RC_LOG ];then
118+
mkdir $RC_LOG
119+
fi
120+
chown www-data:root $RC_LOG
121+
chmod 751 $RC_LOG
122+
123+
if [ ! -z "$(echo "$DB_SYSTEM" | grep -w 'mysql')" ]; then
124+
# Remove the following 2 lines when going live
125+
mysql -e "DROP DATABASE roundcube"
126+
mysql -e "DROP USER roundcube@localhost"
127+
mysql -e "CREATE DATABASE roundcube"
128+
# Mysql available on system
129+
r=$(generate_password)
130+
mysql -e "GRANT ALL ON roundcube.*
131+
TO roundcube@localhost IDENTIFIED BY '$r'"
132+
sed -i "s/%password%/$r/g" $RC_CONFIG_DIR/config.inc.php
133+
mysql roundcube < /var/lib/roundcube/SQL/mysql.initial.sql
134+
fi
135+
# To do in future add support for Postgresql only setup
136+
137+
rcDesKey="$(openssl rand -base64 30 | tr -d "/" | cut -c1-24)"
138+
sed -i "s/%des_key%/$rcDesKey/g" $RC_CONFIG_DIR/config.inc.php
139+
# Change hostname for password change
140+
sed -i "s/localhost/$(hostname)/g" $RC_CONFIG_DIR/plugins/password/config.inc.php
141+
142+
#Clean up
143+
rm -f -r $RC_INSTALL_DIR/installer;
144+
rm -f -r $RC_INSTALL_DIR/$RC_FILE;
145+
rm -f -r $RC_INSTALL_DIR/$RC_EXTRACT;
146+
147+
# Add robots.txt
148+
echo "User-agent: *" > /var/lib/roundcube/robots.txt
149+
echo "Disallow: /" >> /var/lib/roundcube/robots.txt
150+
151+
# Updating hestia.conf
152+
if [ -z "$(grep WEBMAIL_SYSTEM $HESTIA/conf/hestia.conf)" ]; then
153+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' 'roundcube'
154+
else
155+
if [ -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
156+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "roundcube"
157+
else
158+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "roundcube,$WEBMAIL_SYSTEM"
159+
fi
160+
fi
161+
162+
phpenmod mcrypt > /dev/null 2>&1
163+
else
164+
rm -f -r $RC_INSTALL_DIR
165+
mkdir $RC_INSTALL_DIR
166+
cd "$RC_INSTALL_DIR"
167+
[ ! -f "${RC_INSTALL_DIR}/${RC_FILE}" ] && wget "$RC_URL" --quiet -O "${RC_INSTALL_DIR}/${RC_FILE}"
168+
169+
tar xzf $RC_FILE
170+
cp -rf $RC_EXTRACT/* $RC_INSTALL_DIR
171+
172+
cp -f $RC_INSTALL_DIR/config/defaults.inc.php $RC_CONFIG_DIR/defaults.inc.php
173+
rm -f -r $RC_INSTALL_DIR/config/
174+
ln -s $RC_CONFIG_DIR/ ./config
175+
176+
ln -s $RC_CONFIG_DIR/plugins/password/config.inc.php ./plugins/password/config.inc.php
177+
ln -s $RC_CONFIG_DIR/plugins/newmail_notifier/config.inc.php ./plugins/newmail_notifier/config.inc.php
178+
ln -s $RC_CONFIG_DIR/plugins/zipdownload/config.inc.php ./plugins/zipdownload/config.inc.php
179+
180+
$RC_INSTALL_DIR/bin/update.sh --version "$version"
181+
182+
rm -f -r $RC_INSTALL_DIR/installer;
183+
rm -f -r $RC_INSTALL_DIR/$RC_FILE;
184+
rm -f -r $RC_INSTALL_DIR/$RC_EXTRACT;
185+
fi
186+
#----------------------------------------------------------#
187+
# Logging #
188+
#----------------------------------------------------------#
189+
190+
191+
192+
log_history "Rouncube successfuly installed" '' 'admin'
193+
log_event "$OK" "$ARGUMENTS"

func/upgrade.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ upgrade_health_check() {
126126
echo "[ ! ] Adding missing variable to hestia.conf: LOGIN_STYLE ('default')"
127127
$BIN/v-change-sys-config-value "LOGIN_STYLE" "default"
128128
fi
129+
if [ -z "$WEBMAIL_SYSTEM" ]; then
130+
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('')"
131+
$BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" ""
132+
fi
129133

130134
# Inactive session timeout
131135
if [ -z "$INACTIVE_SESSION_TIMEOUT" ]; then
@@ -630,6 +634,18 @@ upgrade_filemanager_update_config() {
630634
fi
631635
}
632636

637+
upgrade_roundcube(){
638+
if [ "UPGRADE_UPDATE_ROUNDCUBE" = "true" ]; then
639+
if [ ! -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
640+
rc_version=$(cat $RC_INSTALL_DIR/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
641+
if [ "$rc_version" == "$rc_v" ]; then
642+
echo "[ * ] Upgrading RoundCube to version v$rc_v..."
643+
$HESTIA/bin/v-add-sys-roundcube
644+
fi
645+
fi
646+
fi
647+
}
648+
633649
upgrade_rebuild_web_templates() {
634650
if [ "$UPGRADE_UPDATE_WEB_TEMPLATES" = "true" ]; then
635651
echo "[ ! ] Updating default web domain templates..."

install/deb/roundcube/config.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
// -----------------------
55
// A driver to use for password change. Default: "sql".
66
// See README file for list of supported driver names.
7-
$rcmail_config['password_driver'] = 'hestia';
7+
$config['password_driver'] = 'hestia';
88

99
// Require the new password to be a certain length.
1010
// set to blank to allow passwords of any length
11-
$rcmail_config['password_minimum_length'] = 8;
11+
$config['password_minimum_length'] = 8;
1212

1313
// Require the new password to contain a letter and punctuation character
1414
// Change to false to remove this check.
15-
$rcmail_config['password_require_nonalpha'] = false;
15+
$config['password_require_nonalpha'] = false;
1616

1717
// Enables logging of password changes into logs/password
18-
$rcmail_config['password_log'] = false;
18+
$config['password_log'] = false;
1919

2020
// Comma-separated list of login exceptions for which password change
2121
// will be not available (no Password tab in Settings)
22-
$rcmail_config['password_login_exceptions'] = null;
22+
$config['password_login_exceptions'] = null;
2323

2424
// By default domains in variables are using unicode.
2525
// Enable this option to use punycoded names
26-
$rcmail_config['password_idn_ascii'] = false;
26+
$config['password_idn_ascii'] = false;
2727

2828
// Hestia Driver options
2929
// -----------------------
3030
// Control Panel host
31-
$rcmail_config['password_hestia_host'] = 'localhost';
32-
$rcmail_config['password_hestia_port'] = '8083';
31+
$config['password_hestia_host'] = 'localhost';
32+
$config['password_hestia_port'] = '8083';

0 commit comments

Comments
 (0)