diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 69123e950ab3fdf512e6c650822a1a8b8fbf4502..65a67a7232dfd7d54c1b7067fe73d5e8d9a58094 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -3,7 +3,7 @@ # Description: Setup or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail # BSD 3 License -# Updated on 20230919-103405 +# Updated on 20231027191348 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install @@ -163,7 +163,7 @@ set_nginx_conf () { rewrite ^/* /filemanager last; } - ## ELFINDER FILE MANAGER CONFIG STARTS ## + ## ELFINDER FILE MANAGER CONFIG ENDS ## EOT @@ -236,7 +236,7 @@ write_nginx_vhost () { set_apache_conf () { tee $ef_temp_conf >/dev/null << END -## ELFINDER FILE MANAGER ## +## ELFINDER FILE MANAGER CONFIG STARTS ## @@ -247,6 +247,8 @@ set_apache_conf () { +## ELFINDER FILE MANAGER CONFIG ENDS ## + END } @@ -255,24 +257,30 @@ END set_apache_vhost () { tee $ef_temp_conf >/dev/null << END -## ELFINDER FILE MANAGER ## +## ELFINDER FILE MANAGER CONFIG STARTS ## Require all granted +## ELFINDER FILE MANAGER CONFIG ENDS ## + END } +# Alternative apache2 etc folder, since it could be httpd in rhel, centos and their derivatives +ef_apache2_dir=/etc/apache2 +if [ ! -d "$ef_apache2_dir" ]; then ef_apache2_dir=/etc/httpd; fi + # Function to download and extract latest elFinder set_elfinder_conf () { # Create basic filemanager config.file - ef_avail_dir=/etc/apache2/conf-available - ef_enabl_dir=/etc/apache2/conf-enabled + ef_avail_dir=$ef_apache2_dir/conf-available + ef_enabl_dir=$ef_apache2_dir/conf-enabled ef_fm_conf=$ef_word.conf tee $ef_avail_dir/$ef_fm_conf >/dev/null << END -# elFinder default Apache configuration +## ELFINDER FILE MANAGER CONFIG STARTS ## Alias /filemanager /usr/share/filemanager @@ -338,6 +346,8 @@ Alias /filemanager /usr/share/filemanager SSLStaplingCache shmcb:/var/run/ocsp(128000) + +## ELFINDER FILE MANAGER CONFIG ENDS ## END if [ ! -f $ef_enabl_dir/$ef_fm_conf ]; then a2enconf $ef_word; fi @@ -347,9 +357,10 @@ END write_apache_vhost () { # Define custom and ispconfig vhost files master_vhost=apache_ispconfig.conf.master - target_vhost=/etc/apache2/sites-available/ispconfig.conf + target_vhost=$ef_apache2_dir/sites-available/ispconfig.conf target_base=$(basename $target_vhost) - ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) + apps_vhost=$ef_apache2_dir/sites-available/apps.vhost + ef_port=$(grep -i "\*:" $apps_vhost | cut -d : -f 2,3 | cut -d " " -f1) sm_search="\/squirrelmail" # Run custom conf function @@ -366,8 +377,6 @@ write_apache_vhost () { set_elfinder_conf # Reload apache2 if all good and report result - ispcvhost=/etc/apache2/sites-available/ispconfig.vhost - ef_port=$(grep -i "\*:" $ispcvhost | cut -d : -f 2,3 | cut -d " " -f1) if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then systemctl reload apache2 echo -e "Apache2 "$ef_reload"\n\n"$ef_browse""$ef_port"/$ef_word\n" @@ -383,7 +392,7 @@ if apt-get -v >/dev/null 2>&1; then # If web server is nginx, check and modify apps vhost accordingly if [ $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 1 ]; then write_nginx_vhost - # If web server is apache2, check and modify ispconfig vhost accordingly + # If web server is apache2, also check and modify apps vhost accordingly elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then write_apache_vhost fi @@ -392,7 +401,7 @@ elif which yum &> /dev/null 2>&1; then # If web server is nginx, check and modify apps vhost accordingly if ( rpm -q nginx ); then write_nginx_vhost - # If web server is apache2, check and modify ispconfig vhost accordingly + # If web server is apache2, also check and modify apps vhost accordingly elif ( rpm -q httpd ); then write_apache_vhost fi