Skip to content

Commit 09975da

Browse files
author
Kristan Kenney
committed
Add restart flag to v-add-*-sftp-jail scripts and modify upgrade routine
This should help prevent service restart storm from issue hestiacp#370
1 parent 4cf01b8 commit 09975da

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

bin/v-add-sys-sftp-jail

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add system sftp jail
3-
# options: NONE
3+
# options: [RESTART]
44
#
55
# The script enables sftp jailed environment
66

@@ -14,6 +14,7 @@ source /etc/profile
1414
source $HESTIA/func/main.sh
1515
source $HESTIA/conf/hestia.conf
1616

17+
restart=$1
1718

1819
#----------------------------------------------------------#
1920
# Verifications #
@@ -45,11 +46,12 @@ if [ -z "$sftp_i" ]; then
4546
echo " X11Forwarding no" >> $config
4647
echo " AllowTCPForwarding no" >> $config
4748
echo " ForceCommand internal-sftp" >> $config
48-
restart='yes'
4949
fi
5050

5151
# Validating opensshd config
52-
if [ "$restart" = 'yes' ]; then
52+
if [ "$restart" = 'no' ]; then
53+
# Skip restarting SSH daemon
54+
else
5355
subj="OpenSSH restart failed"
5456
email=$(grep CONTACT $HESTIA/data/users/admin/user.conf |cut -f 2 -d \')
5557
/usr/sbin/sshd -t >/dev/null 2>&1
@@ -59,7 +61,6 @@ if [ "$restart" = 'yes' ]; then
5961
echo -e "$mail_text" |$SENDMAIL -s "$subj" $email
6062
else
6163
service ssh restart >/dev/null 2>&1
62-
service sshd restart >/dev/null 2>&1
6364
fi
6465
fi
6566

bin/v-add-user-sftp-jail

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add user sftp jail
3-
# options: USER
3+
# options: USER [RESTART]
44
#
55
# The script enables sftp jailed environment
66

@@ -11,6 +11,7 @@
1111

1212
# Argument definition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $HESTIA/func/main.sh
@@ -62,8 +63,11 @@ chown root:root /home/$user
6263
#----------------------------------------------------------#
6364

6465
# Restart ssh service
65-
service ssh restart > /dev/null 2>&1
66-
service sshd restart > /dev/null 2>&1
66+
if [ "$restart" = 'no' ]; then
67+
# Skip restart of SSH daemon
68+
else
69+
service ssh restart > /dev/null 2>&1
70+
fi
6771

6872
# Logging
6973
log_event "$OK" "$ARGUMENTS"

install/upgrade/1.00.0-190618.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,13 @@ if [ ! -z "$WEBALIZER_CHECK" ]; then
323323
fi
324324

325325
# Run sftp jail once
326-
$HESTIA/bin/v-add-sys-sftp-jail
326+
$HESTIA/bin/v-add-sys-sftp-jail no
327327

328328
# Enable SFTP subsystem for SSH
329329
sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
330330
if [ ! -z "$sftp_subsys_enabled" ]; then
331331
echo "(*) Updating SFTP subsystem configuration..."
332332
sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
333-
systemctl restart ssh
334333
fi
335334

336335
# Remove and migrate obsolete object keys
@@ -423,8 +422,9 @@ if [ ! -z $DNS_SYSTEM ]; then
423422
$BIN/v-restart-dns $restart
424423
fi
425424

426-
# restart Hestia services (nginx,php-fpm)
427-
systemctl restart hestia
425+
$BIN/v-restart-service ssh $restart
426+
$BIN/v-restart-service hestia $restart
427+
428428

429429
echo ""
430430
echo " Upgrade complete! Please report any bugs or issues to"

0 commit comments

Comments
 (0)