Skip to content

Commit 90e0bbd

Browse files
committed
FM installer: cleanup and env check
1 parent 58d0519 commit 90e0bbd

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

install/deb/filemanager/install-fm.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/bin/bash
22

3+
# Checking root permissions
4+
if [ "x$(id -u)" != 'x0' ]; then
5+
echo "Error: Script can be run executed only by root"
6+
exit 10
7+
fi
8+
39
if [ -z "$HESTIA" ]; then
410
HESTIA="/usr/local/hestia"
511
fi
612

7-
# Hestia php-fpm pool user
813
user='admin'
9-
1014
source $HESTIA/func/main.sh
1115

16+
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
17+
echo "Error: Hestia environment vars not present"
18+
exit 2
19+
fi
20+
1221
FM_INSTALL_DIR="$HESTIA/web/fm"
1322

1423
FM_V="7.4.1"
@@ -27,15 +36,15 @@ if [ ! -f "$COMPOSER_BIN" ]; then
2736
check_result $? "Create temp file"
2837
chown $user: "$COMPOSER_SETUP_FILE"
2938

30-
signature="$(curl https://composer.github.io/installer.sig)"
39+
signature="$(curl --silent --show-error https://composer.github.io/installer.sig)"
3140
check_result $? "Download signature"
3241

3342
user_exec wget --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache https://getcomposer.org/installer --quiet -O "$COMPOSER_SETUP_FILE"
3443
check_result $? "Download composer installer"
3544

3645
[[ "$signature" = $(sha384sum $COMPOSER_SETUP_FILE | cut -f 1 -d " ") ]] || check_result $E_INVALID "Composer signature does not match"
3746

38-
COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php "$COMPOSER_SETUP_FILE" --install-dir="$COMPOSER_DIR" --filename=composer
47+
COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php "$COMPOSER_SETUP_FILE" --quiet --install-dir="$COMPOSER_DIR" --filename=composer
3948
check_result $? "Composer install failed"
4049

4150
[ -f "$COMPOSER_SETUP_FILE" ] && rm -f "$COMPOSER_SETUP_FILE"
@@ -50,12 +59,14 @@ cd "$FM_INSTALL_DIR"
5059
unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
5160
mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
5261
rm --recursive --force ${FM_INSTALL_DIR}/filegator
53-
chown root: "${FM_INSTALL_DIR}"
5462

5563
cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
5664

57-
COMPOSER_HOME="$HOMEDIR/$user/.config/composer" $COMPOSER_BIN require league/flysystem-sftp
65+
chown $user: -R "${FM_INSTALL_DIR}"
66+
COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php $COMPOSER_BIN --quiet require league/flysystem-sftp
67+
check_result $? "Install filemanager dependency"
5868

69+
chown root: -R "${FM_INSTALL_DIR}"
5970
chown $user: "${FM_INSTALL_DIR}/private"
6071
chown $user: "${FM_INSTALL_DIR}/private/logs"
6172
chown $user: "${FM_INSTALL_DIR}/repository"

0 commit comments

Comments
 (0)