From a77b0c0bfe921aae4700276970f0888ca90c3563 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Thu, 14 Sep 2023 06:28:36 +0000 Subject: [PATCH 001/110] Add new script file to install or update elFinder File Manager in ISPConfig web server --- elfinder_install_update.sh | 173 +++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 elfinder_install_update.sh diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh new file mode 100644 index 0000000..0f06fe4 --- /dev/null +++ b/elfinder_install_update.sh @@ -0,0 +1,173 @@ +#!/bin/bash +# Name: elfinder_install_update.sh +# Description: Install or update elFinder File Manager in ISPConfig web server. +# Author: Hj Ahmad Rasyid bin Hj Ismail +# Updated on 20230914-142723 +# Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install + + +## INSTALL OR UPDATE ELFINDER FILE MANAGER ## +# Define elfinder directory +elfinderdir=/usr/share/elfinder +# Create it if does not exist +if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi +# If it exists, go to it +cd $elfinderdir +# Define current version and latest version +currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) +lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) +# Check if main files are missing; if elfinder version is different # Then proceed installing +if [[ -f "package.json" ] && [ "$currentversion" == "$latestversion" ]]; then + # Existing elfinder is up-to-date + echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" +if [ ! -f "elfinder.html" ] || [[ -f "package.json" ] && [ $currentversion != $lattestversion]]; then + # Download lattest elfinder package + wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz + # Extract, overwriting current files and folders, if any, thus updating as well. + tar -xvf $lattestversion.tar.gz --strip-components=1 + # Make elfinder open full in browser + sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html + # Symlink, which is preferred rather than rename + ln -sf elfinder.html index.html + echo "elFinder filemanager has been installed / updated to the latest version ("$lattestversion")." +fi + +## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## +# Define filemanager directory and its backup +filemanagerdir=/usr/share/filemanager +filemanagerbakdir=/usr/share/filemanagerbak +# Backup then force symlink if directory exist, but not empty and not a link +if [[ -d $filemanagerdir ] && [ ! -z $filemanagerdir ] && [ ! -L $filemanagerdir ]]; then + mkdir -p $filemanagerbakdir + cp $filemanagerdir $filemanagerbakdir + ln -sf $elfinderdir $filemanagerdir +# Force symlink only if directory didn't exist or it exists but empty or it is just a link +elif [ ! -d $filemanagerdir] || [[ -d $filemanagerdir] && [[ -z $filemanagerdir ] || [ -L $filemanagerdir ]]] ; then + ln -sf $elfinderdir $filemanagerdir +fi + +# Define conf directories +confdefaultdir=/usr/local/ispconfig/server/conf +confcustomdir=/usr/local/ispconfig/server/conf-custom +success="elFinder filemanager config has been successfully added to your vhost" +# 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 ] || [ rpm -q nginx ]]; then + # Define vhost file + vhostfile=nginx_apps.vhost.master + # Create conf-custom directory if it doesn't exist + if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi + # Copy apps vhost from conf to conf-custom if it doesn't exist + if [ ! -f $confcustomdir/$vhostfile ]; then + cp $confdefaultdir/$vhostfile $confcustomdir/ + # Force symlink to install directory (default disabled). + # ln -sf $confcustomdir $confcustomdir/install + fi + if [ -f $confcustomdir/$vhostfile ]]; then + # Go to the conf-custom directory + cd $confcustomdir + # Search for filemanager in the apps vhost file + if grep -q "filemanager" $vhostfile; then + echo "Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." + exit + else + # + cat << EOT > elfinder_cat.txt + + + ## ELFINDER FILE MANAGER ## + + location /filemanager { + root /usr/share/; + index index.php index.html index.htm; + location ~ ^/filemanager/(.+\.php)$ { + try_files $uri =404; + root /usr/share/; + include /etc/nginx/fastcgi_params; + + # To access filemanager, create ftp users in ISPConfig UI + {use_tcp}fastcgi_pass 127.0.0.1:9000; + {use_socket}fastcgi_pass unix:{fpm_socket}; + fastcgi_index index.php; + include /etc/nginx/fastcgi_buffer_temp; + fastcgi_read_timeout 1200; + } + location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { + root /usr/share/; + access_log off; + log_not_found off; + expires max; + } + } + location /file { + rewrite ^/* /filemanager last; + } + + +EOT + # Modify the apps vhost file + sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $vhostfile + # Remove the created txt file + rm elfinder_cat.txt + echo "$success" + # Reload nginx if all good + if [[ $(nginx -t 2>&1) = *"successful"* ]]; then + systemctl reload nginx + else + echo "Nginx test failed. Please check and fix manually." + fi + fi + fi +# If web server is apache2, check and modify apps vhost accordingly +elif [[ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ] || [ rpm -q httpd ]]; then + # Define vhost file + vhostfile=apache_ispconfig.conf.master + # Create conf-custom directory if it doesn't exist + if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi + # Copy apps vhost from conf to conf-custom if it doesn't exist + if [ ! -f $confcustomdir/$vhostfile ]; then + cp $confdefaultdir/$vhostfile $confcustomdir/ + # Force symlink to install directory (default disabled). + # ln -sf $confcustomdir $confcustomdir/install + fi + if [ -f $confcustomdir/$vhostfile ]]; then + # Go to the conf-custom directory + cd $confcustomdir + # Search for filemanager in the apps vhost file + if grep -q "filemanager" $vhostfile; then + echo "Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." + exit + else + # + cat << EOT > elfinder_cat.txt + + +## ELFINDER FILE MANAGER ## + + + + Require all granted + + Order allow,deny + Allow from all + + + + +EOT + # Modify the apps vhost file + sed -i '/squirrelmail/e cat elfinder_cat.txt' $vhostfile + # Remove the created txt file + rm elfinder_cat.txt + echo "$success" + # Reload apache2 if all good + if [[ $(apachectl configtest -t 2>&1) = *"Syntax OK"* ]]; then + systemctl reload apache2 + else + echo "Apache2 test failed. Please check and fix manually." + fi + fi + fi +else + echo "You are not on a supported ISPConfig web server!" +fi +echo "Script ended $(date +"%Y%m%d-%H%M%S")" -- GitLab From a52d1b8fc56323a4a2ea6abdec82878a90af3fa7 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Thu, 14 Sep 2023 06:32:30 +0000 Subject: [PATCH 002/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0f06fe4..de7971b 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -10,9 +10,12 @@ # Define elfinder directory elfinderdir=/usr/share/elfinder # Create it if does not exist -if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi -# If it exists, go to it -cd $elfinderdir +if [ ! -d "$elfinderdir" ]; then + mkdir -p $elfinderdir +else + # If it exists, go to it + cd $elfinderdir +fi # Define current version and latest version currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) -- GitLab From 4b47afd83e5eba16087e8a05218c1988bd078598 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Thu, 14 Sep 2023 06:34:37 +0000 Subject: [PATCH 003/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index de7971b..b94df99 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -21,18 +21,18 @@ currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' - lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) # Check if main files are missing; if elfinder version is different # Then proceed installing if [[ -f "package.json" ] && [ "$currentversion" == "$latestversion" ]]; then - # Existing elfinder is up-to-date - echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" + # Existing elfinder is up-to-date + echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" if [ ! -f "elfinder.html" ] || [[ -f "package.json" ] && [ $currentversion != $lattestversion]]; then - # Download lattest elfinder package - wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz - # Extract, overwriting current files and folders, if any, thus updating as well. - tar -xvf $lattestversion.tar.gz --strip-components=1 - # Make elfinder open full in browser - sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html + # Download lattest elfinder package + wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz + # Extract, overwriting current files and folders, if any, thus updating as well. + tar -xvf $lattestversion.tar.gz --strip-components=1 + # Make elfinder open full in browser + sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html # Symlink, which is preferred rather than rename - ln -sf elfinder.html index.html - echo "elFinder filemanager has been installed / updated to the latest version ("$lattestversion")." + ln -sf elfinder.html index.html + echo "elFinder filemanager has been installed / updated to the latest version ("$lattestversion")." fi ## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## -- GitLab From 6d85ca47bf385d57fca921688e26ff59112e3534 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Thu, 14 Sep 2023 06:46:54 +0000 Subject: [PATCH 004/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index b94df99..5cc10de 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -38,11 +38,10 @@ fi ## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## # Define filemanager directory and its backup filemanagerdir=/usr/share/filemanager -filemanagerbakdir=/usr/share/filemanagerbak +filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") # Backup then force symlink if directory exist, but not empty and not a link if [[ -d $filemanagerdir ] && [ ! -z $filemanagerdir ] && [ ! -L $filemanagerdir ]]; then - mkdir -p $filemanagerbakdir - cp $filemanagerdir $filemanagerbakdir + cp $filemanagerdir $filemanagerbakdir -r ln -sf $elfinderdir $filemanagerdir # Force symlink only if directory didn't exist or it exists but empty or it is just a link elif [ ! -d $filemanagerdir] || [[ -d $filemanagerdir] && [[ -z $filemanagerdir ] || [ -L $filemanagerdir ]]] ; then -- GitLab From 8f257216b048c3aff7ffaf5654500b41ba9da0a4 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 06:31:00 +0000 Subject: [PATCH 005/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 5cc10de..55879ef 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -10,20 +10,21 @@ # Define elfinder directory elfinderdir=/usr/share/elfinder # Create it if does not exist -if [ ! -d "$elfinderdir" ]; then - mkdir -p $elfinderdir -else - # If it exists, go to it - cd $elfinderdir -fi +if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi + +# If it exists, go to it +cd $elfinderdir + # Define current version and latest version currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) + # Check if main files are missing; if elfinder version is different # Then proceed installing if [[ -f "package.json" ] && [ "$currentversion" == "$latestversion" ]]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" -if [ ! -f "elfinder.html" ] || [[ -f "package.json" ] && [ $currentversion != $lattestversion]]; then + exit +elif [ ! -f "elfinder.html" ] || [[ -f "package.json" ] && [ $currentversion != $lattestversion]]; then # Download lattest elfinder package wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. -- GitLab From 537117e99dd54f97283ebe8b00bbed151cbba73d Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 06:45:10 +0000 Subject: [PATCH 006/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 55879ef..19e627e 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -16,7 +16,8 @@ if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi cd $elfinderdir # Define current version and latest version -currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) +if [ -f "package.json" ]; then currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2); fi +# currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) # Check if main files are missing; if elfinder version is different # Then proceed installing -- GitLab From b1a512c54b96fcfb46dff7ee507a9c4636901ea0 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 07:08:53 +0000 Subject: [PATCH 007/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 19e627e..d99d7e5 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -9,23 +9,26 @@ ## INSTALL OR UPDATE ELFINDER FILE MANAGER ## # Define elfinder directory elfinderdir=/usr/share/elfinder -# Create it if does not exist -if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi - -# If it exists, go to it -cd $elfinderdir +# Create it if does not exist, then go to it +if [ ! -d "$elfinderdir" ]; then + mkdir -p $elfinderdir + cd $elfinderdir +else + cd $elfinderdir +fi # Define current version and latest version -if [ -f "package.json" ]; then currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2); fi -# currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) -lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) +currentversion="grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2)" +lattestversion="curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2" -# Check if main files are missing; if elfinder version is different # Then proceed installing -if [[ -f "package.json" ] && [ "$currentversion" == "$latestversion" ]]; then +# Check if elfinder version is the same +if [[ -f "package.json" && "$currentversion" == "$latestversion" ]]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" exit -elif [ ! -f "elfinder.html" ] || [[ -f "package.json" ] && [ $currentversion != $lattestversion]]; then + +# Check if main files are missing; if elfinder version is different # Then proceed installing +elif [[ ! -f "package.json"] || [ -f "package.json" && $currentversion != $lattestversion]]; then # Download lattest elfinder package wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. -- GitLab From 283491d97ab9277656a13f22d3d3ca91c7c4f951 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 07:10:24 +0000 Subject: [PATCH 008/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index d99d7e5..d9bb6c9 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -22,7 +22,7 @@ currentversion="grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f lattestversion="curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2" # Check if elfinder version is the same -if [[ -f "package.json" && "$currentversion" == "$latestversion" ]]; then +if [[ -f "package.json" ] && [ "$currentversion" == "$latestversion" ]]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" exit -- GitLab From 3efdcc188d210cb502f5d8e48d19d228f3d92c87 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 10:01:44 +0000 Subject: [PATCH 009/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index d9bb6c9..d1308d9 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -22,13 +22,13 @@ currentversion="grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f lattestversion="curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2" # Check if elfinder version is the same -if [[ -f "package.json" ] && [ "$currentversion" == "$latestversion" ]]; then +if [[ -f "package.json" && "$currentversion" == "$latestversion" ]]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" exit # Check if main files are missing; if elfinder version is different # Then proceed installing -elif [[ ! -f "package.json"] || [ -f "package.json" && $currentversion != $lattestversion]]; then +elif [[ ! -f "package.json" ]] || [[ -f "package.json" && $currentversion != $lattestversion ]]; then # Download lattest elfinder package wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. @@ -45,11 +45,11 @@ fi filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") # Backup then force symlink if directory exist, but not empty and not a link -if [[ -d $filemanagerdir ] && [ ! -z $filemanagerdir ] && [ ! -L $filemanagerdir ]]; then +if [[ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]]; then cp $filemanagerdir $filemanagerbakdir -r ln -sf $elfinderdir $filemanagerdir # Force symlink only if directory didn't exist or it exists but empty or it is just a link -elif [ ! -d $filemanagerdir] || [[ -d $filemanagerdir] && [[ -z $filemanagerdir ] || [ -L $filemanagerdir ]]] ; then +elif [[ ! -d $filemanagerdir ]] || [[ -d $filemanagerdir && -z $filemanagerdir || -d $filemanagerdir && -L $filemanagerdir ]]; then ln -sf $elfinderdir $filemanagerdir fi @@ -58,7 +58,7 @@ confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom success="elFinder filemanager config has been successfully added to your vhost" # 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 ] || [ rpm -q nginx ]]; then +if [[ $(rpm -q nginx) || $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then # Define vhost file vhostfile=nginx_apps.vhost.master # Create conf-custom directory if it doesn't exist @@ -69,7 +69,7 @@ if [[ $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") # Force symlink to install directory (default disabled). # ln -sf $confcustomdir $confcustomdir/install fi - if [ -f $confcustomdir/$vhostfile ]]; then + if [ -f $confcustomdir/$vhostfile ]; then # Go to the conf-custom directory cd $confcustomdir # Search for filemanager in the apps vhost file @@ -125,7 +125,7 @@ EOT fi fi # If web server is apache2, check and modify apps vhost accordingly -elif [[ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ] || [ rpm -q httpd ]]; then +elif [[ $(rpm -q httpd) || $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then # Define vhost file vhostfile=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist -- GitLab From 75dd976b116348b5a3f660681c51f9c448efa031 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:22:28 +0000 Subject: [PATCH 010/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 136 ++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 47 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index d1308d9..68477d7 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -5,60 +5,69 @@ # Updated on 20230914-142723 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install - -## INSTALL OR UPDATE ELFINDER FILE MANAGER ## -# Define elfinder directory +# Define elfinder and its extract dir elfinderdir=/usr/share/elfinder -# Create it if does not exist, then go to it -if [ ! -d "$elfinderdir" ]; then - mkdir -p $elfinderdir - cd $elfinderdir -else - cd $elfinderdir -fi - -# Define current version and latest version -currentversion="grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2)" -lattestversion="curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2" - -# Check if elfinder version is the same -if [[ -f "package.json" && "$currentversion" == "$latestversion" ]]; then - # Existing elfinder is up-to-date - echo "Existing install is up-to-date as current elFinder version is "$currentversion" and lattest version is "$lattestversion"" - exit - -# Check if main files are missing; if elfinder version is different # Then proceed installing -elif [[ ! -f "package.json" ]] || [[ -f "package.json" && $currentversion != $lattestversion ]]; then +extractdir=/tmp/elfinder +get_elfinder () { + # Go to the defined extract dir + cd $extractdir # Download lattest elfinder package wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. tar -xvf $lattestversion.tar.gz --strip-components=1 # Make elfinder open full in browser sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html - # Symlink, which is preferred rather than rename + # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html - echo "elFinder filemanager has been installed / updated to the latest version ("$lattestversion")." +} + +if [ -d "$elfinderdir" ]; then + cd $elfinderdir + if [ -f "package.json" && ]; then + currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) + lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) + if [ "$currentversion" == "$latestversion" ]; then + # Existing elfinder is up-to-date + echo "Existing install is up-to-date with the latest version of "$lattestversion"" + else + get_elfinder + cp -R $extractdir/* $elfinderdir + echo "elFinder filemanager has been updated to the latest version ("$lattestversion")." + fi + else + get_elfinder + cp -R $extractdir/* $elfinderdir + echo "elFinder filemanager has been installed with version ("$lattestversion")." + fi +else + cp -R $extractdir/* $elfinderdir + echo "elFinder filemanager has been installed with version ("$lattestversion")." fi -## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## + +## FILE MANAGER CREATE OR OVERWRITE, THUS TO BACKUP IF EXIST AND IS NEITHER EMPTY NOR LINKED ## # Define filemanager directory and its backup filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") -# Backup then force symlink if directory exist, but not empty and not a link +# Backup then force symlink if directory exist but not empty and also not a link if [[ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]]; then cp $filemanagerdir $filemanagerbakdir -r ln -sf $elfinderdir $filemanagerdir # Force symlink only if directory didn't exist or it exists but empty or it is just a link -elif [[ ! -d $filemanagerdir ]] || [[ -d $filemanagerdir && -z $filemanagerdir || -d $filemanagerdir && -L $filemanagerdir ]]; then +elif [[ ! -d $filemanagerdir ]] || [[ -d $filemanagerdir && -z $filemanagerdir ]] || [[ -d $filemanagerdir && -L $filemanagerdir ]]; then ln -sf $elfinderdir $filemanagerdir fi -# Define conf directories + +## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## +# Define conf directories and other messages confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom -success="elFinder filemanager config has been successfully added to your vhost" -# If web server is nginx, check and modify apps vhost accordingly -if [[ $(rpm -q nginx) || $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then +confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install +exist="Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." +success="elFinder filemanager config has been successfully added to your vhost." +failed="Apache2 test failed. Please check and fix manually." +write nginx () { # Define vhost file vhostfile=nginx_apps.vhost.master # Create conf-custom directory if it doesn't exist @@ -66,15 +75,21 @@ if [[ $(rpm -q nginx) || $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep # Copy apps vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$vhostfile ]; then cp $confdefaultdir/$vhostfile $confcustomdir/ - # Force symlink to install directory (default disabled). - # ln -sf $confcustomdir $confcustomdir/install + # Check conf-custom/install directory + if [ ! -d $confcustominstalldir ]; then + # Force symlink to install directory, if it doesn't exist + ln -sf $confcustomdir $confcustominstalldir + else + # Force symlink apps from custom-conf to install directory + ln -sf $confcustomdir/$vhostfile $confcustominstalldir/ + fi fi if [ -f $confcustomdir/$vhostfile ]; then # Go to the conf-custom directory cd $confcustomdir # Search for filemanager in the apps vhost file if grep -q "filemanager" $vhostfile; then - echo "Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." + echo "$exist" exit else # @@ -115,17 +130,19 @@ EOT sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $vhostfile # Remove the created txt file rm elfinder_cat.txt - echo "$success" # Reload nginx if all good if [[ $(nginx -t 2>&1) = *"successful"* ]]; then systemctl reload nginx + echo "$success" else - echo "Nginx test failed. Please check and fix manually." + echo "$failed" fi fi fi -# If web server is apache2, check and modify apps vhost accordingly -elif [[ $(rpm -q httpd) || $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + +} + +write_apache () { # Define vhost file vhostfile=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist @@ -133,16 +150,21 @@ elif [[ $(rpm -q httpd) || $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | # Copy apps vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$vhostfile ]; then cp $confdefaultdir/$vhostfile $confcustomdir/ - # Force symlink to install directory (default disabled). - # ln -sf $confcustomdir $confcustomdir/install + # Check conf-custom/install directory + if [ ! -d $confcustominstalldir ]; then + # Force symlink to install directory, if it doesn't exist + ln -sf $confcustomdir $confcustominstalldir + else + # Force symlink apps from custom-conf to install directory + ln -sf $confcustomdir/$vhostfile $confcustominstalldir/ + fi fi if [ -f $confcustomdir/$vhostfile ]]; then # Go to the conf-custom directory cd $confcustomdir # Search for filemanager in the apps vhost file if grep -q "filemanager" $vhostfile; then - echo "Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." - exit + echo "$exist" else # cat << EOT > elfinder_cat.txt @@ -165,16 +187,36 @@ EOT sed -i '/squirrelmail/e cat elfinder_cat.txt' $vhostfile # Remove the created txt file rm elfinder_cat.txt - echo "$success" # Reload apache2 if all good if [[ $(apachectl configtest -t 2>&1) = *"Syntax OK"* ]]; then systemctl reload apache2 + echo "$success" else - echo "Apache2 test failed. Please check and fix manually." + echo "$failed" fi fi fi -else - echo "You are not on a supported ISPConfig web server!" +} +nosupport="You are not on a supported ISPConfig web server!" +if [[ 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 apps vhost accordingly + elif [[ rpm -q httpd ]]; then + write_apache_vhost + else + echo $nosupport + fi +elif [[ 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 apps vhost accordingly + elif [[ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + write_apache_vhost + else + echo $nosupport + fi fi echo "Script ended $(date +"%Y%m%d-%H%M%S")" -- GitLab From cfc18d4d8e7163d999af35752f3379a4592b8e28 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:28:11 +0000 Subject: [PATCH 011/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 68477d7..2b1e06a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -9,6 +9,8 @@ elfinderdir=/usr/share/elfinder extractdir=/tmp/elfinder get_elfinder () { + # Create extract dir if doesn't exist + if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi # Go to the defined extract dir cd $extractdir # Download lattest elfinder package -- GitLab From 92d8e72a2be846d303bcddb1a6eb9935e1baf240 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:30:07 +0000 Subject: [PATCH 012/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 2b1e06a..6c7e5da 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -8,6 +8,7 @@ # Define elfinder and its extract dir elfinderdir=/usr/share/elfinder extractdir=/tmp/elfinder +lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) get_elfinder () { # Create extract dir if doesn't exist if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi -- GitLab From 2bdae3e7328f82e413c44aeb7880fd714bb2fd1f Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:35:50 +0000 Subject: [PATCH 013/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 6c7e5da..92d69de 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -70,7 +70,7 @@ confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install exist="Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." success="elFinder filemanager config has been successfully added to your vhost." failed="Apache2 test failed. Please check and fix manually." -write nginx () { +write_nginx_vhost () { # Define vhost file vhostfile=nginx_apps.vhost.master # Create conf-custom directory if it doesn't exist @@ -145,7 +145,7 @@ EOT } -write_apache () { +write_apache_vhost () { # Define vhost file vhostfile=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist -- GitLab From c017028225f6d4098c683923a16d982b73fd1eae Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:38:04 +0000 Subject: [PATCH 014/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 92d69de..ae89712 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -201,22 +201,22 @@ EOT fi } nosupport="You are not on a supported ISPConfig web server!" -if [[ which yum &> /dev/null 2>&1 ]]; then +if [ which yum &> /dev/null 2>&1 ]; then # If web server is nginx, check and modify apps vhost accordingly - if [[ rpm -q nginx ]]; then + if [ rpm -q nginx ]; then write_nginx_vhost # If web server is apache2, check and modify apps vhost accordingly - elif [[ rpm -q httpd ]]; then + elif [ rpm -q httpd ]; then write_apache_vhost else echo $nosupport fi -elif [[ apt-get -v >/dev/null 2>&1 ]]; then +elif [ 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 + 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 apps vhost accordingly - elif [[ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then + elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then write_apache_vhost else echo $nosupport -- GitLab From ae6761150ce2c5eedc3216040e389902b791bbd9 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:40:54 +0000 Subject: [PATCH 015/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index ae89712..62e0f6e 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -53,11 +53,11 @@ fi filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") # Backup then force symlink if directory exist but not empty and also not a link -if [[ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]]; then +if [ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]; then cp $filemanagerdir $filemanagerbakdir -r ln -sf $elfinderdir $filemanagerdir # Force symlink only if directory didn't exist or it exists but empty or it is just a link -elif [[ ! -d $filemanagerdir ]] || [[ -d $filemanagerdir && -z $filemanagerdir ]] || [[ -d $filemanagerdir && -L $filemanagerdir ]]; then +elif [ ! -d $filemanagerdir || -d $filemanagerdir && -z $filemanagerdir || -d $filemanagerdir && -L $filemanagerdir ]]; then ln -sf $elfinderdir $filemanagerdir fi -- GitLab From 82ecffbe27b35489096c3f89c57ec9a77e8db953 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:50:58 +0000 Subject: [PATCH 016/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 62e0f6e..fe4214b 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -8,6 +8,8 @@ # Define elfinder and its extract dir elfinderdir=/usr/share/elfinder extractdir=/tmp/elfinder + if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi + cd $extractdir lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) get_elfinder () { # Create extract dir if doesn't exist @@ -22,29 +24,42 @@ get_elfinder () { sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html + hasbeen="elFinder filemanager has been" } if [ -d "$elfinderdir" ]; then cd $elfinderdir if [ -f "package.json" && ]; then currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) - lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) if [ "$currentversion" == "$latestversion" ]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date with the latest version of "$lattestversion"" else get_elfinder - cp -R $extractdir/* $elfinderdir - echo "elFinder filemanager has been updated to the latest version ("$lattestversion")." + if [ -d "$extractdir" ]; then + cp -R $extractdir/* $elfinderdir + echo "$hasbeen updated to the latest version ("$lattestversion")." + else + echo "Failed. $extractdir is missing." + fi fi else get_elfinder - cp -R $extractdir/* $elfinderdir - echo "elFinder filemanager has been installed with version ("$lattestversion")." + if [ -d "$extractdir" ]; then + cp -R $extractdir/* $elfinderdir + echo "$hasbeen installed with version ("$lattestversion")." + else + echo "Failed. $extractdir is missing." + fi fi else + get_elfinder + if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "elFinder filemanager has been installed with version ("$lattestversion")." + echo "$hasbeen installed with version ("$lattestversion")." + else + echo "Failed. $extractdir is missing." + fi fi @@ -53,11 +68,11 @@ fi filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") # Backup then force symlink if directory exist but not empty and also not a link -if [ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]; then +if [[ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]]; then cp $filemanagerdir $filemanagerbakdir -r ln -sf $elfinderdir $filemanagerdir # Force symlink only if directory didn't exist or it exists but empty or it is just a link -elif [ ! -d $filemanagerdir || -d $filemanagerdir && -z $filemanagerdir || -d $filemanagerdir && -L $filemanagerdir ]]; then +elif [[ ! -d $filemanagerdir ]] || [[ -d $filemanagerdir && -z $filemanagerdir ]] || [[ -d $filemanagerdir && -L $filemanagerdir ]]; then ln -sf $elfinderdir $filemanagerdir fi -- GitLab From c6f9433b1bbd6bdc5b0547c6d61166c314a1e834 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:51:57 +0000 Subject: [PATCH 017/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index fe4214b..81329a7 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -8,9 +8,6 @@ # Define elfinder and its extract dir elfinderdir=/usr/share/elfinder extractdir=/tmp/elfinder - if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi - cd $extractdir -lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) get_elfinder () { # Create extract dir if doesn't exist if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi @@ -27,6 +24,8 @@ get_elfinder () { hasbeen="elFinder filemanager has been" } +# Define latest version +lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) if [ -d "$elfinderdir" ]; then cd $elfinderdir if [ -f "package.json" && ]; then -- GitLab From 08c75b55554a117429782df53723da65dbf0e9d1 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:57:33 +0000 Subject: [PATCH 018/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 81329a7..ebfa066 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -10,7 +10,8 @@ elfinderdir=/usr/share/elfinder extractdir=/tmp/elfinder get_elfinder () { # Create extract dir if doesn't exist - if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi + if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fiexist + if [ ! -d "$elfinderdir" ]; then mkdir -p $extractdir; fi # Go to the defined extract dir cd $extractdir # Download lattest elfinder package @@ -21,6 +22,7 @@ get_elfinder () { sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html + rm *.tar.gz hasbeen="elFinder filemanager has been" } -- GitLab From f3961b88ee318a21b748ab52752cc66a8972b63d Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 12:58:52 +0000 Subject: [PATCH 019/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index ebfa066..20d9fc0 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -17,7 +17,7 @@ get_elfinder () { # Download lattest elfinder package wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. - tar -xvf $lattestversion.tar.gz --strip-components=1 + tar -xzf $lattestversion.tar.gz --strip-components=1 # Make elfinder open full in browser sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html # Symlink, which is preferred rather than rename -- GitLab From a324a61c0c0ba4e10a73419f002f3f3c9122ffc9 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:00:13 +0000 Subject: [PATCH 020/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 20d9fc0..f63e724 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -10,7 +10,7 @@ elfinderdir=/usr/share/elfinder extractdir=/tmp/elfinder get_elfinder () { # Create extract dir if doesn't exist - if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fiexist + if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi if [ ! -d "$elfinderdir" ]; then mkdir -p $extractdir; fi # Go to the defined extract dir cd $extractdir -- GitLab From bbd80ed7aae49b0c71a22bb8d3cd3c3b06d6d4e4 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:01:16 +0000 Subject: [PATCH 021/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index f63e724..b0fd266 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -11,7 +11,7 @@ extractdir=/tmp/elfinder get_elfinder () { # Create extract dir if doesn't exist if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi - if [ ! -d "$elfinderdir" ]; then mkdir -p $extractdir; fi + if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi # Go to the defined extract dir cd $extractdir # Download lattest elfinder package -- GitLab From 6af93d7477331d603a03f601985a90d4f78128e2 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:19:26 +0000 Subject: [PATCH 022/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index b0fd266..39909a3 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -68,12 +68,11 @@ fi # Define filemanager directory and its backup filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") -# Backup then force symlink if directory exist but not empty and also not a link -if [[ -d $filemanagerdir && ! -z $filemanagerdir && ! -L $filemanagerdir ]]; then - cp $filemanagerdir $filemanagerbakdir -r +if [ -d $filemanagerdir ]; then + # Backup then force symlink if directory exist but not empty and also not a link + if [[ ! -z $filemanagerdir || ! -L $filemanagerdir ]]; then cp $filemanagerdir $filemanagerbakdir; fi ln -sf $elfinderdir $filemanagerdir -# Force symlink only if directory didn't exist or it exists but empty or it is just a link -elif [[ ! -d $filemanagerdir ]] || [[ -d $filemanagerdir && -z $filemanagerdir ]] || [[ -d $filemanagerdir && -L $filemanagerdir ]]; then +else ln -sf $elfinderdir $filemanagerdir fi @@ -217,7 +216,7 @@ EOT fi } nosupport="You are not on a supported ISPConfig web server!" -if [ which yum &> /dev/null 2>&1 ]; then +if [[ 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 @@ -227,7 +226,7 @@ if [ which yum &> /dev/null 2>&1 ]; then else echo $nosupport fi -elif [ apt-get -v >/dev/null 2>&1 ]; then +elif [[ 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 -- GitLab From 30dcf687e01d93217d7d64f7e64c967f1276048e Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:22:31 +0000 Subject: [PATCH 023/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 39909a3..c3872af 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -216,7 +216,7 @@ EOT fi } nosupport="You are not on a supported ISPConfig web server!" -if [[ which yum &> /dev/null 2>&1 ]]; then +if 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 -- GitLab From b3f79ab2578a07d993e11d58952b84f6e9ddb106 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:24:35 +0000 Subject: [PATCH 024/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index c3872af..59c8b6f 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -216,12 +216,12 @@ EOT fi } nosupport="You are not on a supported ISPConfig web server!" -if which yum &> /dev/null 2>&1; then +if which yum &> /dev/null 2>&1 ; then # If web server is nginx, check and modify apps vhost accordingly - if [ rpm -q nginx ]; then + if ( rpm -q nginx ); then write_nginx_vhost # If web server is apache2, check and modify apps vhost accordingly - elif [ rpm -q httpd ]; then + elif ( rpm -q httpd ); then write_apache_vhost else echo $nosupport -- GitLab From 23b0df81e3eb524af494dab45438aa4f97ffb6f2 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:38:21 +0000 Subject: [PATCH 025/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 59c8b6f..54d661c 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -216,7 +216,7 @@ EOT fi } nosupport="You are not on a supported ISPConfig web server!" -if which yum &> /dev/null 2>&1 ; then +if 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 @@ -226,7 +226,7 @@ if which yum &> /dev/null 2>&1 ; then else echo $nosupport fi -elif [[ apt-get -v >/dev/null 2>&1 ]]; then +elif 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 @@ -237,4 +237,4 @@ elif [[ apt-get -v >/dev/null 2>&1 ]]; then echo $nosupport fi fi -echo "Script ended $(date +"%Y%m%d-%H%M%S")" +echo "elFinder script ended $(date +"%Y%m%d-%H%M%S")" -- GitLab From 5a50c921645d54dbd3e02b26457aa15668dcecc0 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:40:23 +0000 Subject: [PATCH 026/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 54d661c..b3d5588 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -216,22 +216,22 @@ EOT fi } nosupport="You are not on a supported ISPConfig web server!" -if which yum &> /dev/null 2>&1; then +if apt-get -v >/dev/null 2>&1; then # If web server is nginx, check and modify apps vhost accordingly - if ( rpm -q nginx ); then + 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 apps vhost accordingly - elif ( rpm -q httpd ); then + elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then write_apache_vhost else echo $nosupport fi -elif apt-get -v >/dev/null 2>&1; then +elif which yum &> /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 + if ( rpm -q nginx ); then write_nginx_vhost # If web server is apache2, check and modify apps vhost accordingly - elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then + elif ( rpm -q httpd ); then write_apache_vhost else echo $nosupport -- GitLab From 37a760a98109f05a24935082dedebd9c57898299 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:45:45 +0000 Subject: [PATCH 027/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index b3d5588..133ec58 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -218,10 +218,10 @@ EOT nosupport="You are not on a supported ISPConfig web server!" 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 + if [ $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 0 ]; then write_nginx_vhost # If web server is apache2, check and modify apps vhost accordingly - elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then + elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then write_apache_vhost else echo $nosupport -- GitLab From 5496f0defaca19635ad09f59ed641f78de6aa03d Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:47:59 +0000 Subject: [PATCH 028/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 133ec58..2f1e9e7 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -84,7 +84,7 @@ confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install exist="Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." success="elFinder filemanager config has been successfully added to your vhost." -failed="Apache2 test failed. Please check and fix manually." +failed="test failed. Please check and fix manually." write_nginx_vhost () { # Define vhost file vhostfile=nginx_apps.vhost.master @@ -153,7 +153,7 @@ EOT systemctl reload nginx echo "$success" else - echo "$failed" + echo "Nginx $failed" fi fi fi @@ -210,7 +210,7 @@ EOT systemctl reload apache2 echo "$success" else - echo "$failed" + echo "Apache $failed" fi fi fi -- GitLab From 2f5e3613c5e0833e6cace37f6452149cafd218d9 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 13:49:09 +0000 Subject: [PATCH 029/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 2f1e9e7..1e79519 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -149,7 +149,7 @@ EOT # Remove the created txt file rm elfinder_cat.txt # Reload nginx if all good - if [[ $(nginx -t 2>&1) = *"successful"* ]]; then + if $(nginx -t 2>&1) = *"successful"*; then systemctl reload nginx echo "$success" else @@ -206,7 +206,7 @@ EOT # Remove the created txt file rm elfinder_cat.txt # Reload apache2 if all good - if [[ $(apachectl configtest -t 2>&1) = *"Syntax OK"* ]]; then + if $(apachectl configtest -t 2>&1) = *"Syntax OK"*; then systemctl reload apache2 echo "$success" else -- GitLab From 565afca1ceb32aa852b7d991dded27b2a330b69a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 14:28:31 +0000 Subject: [PATCH 030/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 1e79519..21a6c4e 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -149,7 +149,7 @@ EOT # Remove the created txt file rm elfinder_cat.txt # Reload nginx if all good - if $(nginx -t 2>&1) = *"successful"*; then + if nginx -t 2>/dev/null; then systemctl reload nginx echo "$success" else @@ -206,7 +206,7 @@ EOT # Remove the created txt file rm elfinder_cat.txt # Reload apache2 if all good - if $(apachectl configtest -t 2>&1) = *"Syntax OK"*; then + if $(apachectl configtest 2>&1) = *"Syntax OK"*; then systemctl reload apache2 echo "$success" else -- GitLab From bb5a87fb321442171a58e96155bd12328e79be01 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:01:50 +0000 Subject: [PATCH 031/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 126 ++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 56 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 21a6c4e..e5cd2eb 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -86,66 +86,78 @@ exist="Word filemanager exists in the apps vhost, aborting to avoid overwriting success="elFinder filemanager config has been successfully added to your vhost." failed="test failed. Please check and fix manually." write_nginx_vhost () { - # Define vhost file - vhostfile=nginx_apps.vhost.master + # Define custom and apps vhost files + nginxvhostdir=/etc/nginx/sites-available + appsvhost=apps.vhost + confvhost=nginx_apps.vhost.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy apps vhost from conf to conf-custom if it doesn't exist - if [ ! -f $confcustomdir/$vhostfile ]; then - cp $confdefaultdir/$vhostfile $confcustomdir/ + if [ ! -f $confcustomdir/$confvhost ]; then + cp $confdefaultdir/$confvhost $confcustomdir/ # Check conf-custom/install directory if [ ! -d $confcustominstalldir ]; then # Force symlink to install directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else # Force symlink apps from custom-conf to install directory - ln -sf $confcustomdir/$vhostfile $confcustominstalldir/ + ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi - if [ -f $confcustomdir/$vhostfile ]; then - # Go to the conf-custom directory - cd $confcustomdir - # Search for filemanager in the apps vhost file - if grep -q "filemanager" $vhostfile; then - echo "$exist" - exit - else - # + # Add content to dummy file cat << EOT > elfinder_cat.txt - ## ELFINDER FILE MANAGER ## - - location /filemanager { - root /usr/share/; - index index.php index.html index.htm; - location ~ ^/filemanager/(.+\.php)$ { - try_files $uri =404; - root /usr/share/; - include /etc/nginx/fastcgi_params; - - # To access filemanager, create ftp users in ISPConfig UI - {use_tcp}fastcgi_pass 127.0.0.1:9000; - {use_socket}fastcgi_pass unix:{fpm_socket}; - fastcgi_index index.php; - include /etc/nginx/fastcgi_buffer_temp; - fastcgi_read_timeout 1200; - } - location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { - root /usr/share/; - access_log off; - log_not_found off; - expires max; - } - } - location /file { - rewrite ^/* /filemanager last; - } + ## ELFINDER FILE MANAGER ## + + location /filemanager { + root /usr/share/; + index index.php index.html index.htm; + location ~ ^/filemanager/(.+\.php)$ { + try_files $uri =404; + root /usr/share/; + include /etc/nginx/fastcgi_params; + + # To access filemanager, create ftp users in ISPConfig UI + {use_tcp}fastcgi_pass 127.0.0.1:9000; + {use_socket}fastcgi_pass unix:{fpm_socket}; + fastcgi_index index.php; + include /etc/nginx/fastcgi_buffer_temp; + fastcgi_read_timeout 1200; + } + location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { + root /usr/share/; + access_log off; + log_not_found off; + expires max; + } + } + location /file { + rewrite ^/* /filemanager last; + } EOT + + if [ -f $confcustomdir/$confvhost ]; then + # Go to the conf-custom directory + cd $confcustomdir + # Search for filemanager in the apps vhost file + if grep -q "filemanager" $confvhost; then + echo "$exist" + exit + else # Modify the apps vhost file - sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $vhostfile + sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost + if grep -q "filemanager" $confvhost; then + echo "$exist" + exit + else + sed -i 's/{use_tcp}/#/g' + phpfpm="\t\t\t\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\$phpfpm;" $appsvhost + sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost + fi # Remove the created txt file rm elfinder_cat.txt # Reload nginx if all good @@ -161,27 +173,29 @@ EOT } write_apache_vhost () { - # Define vhost file - vhostfile=apache_ispconfig.conf.master + # Define custom and apps vhost files + apachevhostdir=/etc/apache2/sites-available + appsvhost=apps.vhost + confvhost=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy apps vhost from conf to conf-custom if it doesn't exist - if [ ! -f $confcustomdir/$vhostfile ]; then - cp $confdefaultdir/$vhostfile $confcustomdir/ + if [ ! -f $confcustomdir/$confvhost ]; then + cp $confdefaultdir/$confvhost $confcustomdir/ # Check conf-custom/install directory if [ ! -d $confcustominstalldir ]; then # Force symlink to install directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else # Force symlink apps from custom-conf to install directory - ln -sf $confcustomdir/$vhostfile $confcustominstalldir/ + ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi - if [ -f $confcustomdir/$vhostfile ]]; then + if [ -f $confcustomdir/$confvhost ]]; then # Go to the conf-custom directory cd $confcustomdir # Search for filemanager in the apps vhost file - if grep -q "filemanager" $vhostfile; then + if grep -q "filemanager" $confvhost; then echo "$exist" else # @@ -191,18 +205,18 @@ write_apache_vhost () { ## ELFINDER FILE MANAGER ## - - Require all granted - - Order allow,deny - Allow from all - + + Require all granted + + Order allow,deny + Allow from all + EOT # Modify the apps vhost file - sed -i '/squirrelmail/e cat elfinder_cat.txt' $vhostfile + sed -i '/squirrelmail/e cat elfinder_cat.txt' $confvhost # Remove the created txt file rm elfinder_cat.txt # Reload apache2 if all good -- GitLab From 2635117a004b922efea7f544b215ed89cff6d92d Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:10:14 +0000 Subject: [PATCH 032/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index e5cd2eb..d1e34f6 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -104,8 +104,13 @@ write_nginx_vhost () { ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi - # Add content to dummy file - cat << EOT > elfinder_cat.txt + + if [ -f $confcustomdir/$confvhost ]; then + # Go to the conf-custom directory + cd $confcustomdir + + # Add content to dummy file + cat << EOT > elfinder_cat.txt ## ELFINDER FILE MANAGER ## @@ -139,9 +144,6 @@ write_nginx_vhost () { EOT - if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom directory - cd $confcustomdir # Search for filemanager in the apps vhost file if grep -q "filemanager" $confvhost; then echo "$exist" -- GitLab From 4bc296a74f0220c09334dbe41d63b9d8e0b3c83a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:13:45 +0000 Subject: [PATCH 033/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index d1e34f6..0f3d569 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -87,8 +87,7 @@ success="elFinder filemanager config has been successfully added to your vhost." failed="test failed. Please check and fix manually." write_nginx_vhost () { # Define custom and apps vhost files - nginxvhostdir=/etc/nginx/sites-available - appsvhost=apps.vhost + appsvhost=/etc/nginx/sites-available/apps.vhost confvhost=nginx_apps.vhost.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi @@ -176,8 +175,7 @@ EOT write_apache_vhost () { # Define custom and apps vhost files - apachevhostdir=/etc/apache2/sites-available - appsvhost=apps.vhost + appsvhost=/etc/apache2/sites-available/apps.vhost confvhost=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi -- GitLab From 3507619514fc7da68ed3bf27ebdac319d3cbdcb4 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:15:36 +0000 Subject: [PATCH 034/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0f3d569..50aede6 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -150,7 +150,7 @@ EOT else # Modify the apps vhost file sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost - if grep -q "filemanager" $confvhost; then + if grep -q "filemanager" $appsvhost; then echo "$exist" exit else -- GitLab From a8cfc89b272ecb0339fc12f30b2d2167885dd190 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:22:18 +0000 Subject: [PATCH 035/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 50aede6..e569548 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -109,7 +109,8 @@ write_nginx_vhost () { cd $confcustomdir # Add content to dummy file - cat << EOT > elfinder_cat.txt + catfile=elfinder_cat.txt + cat << EOT > $catfile ## ELFINDER FILE MANAGER ## @@ -154,13 +155,13 @@ EOT echo "$exist" exit else - sed -i 's/{use_tcp}/#/g' + sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\t\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\$phpfpm;" $appsvhost + sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost fi # Remove the created txt file - rm elfinder_cat.txt + rm $catfile # Reload nginx if all good if nginx -t 2>/dev/null; then systemctl reload nginx -- GitLab From 76ccc7cb4993deffa92b1487e6152b8fb0d0001a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:43:41 +0000 Subject: [PATCH 036/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 56 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index e569548..af25a6a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -22,6 +22,7 @@ get_elfinder () { sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html + cp php/connector.minimal.php-dist php/connector.minimal.php rm *.tar.gz hasbeen="elFinder filemanager has been" } @@ -113,33 +114,37 @@ write_nginx_vhost () { cat << EOT > $catfile - ## ELFINDER FILE MANAGER ## - - location /filemanager { - root /usr/share/; - index index.php index.html index.htm; - location ~ ^/filemanager/(.+\.php)$ { - try_files $uri =404; - root /usr/share/; - include /etc/nginx/fastcgi_params; - - # To access filemanager, create ftp users in ISPConfig UI - {use_tcp}fastcgi_pass 127.0.0.1:9000; - {use_socket}fastcgi_pass unix:{fpm_socket}; - fastcgi_index index.php; - include /etc/nginx/fastcgi_buffer_temp; - fastcgi_read_timeout 1200; - } - location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { - root /usr/share/; - access_log off; - log_not_found off; - expires max; - } + ## ELFINDER FILE MANAGER ## + + location /filemanager { + root /usr/share/; + index index.php index.html index.htm; + location ~ ^/filemanager/(.+\.php)$ { + try_files $uri =404; + root /usr/share/; + include /etc/nginx/fastcgi_params; + + # To access filemanager, create ftp users in ISPConfig UI + {use_tcp}fastcgi_pass 127.0.0.1:9000; + {use_socket}fastcgi_pass unix:{fpm_socket}; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_buffer_size 128k; + fastcgi_buffers 256 4k; + fastcgi_busy_buffers_size 256k; + fastcgi_temp_file_write_size 256k; + fastcgi_read_timeout 1200; } - location /file { - rewrite ^/* /filemanager last; + location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { + root /usr/share/; + access_log off; + log_not_found off; + expires max; } + } + location /file { + rewrite ^/* /filemanager last; + } EOT @@ -150,7 +155,6 @@ EOT exit else # Modify the apps vhost file - sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost if grep -q "filemanager" $appsvhost; then echo "$exist" exit -- GitLab From 3858dee8fe94cd896115b9637cd2daa49d335077 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 16:58:16 +0000 Subject: [PATCH 037/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index af25a6a..0189d13 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -111,7 +111,7 @@ write_nginx_vhost () { # Add content to dummy file catfile=elfinder_cat.txt - cat << EOT > $catfile + cat <<"EOT" > $catfile ## ELFINDER FILE MANAGER ## @@ -120,7 +120,7 @@ write_nginx_vhost () { root /usr/share/; index index.php index.html index.htm; location ~ ^/filemanager/(.+\.php)$ { - try_files $uri =404; + #try_files $uri =404; root /usr/share/; include /etc/nginx/fastcgi_params; @@ -204,7 +204,7 @@ write_apache_vhost () { echo "$exist" else # - cat << EOT > elfinder_cat.txt + cat <<"EOT" > elfinder_cat.txt ## ELFINDER FILE MANAGER ## -- GitLab From 4e07a957654aa49af8eed9781ab5fd841b3aa8d9 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 17:07:48 +0000 Subject: [PATCH 038/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0189d13..18eadab 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -120,7 +120,7 @@ write_nginx_vhost () { root /usr/share/; index index.php index.html index.htm; location ~ ^/filemanager/(.+\.php)$ { - #try_files $uri =404; + try_files $uri =404; root /usr/share/; include /etc/nginx/fastcgi_params; -- GitLab From 412368643e478d456a5b06f91c63df19c3d1a719 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Fri, 15 Sep 2023 17:09:10 +0000 Subject: [PATCH 039/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 18eadab..73cb1de 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -160,7 +160,7 @@ EOT exit else sed -i 's/{use_tcp}/#/g' $catfile - phpfpm="\t\t\t\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost fi -- GitLab From 52ada57d7019046c9335608beadb1e13aeb0e828 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 01:42:59 +0000 Subject: [PATCH 040/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 89 ++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 73cb1de..0bef909 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -79,13 +79,18 @@ fi ## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## -# Define conf directories and other messages +# Define conf directories, cat dummy files and other messages confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install -exist="Word filemanager exists in the apps vhost, aborting to avoid overwriting custom config. Please do this part manually later." -success="elFinder filemanager config has been successfully added to your vhost." -failed="test failed. Please check and fix manually." +catfile=elfinder_cat.txt +exist="Not overwriting as string (filemanager) exists in the vhost files for" +added="Added elFinder filemanager config successfully in the vhost files for" +success="has been successfully reloaded." +failed="configuration test failed." +manual="Please manually check and fix the related vhost file(s)." +browse="Your may try browsing the elfinder file manager at https://$(hostname -f):" +# Nginx write to custom and apps vhost files function write_nginx_vhost () { # Define custom and apps vhost files appsvhost=/etc/nginx/sites-available/apps.vhost @@ -109,8 +114,7 @@ write_nginx_vhost () { # Go to the conf-custom directory cd $confcustomdir - # Add content to dummy file - catfile=elfinder_cat.txt + # Add content to the defined dummy file cat <<"EOT" > $catfile @@ -149,38 +153,44 @@ write_nginx_vhost () { EOT - # Search for filemanager in the apps vhost file + # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo "$exist" + echo "$exist conf. $manual" exit else - # Modify the apps vhost file + # First modify the conf vhost file and report success + sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost + if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$exist conf. $manual" && exit; fi + # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo "$exist" + echo "$exist apps. $manual" exit + # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost + if grep -q "filemanager" $appsvhost; then echo "$added for apps."; else echo "$exist apps. $manual" && exit; fi fi - # Remove the created txt file + # All done. Remove the dummy file rm $catfile - # Reload nginx if all good + # Reload nginx if all good and report whether it is successful or failed if nginx -t 2>/dev/null; then systemctl reload nginx - echo "$success" + echo "Nginx $success. $browse8081/filemanager" else - echo "Nginx $failed" + echo "Nginx $failed $manual" fi fi fi } +# Apache write to custom and apps vhost files function write_apache_vhost () { # Define custom and apps vhost files - appsvhost=/etc/apache2/sites-available/apps.vhost + appsvhost=/etc/apache2/sites-available/ispconfig.vhost confvhost=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi @@ -196,15 +206,13 @@ write_apache_vhost () { ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi + if [ -f $confcustomdir/$confvhost ]]; then # Go to the conf-custom directory cd $confcustomdir - # Search for filemanager in the apps vhost file - if grep -q "filemanager" $confvhost; then - echo "$exist" - else - # - cat <<"EOT" > elfinder_cat.txt + + # Add content to the defined dummy file + cat <<"EOT" > $catfile ## ELFINDER FILE MANAGER ## @@ -220,16 +228,35 @@ write_apache_vhost () { EOT - # Modify the apps vhost file - sed -i '/squirrelmail/e cat elfinder_cat.txt' $confvhost - # Remove the created txt file - rm elfinder_cat.txt + + # Search for filemanager in the conf vhost file + if grep -q "filemanager" $confvhost; then + echo "$exist conf. $manual" + exit + else + # First modify the conf vhost file and report success + sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost + if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$exist conf. $manual" && exit; fi + # Then search for filemanager in the ispconfig vhost file, before we proceed further + if grep -q "filemanager" $appsvhost; then + echo "$exist ispconfig. $manual" + exit + # Finally, if it is safe, modify the ispconfig vhost file, with some edits for it to work + else + sed -i 's/{use_tcp}/#/g' $catfile + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile + sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost + if grep -q "filemanager" $appsvhost; then echo "$added for ispconfig."; else echo "$exist ispconfig. $manual" && exit; fi + fi + # All done. Remove the dummy file + rm $catfile # Reload apache2 if all good if $(apachectl configtest 2>&1) = *"Syntax OK"*; then systemctl reload apache2 - echo "$success" + echo "Apache2 $success. $browse8080/filemanager" else - echo "Apache $failed" + echo "Apache2 $failed $manual" fi fi fi @@ -242,8 +269,6 @@ if apt-get -v >/dev/null 2>&1; then # If web server is apache2, check and modify apps vhost accordingly elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then write_apache_vhost - else - echo $nosupport fi elif which yum &> /dev/null 2>&1; then # If web server is nginx, check and modify apps vhost accordingly @@ -252,8 +277,8 @@ elif which yum &> /dev/null 2>&1; then # If web server is apache2, check and modify apps vhost accordingly elif ( rpm -q httpd ); then write_apache_vhost - else - echo $nosupport fi +else + echo $nosupport fi -echo "elFinder script ended $(date +"%Y%m%d-%H%M%S")" +echo "elFinder script ended $(date +"%Y%m%d-%H%M%S")\nPlease report if there is any error(s) or failure(s) in HowToForge forum." -- GitLab From a20657e6061ecf9188dd8ca09b51a1a8c45a5e5e Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 01:48:34 +0000 Subject: [PATCH 041/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0bef909..0c023b1 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -89,7 +89,7 @@ added="Added elFinder filemanager config successfully in the vhost files for" success="has been successfully reloaded." failed="configuration test failed." manual="Please manually check and fix the related vhost file(s)." -browse="Your may try browsing the elfinder file manager at https://$(hostname -f):" +browse="Your may now try browsing the elfinder file manager at https://$(hostname -f):" # Nginx write to custom and apps vhost files function write_nginx_vhost () { # Define custom and apps vhost files -- GitLab From df1da8b5c5214f8b8f0c8871d0c090440474c7e2 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 01:53:02 +0000 Subject: [PATCH 042/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0c023b1..6b7787d 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -105,7 +105,7 @@ write_nginx_vhost () { # Force symlink to install directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink apps from custom-conf to install directory + # Force symlink apps file from custom-conf to install directory ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi @@ -187,14 +187,14 @@ EOT } -# Apache write to custom and apps vhost files function +# Apache write to custom and ispconfig vhost files function write_apache_vhost () { - # Define custom and apps vhost files + # Define custom and ispconfig vhost files appsvhost=/etc/apache2/sites-available/ispconfig.vhost confvhost=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi - # Copy apps vhost from conf to conf-custom if it doesn't exist + # Copy ispconfig vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ # Check conf-custom/install directory @@ -202,7 +202,7 @@ write_apache_vhost () { # Force symlink to install directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink apps from custom-conf to install directory + # Force symlink ispconfig file from custom-conf to install directory ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi @@ -266,7 +266,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 0 ]; then write_nginx_vhost - # If web server is apache2, check and modify apps vhost accordingly + # If web server is apache2, check and modify ispconfig vhost accordingly elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then write_apache_vhost fi @@ -274,7 +274,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 apps vhost accordingly + # If web server is apache2, check and modify ispconfig vhost accordingly elif ( rpm -q httpd ); then write_apache_vhost fi -- GitLab From 3731a2a08df3c3b121265ae4cb8e50d6d3b13d93 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 01:56:49 +0000 Subject: [PATCH 043/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 6b7787d..2f7fed4 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -90,6 +90,9 @@ success="has been successfully reloaded." failed="configuration test failed." manual="Please manually check and fix the related vhost file(s)." browse="Your may now try browsing the elfinder file manager at https://$(hostname -f):" +nosupport="You are not on a supported ISPConfig web server!" + + # Nginx write to custom and apps vhost files function write_nginx_vhost () { # Define custom and apps vhost files @@ -187,6 +190,7 @@ EOT } + # Apache write to custom and ispconfig vhost files function write_apache_vhost () { # Define custom and ispconfig vhost files @@ -261,7 +265,9 @@ EOT fi fi } -nosupport="You are not on a supported ISPConfig web server!" + + +# For Debian, Ubuntu & derivatives 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 0 ]; then @@ -270,6 +276,7 @@ if apt-get -v >/dev/null 2>&1; then elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then write_apache_vhost fi +# For Red Hat, Centos & derivatives elif which yum &> /dev/null 2>&1; then # If web server is nginx, check and modify apps vhost accordingly if ( rpm -q nginx ); then -- GitLab From 0ff1fad487b630d413780562a1684f1a0acf4351 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 02:32:09 +0000 Subject: [PATCH 044/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 41 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 2f7fed4..a0a9c58 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -2,7 +2,7 @@ # Name: elfinder_install_update.sh # Description: Install or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail -# Updated on 20230914-142723 +# Updated on 20230916-103205 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install # Define elfinder and its extract dir @@ -40,7 +40,8 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen updated to the latest version ("$lattestversion")." + status="updated" + echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." else echo "Failed. $extractdir is missing." fi @@ -49,6 +50,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir + status="installed" echo "$hasbeen installed with version ("$lattestversion")." else echo "Failed. $extractdir is missing." @@ -58,6 +60,7 @@ else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir + status="installed" echo "$hasbeen installed with version ("$lattestversion")." else echo "Failed. $extractdir is missing." @@ -91,6 +94,8 @@ failed="configuration test failed." manual="Please manually check and fix the related vhost file(s)." browse="Your may now try browsing the elfinder file manager at https://$(hostname -f):" nosupport="You are not on a supported ISPConfig web server!" +previous="Previous install could have set this up." +ooops="Something is wrong!" # Nginx write to custom and apps vhost files function @@ -158,15 +163,17 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo "$exist conf. $manual" + echo "$exist conf." + if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit else - # First modify the conf vhost file and report success + # First modify the conf vhost file and report result sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost - if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$exist conf. $manual" && exit; fi + if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo "$exist apps. $manual" + echo "$exist apps." + if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else @@ -174,11 +181,11 @@ EOT phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added for apps."; else echo "$exist apps. $manual" && exit; fi + if grep -q "filemanager" $appsvhost; then echo "$added for apps."; else echo "$ooops $manual" && exit; fi fi # All done. Remove the dummy file rm $catfile - # Reload nginx if all good and report whether it is successful or failed + # Reload nginx if all good and report result if nginx -t 2>/dev/null; then systemctl reload nginx echo "Nginx $success. $browse8081/filemanager" @@ -235,27 +242,29 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo "$exist conf. $manual" + echo "$exist conf." + if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit else - # First modify the conf vhost file and report success + # First modify the conf vhost file and report result sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost - if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$exist conf. $manual" && exit; fi - # Then search for filemanager in the ispconfig vhost file, before we proceed further + if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi + # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo "$exist ispconfig. $manual" + echo "$exist ISPConfig." + if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit - # Finally, if it is safe, modify the ispconfig vhost file, with some edits for it to work + # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added for ispconfig."; else echo "$exist ispconfig. $manual" && exit; fi + if grep -q "filemanager" $appsvhost; then echo "$added for ISPConfig."; else echo "$ooops $manual" && exit; fi fi # All done. Remove the dummy file rm $catfile - # Reload apache2 if all good + # Reload apache2 if all good and report result if $(apachectl configtest 2>&1) = *"Syntax OK"*; then systemctl reload apache2 echo "Apache2 $success. $browse8080/filemanager" -- GitLab From d4cca564b2ede452ffe8558a9432ab9d90fcbab1 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:16:01 +0000 Subject: [PATCH 045/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index a0a9c58..437938d 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -19,7 +19,7 @@ get_elfinder () { # Extract, overwriting current files and folders, if any, thus updating as well. tar -xzf $lattestversion.tar.gz --strip-components=1 # Make elfinder open full in browser - sed -i '/defaultOpts/a \\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false,' elfinder.html + sed -i "/defaultOpts/a \\\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false," elfinder.html # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html cp php/connector.minimal.php-dist php/connector.minimal.php -- GitLab From a35933c57345a8e6dccb3d6b53231f4e7820c926 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:23:28 +0000 Subject: [PATCH 046/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 437938d..17fa328 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -92,7 +92,7 @@ added="Added elFinder filemanager config successfully in the vhost files for" success="has been successfully reloaded." failed="configuration test failed." manual="Please manually check and fix the related vhost file(s)." -browse="Your may now try browsing the elfinder file manager at https://$(hostname -f):" +browse="Your may now try browsing the elfinder file manager at https://`hostname -f`:" nosupport="You are not on a supported ISPConfig web server!" previous="Previous install could have set this up." ooops="Something is wrong!" -- GitLab From ea8a64b34016b4377d9388034f5dc32ac9345d7a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:24:30 +0000 Subject: [PATCH 047/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 17fa328..b7a1ad9 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -181,7 +181,7 @@ EOT phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added for apps."; else echo "$ooops $manual" && exit; fi + if grep -q "filemanager" $appsvhost; then echo "$added apps."; else echo "$ooops $manual" && exit; fi fi # All done. Remove the dummy file rm $catfile @@ -260,7 +260,7 @@ EOT phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added for ISPConfig."; else echo "$ooops $manual" && exit; fi + if grep -q "filemanager" $appsvhost; then echo "$added ISPConfig."; else echo "$ooops $manual" && exit; fi fi # All done. Remove the dummy file rm $catfile -- GitLab From e3229d73532351031765ebcf91a9d162dc8ee97e Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:34:19 +0000 Subject: [PATCH 048/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index b7a1ad9..08b8e93 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -164,7 +164,7 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then echo "$exist conf." - if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit else # First modify the conf vhost file and report result @@ -173,7 +173,7 @@ EOT # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then echo "$exist apps." - if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else @@ -243,7 +243,7 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then echo "$exist conf." - if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit else # First modify the conf vhost file and report result @@ -252,7 +252,7 @@ EOT # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then echo "$exist ISPConfig." - if [[ $status == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else -- GitLab From aefea1ceb616150797f72a630ffb0dfaec222714 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:44:22 +0000 Subject: [PATCH 049/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 08b8e93..48ffa65 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -40,8 +40,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - status="updated" - echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." + echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." | tee -a status.txt else echo "Failed. $extractdir is missing." fi @@ -50,8 +49,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - status="installed" - echo "$hasbeen installed with version ("$lattestversion")." + echo "$hasbeen installed with version ("$lattestversion")." | tee -a status.txt else echo "Failed. $extractdir is missing." fi @@ -60,8 +58,7 @@ else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - status="installed" - echo "$hasbeen installed with version ("$lattestversion")." + echo "$hasbeen installed with version ("$lattestversion")." | tee -a status.txt else echo "Failed. $extractdir is missing." fi @@ -74,7 +71,7 @@ filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") if [ -d $filemanagerdir ]; then # Backup then force symlink if directory exist but not empty and also not a link - if [[ ! -z $filemanagerdir || ! -L $filemanagerdir ]]; then cp $filemanagerdir $filemanagerbakdir; fi + if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp $filemanagerdir $filemanagerbakdir; fi ln -sf $elfinderdir $filemanagerdir else ln -sf $elfinderdir $filemanagerdir @@ -87,6 +84,7 @@ confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install catfile=elfinder_cat.txt +status=$elfinderdir/status.txt exist="Not overwriting as string (filemanager) exists in the vhost files for" added="Added elFinder filemanager config successfully in the vhost files for" success="has been successfully reloaded." -- GitLab From dff39de6a5991362bcf9ea64acfe88846ef83945 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:55:56 +0000 Subject: [PATCH 050/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 48ffa65..31f0f7a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -71,7 +71,7 @@ filemanagerdir=/usr/share/filemanager filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") if [ -d $filemanagerdir ]; then # Backup then force symlink if directory exist but not empty and also not a link - if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp $filemanagerdir $filemanagerbakdir; fi + if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp -R $filemanagerdir $filemanagerbakdir; fi ln -sf $elfinderdir $filemanagerdir else ln -sf $elfinderdir $filemanagerdir @@ -162,7 +162,7 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then echo "$exist conf." - if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi exit else # First modify the conf vhost file and report result @@ -171,7 +171,7 @@ EOT # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then echo "$exist apps." - if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else @@ -181,8 +181,8 @@ EOT sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost if grep -q "filemanager" $appsvhost; then echo "$added apps."; else echo "$ooops $manual" && exit; fi fi - # All done. Remove the dummy file - rm $catfile + # All done. Remove the dummy files + rm $catfile $status # Reload nginx if all good and report result if nginx -t 2>/dev/null; then systemctl reload nginx @@ -241,7 +241,7 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then echo "$exist conf." - if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi exit else # First modify the conf vhost file and report result @@ -250,7 +250,7 @@ EOT # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then echo "$exist ISPConfig." - if [[ "$status" == *"updated"* ]]; then echo "$previous"; else echo "$manual"; fi + if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else @@ -260,8 +260,8 @@ EOT sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost if grep -q "filemanager" $appsvhost; then echo "$added ISPConfig."; else echo "$ooops $manual" && exit; fi fi - # All done. Remove the dummy file - rm $catfile + # All done. Remove the dummy files + rm $catfile $status # Reload apache2 if all good and report result if $(apachectl configtest 2>&1) = *"Syntax OK"*; then systemctl reload apache2 -- GitLab From 2a34373d202d63d20d4842e06ece56d2150422e3 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 05:59:00 +0000 Subject: [PATCH 051/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 31f0f7a..81c6291 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -170,7 +170,7 @@ EOT if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo "$exist apps." + echo "$exist apps. \n$status" if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the apps vhost file, with some edits for it to work -- GitLab From 4585836f867e2418c26d68f255b59dec2afb8434 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:07:00 +0000 Subject: [PATCH 052/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 81c6291..0c94b6a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -170,7 +170,8 @@ EOT if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo "$exist apps. \n$status" + echo "$exist apps." + cat "$status" if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi exit # Finally, if it is safe, modify the apps vhost file, with some edits for it to work -- GitLab From 99efb24e7474c84808afe9f128428fec916ffab5 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:18:17 +0000 Subject: [PATCH 053/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0c94b6a..226fbec 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -28,11 +28,11 @@ get_elfinder () { } # Define latest version -lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) +lattestversion=curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2 if [ -d "$elfinderdir" ]; then cd $elfinderdir if [ -f "package.json" && ]; then - currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) + currentversion=grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2 if [ "$currentversion" == "$latestversion" ]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date with the latest version of "$lattestversion"" -- GitLab From c53f5c2a015c2cff26b9c5c7b155777b5d4b7099 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:47:45 +0000 Subject: [PATCH 054/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 226fbec..fe20077 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -28,11 +28,11 @@ get_elfinder () { } # Define latest version -lattestversion=curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2 +lattestversion=`curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2` if [ -d "$elfinderdir" ]; then cd $elfinderdir if [ -f "package.json" && ]; then - currentversion=grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2 + currentversion=`grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2` if [ "$currentversion" == "$latestversion" ]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date with the latest version of "$lattestversion"" -- GitLab From 3e7e311d670cbe57dec443807942006de60f382b Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:53:39 +0000 Subject: [PATCH 055/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index fe20077..cc80955 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -28,11 +28,11 @@ get_elfinder () { } # Define latest version -lattestversion=`curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2` +lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) if [ -d "$elfinderdir" ]; then cd $elfinderdir - if [ -f "package.json" && ]; then - currentversion=`grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2` + if [ -f "package.json" ]; then + currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) if [ "$currentversion" == "$latestversion" ]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date with the latest version of "$lattestversion"" @@ -40,7 +40,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." | tee -a status.txt + echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." | tee -a $elfinderdir/status.txt else echo "Failed. $extractdir is missing." fi @@ -49,7 +49,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." | tee -a status.txt + echo "$hasbeen installed with version ("$lattestversion")." | tee -a $elfinderdir/status.txt else echo "Failed. $extractdir is missing." fi @@ -58,7 +58,7 @@ else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." | tee -a status.txt + echo "$hasbeen installed with version ("$lattestversion")." | tee -a $elfinderdir/status.txt else echo "Failed. $extractdir is missing." fi -- GitLab From 2af06d8761b405515d601a6a03845102bde22f55 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:58:04 +0000 Subject: [PATCH 056/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index cc80955..bcede58 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -27,20 +27,21 @@ get_elfinder () { hasbeen="elFinder filemanager has been" } -# Define latest version +# Define latest version and create status dummy file lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) +status=$elfinderdir/status.txt if [ -d "$elfinderdir" ]; then cd $elfinderdir if [ -f "package.json" ]; then currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) - if [ "$currentversion" == "$latestversion" ]; then + if [[ "$currentversion" == "$latestversion" ]]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date with the latest version of "$lattestversion"" else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." | tee -a $elfinderdir/status.txt + echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." | tee -a $status else echo "Failed. $extractdir is missing." fi @@ -49,7 +50,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." | tee -a $elfinderdir/status.txt + echo "$hasbeen installed with version ("$lattestversion")." | tee -a $status else echo "Failed. $extractdir is missing." fi @@ -58,7 +59,7 @@ else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." | tee -a $elfinderdir/status.txt + echo "$hasbeen installed with version ("$lattestversion")." | tee -a $status else echo "Failed. $extractdir is missing." fi @@ -84,7 +85,6 @@ confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install catfile=elfinder_cat.txt -status=$elfinderdir/status.txt exist="Not overwriting as string (filemanager) exists in the vhost files for" added="Added elFinder filemanager config successfully in the vhost files for" success="has been successfully reloaded." -- GitLab From 3e2d7d64dc6ce63098f16b7f5ab6b09a705ad254 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:59:08 +0000 Subject: [PATCH 057/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index bcede58..acb3938 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -296,4 +296,3 @@ elif which yum &> /dev/null 2>&1; then else echo $nosupport fi -echo "elFinder script ended $(date +"%Y%m%d-%H%M%S")\nPlease report if there is any error(s) or failure(s) in HowToForge forum." -- GitLab From d641f86714554f4a6f6c0559e839b35c35b12222 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 06:59:57 +0000 Subject: [PATCH 058/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index acb3938..4fb882f 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -217,7 +217,7 @@ write_apache_vhost () { fi fi - if [ -f $confcustomdir/$confvhost ]]; then + if [ -f $confcustomdir/$confvhost ]; then # Go to the conf-custom directory cd $confcustomdir -- GitLab From b192d2af04139f80bc4f629b5353136b1a7bab7d Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 07:10:53 +0000 Subject: [PATCH 059/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 4fb882f..636a3df 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -34,7 +34,7 @@ if [ -d "$elfinderdir" ]; then cd $elfinderdir if [ -f "package.json" ]; then currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) - if [[ "$currentversion" == "$latestversion" ]]; then + if [[ "$currentversion" == "$lattestversion" ]]; then # Existing elfinder is up-to-date echo "Existing install is up-to-date with the latest version of "$lattestversion"" else -- GitLab From 122ab3af9bcca2d55f0cd7605213da2a82e558a2 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 07:15:19 +0000 Subject: [PATCH 060/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 636a3df..8819f7e 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -166,7 +166,7 @@ EOT exit else # First modify the conf vhost file and report result - sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost + sed -i "/location \/squirrelmail/e cat $catfile" $confvhost if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then @@ -179,7 +179,7 @@ EOT sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile - sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost + sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost if grep -q "filemanager" $appsvhost; then echo "$added apps."; else echo "$ooops $manual" && exit; fi fi # All done. Remove the dummy files @@ -246,7 +246,7 @@ EOT exit else # First modify the conf vhost file and report result - sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $confvhost + sed -i "/location \/squirrelmail/e cat $catfile" $confvhost if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then @@ -258,7 +258,7 @@ EOT sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile - sed -i '/location \/squirrelmail/e cat elfinder_cat.txt' $appsvhost + sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost if grep -q "filemanager" $appsvhost; then echo "$added ISPConfig."; else echo "$ooops $manual" && exit; fi fi # All done. Remove the dummy files -- GitLab From cec34427b4627903e686f3cfdad9ce6dc2aa27e5 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 09:22:32 +0000 Subject: [PATCH 061/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 118 +++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 8819f7e..db2a8c5 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -2,8 +2,9 @@ # Name: elfinder_install_update.sh # Description: Install or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail +# BSD 3 License # Updated on 20230916-103205 -# Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install +# Should, in theory, work on systems that were setup according to HowToForge's Perfect Server guides auto/manual # Define elfinder and its extract dir elfinderdir=/usr/share/elfinder @@ -36,12 +37,14 @@ if [ -d "$elfinderdir" ]; then currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) if [[ "$currentversion" == "$lattestversion" ]]; then # Existing elfinder is up-to-date - echo "Existing install is up-to-date with the latest version of "$lattestversion"" + echo "Existing install is up-to-date with the latest version of "$lattestversion"" >> $status + cat "$status" else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." | tee -a $status + echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." >> $status + cat "$status" else echo "Failed. $extractdir is missing." fi @@ -50,7 +53,8 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." | tee -a $status + echo "$hasbeen installed with version ("$lattestversion")." >> $status + cat "$status" else echo "Failed. $extractdir is missing." fi @@ -59,7 +63,8 @@ else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." | tee -a $status + echo "$hasbeen installed with version ("$lattestversion")." >> $status + cat "$status" else echo "Failed. $extractdir is missing." fi @@ -89,8 +94,8 @@ exist="Not overwriting as string (filemanager) exists in the vhost files for" added="Added elFinder filemanager config successfully in the vhost files for" success="has been successfully reloaded." failed="configuration test failed." -manual="Please manually check and fix the related vhost file(s)." -browse="Your may now try browsing the elfinder file manager at https://`hostname -f`:" +manual="Please double check and manually fix the vhost file(s), if needed." +browse="Your may now try browsing the elfinder file manager at \nhttps://$(hostname -f):" nosupport="You are not on a supported ISPConfig web server!" previous="Previous install could have set this up." ooops="Something is wrong!" @@ -161,36 +166,34 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo "$exist conf." - if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi - exit + echo -e ""$exist" conf.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/location \/squirrelmail/e cat $catfile" $confvhost if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi - # Then search for filemanager in the apps vhost file, before we proceed further - if grep -q "filemanager" $appsvhost; then - echo "$exist apps." - cat "$status" - if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi - exit - # Finally, if it is safe, modify the apps vhost file, with some edits for it to work - else - sed -i 's/{use_tcp}/#/g' $catfile - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile - sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added apps."; else echo "$ooops $manual" && exit; fi - fi - # All done. Remove the dummy files - rm $catfile $status - # Reload nginx if all good and report result - if nginx -t 2>/dev/null; then - systemctl reload nginx - echo "Nginx $success. $browse8081/filemanager" - else - echo "Nginx $failed $manual" - fi + fi + + # Then search for filemanager in the apps vhost file, before we proceed further + if grep -q "filemanager" $appsvhost; then + echo -e ""$exist" apps.\n"$previous"\n"$manual"" + # Finally, if it is safe, modify the apps vhost file, with some edits for it to work + else + sed -i 's/{use_tcp}/#/g' $catfile + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile + sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost + if grep -q "filemanager" $appsvhost; then echo "$added apps."; else echo "$ooops $manual" && exit; fi + fi + + # Both vhosts modifications are done. Remove the unneeded files + rm -rf $catfile $status $extractdir + + # Reload nginx if all good and report result + if nginx -t 2>/dev/null; then + systemctl reload nginx + echo -e "Nginx "$success" \n"$browse"8081/filemanager" + else + echo -e "Nginx "$failed" \n"$manual"" fi fi @@ -241,35 +244,34 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo "$exist conf." - if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi - exit + echo -e ""$exist" conf.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/location \/squirrelmail/e cat $catfile" $confvhost if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi - # Then search for filemanager in the ISPConfig vhost file, before we proceed further - if grep -q "filemanager" $appsvhost; then - echo "$exist ISPConfig." - if grep -Fxq "updated" $status; then echo "$previous"; else echo "$manual"; fi - exit - # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work - else - sed -i 's/{use_tcp}/#/g' $catfile - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile - sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added ISPConfig."; else echo "$ooops $manual" && exit; fi - fi - # All done. Remove the dummy files - rm $catfile $status - # Reload apache2 if all good and report result - if $(apachectl configtest 2>&1) = *"Syntax OK"*; then - systemctl reload apache2 - echo "Apache2 $success. $browse8080/filemanager" - else - echo "Apache2 $failed $manual" - fi + fi + + # Then search for filemanager in the ISPConfig vhost file, before we proceed further + if grep -q "filemanager" $appsvhost; then + echo -e ""$exist" ISPConfig.\n"$previous"\n"$manual"" + # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work + else + sed -i 's/{use_tcp}/#/g' $catfile + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile + sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost + if grep -q "filemanager" $appsvhost; then echo "$added ISPConfig."; else echo "$ooops $manual" && exit; fi + fi + + # Both vhosts modifications are done. Remove the unneeded files + rm -rf $catfile $status $extractdir + + # Reload apache2 if all good and report result + if $(apachectl configtest 2>&1) = *"Syntax OK"*; then + systemctl reload apache2 + echo -e "Apache2 "$success"\n"$browse"8080/filemanager" + else + echo -e "Apache2 "$failed"\n"$manual"" fi fi } -- GitLab From 47782522b22f1edbb1bd014aa6905a4a9b8360ac Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Sat, 16 Sep 2023 16:59:49 +0000 Subject: [PATCH 062/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 147 +++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 32 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index db2a8c5..43dc46a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -2,9 +2,8 @@ # Name: elfinder_install_update.sh # Description: Install or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail -# BSD 3 License # Updated on 20230916-103205 -# Should, in theory, work on systems that were setup according to HowToForge's Perfect Server guides auto/manual +# Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install # Define elfinder and its extract dir elfinderdir=/usr/share/elfinder @@ -53,7 +52,7 @@ if [ -d "$elfinderdir" ]; then get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." >> $status + echo "$hasbeen installed with version "$lattestversion"." >> $status cat "$status" else echo "Failed. $extractdir is missing." @@ -63,7 +62,7 @@ else get_elfinder if [ -d "$extractdir" ]; then cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version ("$lattestversion")." >> $status + echo "$hasbeen installed with version "$lattestversion"." >> $status cat "$status" else echo "Failed. $extractdir is missing." @@ -90,8 +89,9 @@ confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install catfile=elfinder_cat.txt -exist="Not overwriting as string (filemanager) exists in the vhost files for" -added="Added elFinder filemanager config successfully in the vhost files for" +catfile2=elfinder_cat2.txt +exist="Not overwriting as string (filemanager) exists in the" +added="Added elFinder filemanager config successfully in the" success="has been successfully reloaded." failed="configuration test failed." manual="Please double check and manually fix the vhost file(s), if needed." @@ -166,23 +166,23 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo -e ""$exist" conf.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/location \/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi + if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo -e ""$exist" apps.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$appsvhost" file.\n"$previous"\n"$manual"" # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added apps."; else echo "$ooops $manual" && exit; fi + if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$appsvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi fi # Both vhosts modifications are done. Remove the unneeded files @@ -191,9 +191,9 @@ EOT # Reload nginx if all good and report result if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "Nginx "$success" \n"$browse"8081/filemanager" + echo -e "\nNginx "$success"\n\n"$browse"8081/filemanager" else - echo -e "Nginx "$failed" \n"$manual"" + echo -e "\nNginx "$failed"\n\n"$manual"" fi fi @@ -203,7 +203,8 @@ EOT # Apache write to custom and ispconfig vhost files function write_apache_vhost () { # Define custom and ispconfig vhost files - appsvhost=/etc/apache2/sites-available/ispconfig.vhost + appsvhost=/etc/apache2/sites-available/ispconfig.conf + basename=$(basename $appsvhost) confvhost=apache_ispconfig.conf.master # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi @@ -225,8 +226,7 @@ write_apache_vhost () { cd $confcustomdir # Add content to the defined dummy file - cat <<"EOT" > $catfile - + tee $catfile >/dev/null << END ## ELFINDER FILE MANAGER ## @@ -240,38 +240,121 @@ write_apache_vhost () { -EOT +END # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo -e ""$exist" conf.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result - sed -i "/location \/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo "$added conf."; else echo "$ooops $manual" && exit; fi + sed -i "/\/squirrelmail/e cat $catfile" $confvhost + if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi fi + tee $catfile2 >/dev/null << END + +## ELFINDER FILE MANAGER ## + + + Require all granted + + + +END + # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo -e ""$exist" ISPConfig.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$basename" file.\n"$previous"\n"$manual"\n" # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else - sed -i 's/{use_tcp}/#/g' $catfile - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile - sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo "$added ISPConfig."; else echo "$ooops $manual" && exit; fi + sed -i "/\/squirrelmail/e cat $catfile2" $appsvhost + if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$basename" file.\n"; else echo -e "\n"$ooops" "$manual"\n" && exit; fi fi - + + + # Create basic filemanager config.file + elfinderadir=/etc/apache2/conf-available + elfinderedir=/etc/apache2/conf-enabled + elfinderconf=filemanager.conf + tee $elfinderadir/$elfinderconf >/dev/null << END +# elFinder default Apache configuration + +Alias /filemanager /usr/share/filemanager + + + Options FollowSymLinks + DirectoryIndex index.html + + AllowOverride All + + = 2.3> + Require all granted + + + + Order allow,deny + Allow from all + + + # Clear PHP settings of this website + # + # SetHandler None + # + + Require all granted + + + + + + + SetHandler php-fcgi + + + + + + + + SetHandler php-fcgi + + + + + Action php-fcgi /php-fcgi virtual + + + + + Header set Content-Security-Policy "script-src 'self' https://cdnjs.cloudflare.com/" + Header set Content-Security-Policy "img-src 'self'" + + + + AddType application/x-httpd-php .php + php_flag magic_quotes_gpc Off + php_flag track_vars On + php_flag register_globals Off + php_value include_path . + + + + + + SSLStaplingCache shmcb:/var/run/ocsp(128000) + +END + + if [ ! -f $elfinderedir/$elfinderconf ]; then a2enconf filemanager; fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $status $extractdir + rm -rf $catfile $catfile2 $status $extractdir # Reload apache2 if all good and report result - if $(apachectl configtest 2>&1) = *"Syntax OK"*; then + if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then systemctl reload apache2 - echo -e "Apache2 "$success"\n"$browse"8080/filemanager" + echo -e "\nApache2 "$success"\n\n"$browse"8080/filemanager" else - echo -e "Apache2 "$failed"\n"$manual"" + echo -e "\nApache2 "$failed"\n\n"$manual"" fi fi } @@ -280,10 +363,10 @@ EOT # For Debian, Ubuntu & derivatives 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 0 ]; then + 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 - elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + elif [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then write_apache_vhost fi # For Red Hat, Centos & derivatives -- GitLab From 207510e9a9c50e8ec827f3928c48297e9455f4d6 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 01:45:47 +0000 Subject: [PATCH 063/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 134 ++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 43dc46a..c253085 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -5,86 +5,94 @@ # Updated on 20230916-103205 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install -# Define elfinder and its extract dir -elfinderdir=/usr/share/elfinder -extractdir=/tmp/elfinder + +## INSTALLATION / UPDATE FOR ELFINDER FILE MANAGER +# Function to download and extract elFinder get_elfinder () { # Create extract dir if doesn't exist - if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi - if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi + if [ ! -d "$ef_extr_dir" ]; then mkdir -p $ef_extr_dir; fi + if [ ! -d "$ef_main_dir" ]; then mkdir -p $ef_main_dir; fi # Go to the defined extract dir - cd $extractdir + cd $ef_extr_dir # Download lattest elfinder package - wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz + wget https://github.com/Studio-42/elFinder/archive/$ef_late_ver.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. - tar -xzf $lattestversion.tar.gz --strip-components=1 + tar -xzf $ef_late_ver.tar.gz --strip-components=1 # Make elfinder open full in browser sed -i "/defaultOpts/a \\\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false," elfinder.html # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html cp php/connector.minimal.php-dist php/connector.minimal.php rm *.tar.gz - hasbeen="elFinder filemanager has been" } -# Define latest version and create status dummy file -lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) -status=$elfinderdir/status.txt -if [ -d "$elfinderdir" ]; then - cd $elfinderdir +# Function to install or update elFinder via overwriting +new_elfinder () { + if [ -d $ef_ext_dir ]; then + cp -R $ef_ext_dir/* $ef_main_dir + if [ -f "package.json" ]; then + echo -e ""$ef_exist" "$ef_curr_ver"\n"$ef_outdated" "$ef_late_ver"." | tee $ef_stat_log + else + echo -e ""$ef_none" "$ef_uptodate"" | tee $ef_stat_log + fi + else + echo $ef_failed + fi +} + + +if [ -d "$ef_main_dir" ]; then + # Get into elFinder folder + cd $ef_main_dir + + # Define elFinder main & extract folder & latest version & install messages + ef_late_ver=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) + ef_main_dir=/usr/share/elfinder + ef_extr_dir=/tmp/elfinder + ef_stat_log=$ef_main_dir/temp-status.log + ef_exist="elFinder filemanager install exists with version" + ef_uptodate="It is up-to-date. Neither new install nor update is needed." + ef_outdated="This old insrall has been updated to latest version" + ef_none="We've setup new elFinder filemanager as none is found i.e. version" + ef_failed="Failed to download and install / download elFinder filemanager." + if [ -f "package.json" ]; then - currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) - if [[ "$currentversion" == "$lattestversion" ]]; then - # Existing elfinder is up-to-date - echo "Existing install is up-to-date with the latest version of "$lattestversion"" >> $status - cat "$status" + ef_curr_ver=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) + if [[ "$ef_curr_ver" == "$ef_late_ver" ]]; then + if [[ $ef_curr_ver == $ef_late_ver ]]; then + # Existing elFinder is up-to-date + echo -e ""$ef_exist" "$ef_late_ver".\n"$ef_uptodate"" | tee $ef_stat_log else + # Existing elFinder is outdated get_elfinder - if [ -d "$extractdir" ]; then - cp -R $extractdir/* $elfinderdir - echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." >> $status - cat "$status" - else - echo "Failed. $extractdir is missing." - fi - fi + new_elfinder else + # No existing elFinder package get_elfinder - if [ -d "$extractdir" ]; then - cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version "$lattestversion"." >> $status - cat "$status" - else - echo "Failed. $extractdir is missing." - fi + new_elfinder fi else + # No existing elFinder folder get_elfinder - if [ -d "$extractdir" ]; then - cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version "$lattestversion"." >> $status - cat "$status" - else - echo "Failed. $extractdir is missing." - fi + new_elfinder fi -## FILE MANAGER CREATE OR OVERWRITE, THUS TO BACKUP IF EXIST AND IS NEITHER EMPTY NOR LINKED ## -# Define filemanager directory and its backup -filemanagerdir=/usr/share/filemanager -filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") -if [ -d $filemanagerdir ]; then - # Backup then force symlink if directory exist but not empty and also not a link - if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp -R $filemanagerdir $filemanagerbakdir; fi - ln -sf $elfinderdir $filemanagerdir +## FILE MANAGER CREATE / OVERWRITE, TO BACKUP IF EXIST & NEITHER EMPTY NOR LINKED +# Define filemanager folder and its backup +ef_fm_dir=/usr/share/filemanager +ef_fm_bak_dir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") +if [ -d $ef_fm_dir ]; then + # Backup then force symlink if folder exist but not empty and also not a link + if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak_dir; fi + ln -sf $ef_main_dir $ef_fm_dir else - ln -sf $elfinderdir $filemanagerdir + ln -sf $ef_main_dir $ef_fm_dir fi ## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## -# Define conf directories, cat dummy files and other messages +# Define conf folders, cat dummy files and other messages confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install @@ -106,23 +114,23 @@ write_nginx_vhost () { # Define custom and apps vhost files appsvhost=/etc/nginx/sites-available/apps.vhost confvhost=nginx_apps.vhost.master - # Create conf-custom directory if it doesn't exist + # Create conf-custom folder if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy apps vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install directory + # Check conf-custom/install folder if [ ! -d $confcustominstalldir ]; then - # Force symlink to install directory, if it doesn't exist + # Force symlink to install folder, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink apps file from custom-conf to install directory + # Force symlink apps file from custom-conf to install folder ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom directory + # Go to the conf-custom folder cd $confcustomdir # Add content to the defined dummy file @@ -186,7 +194,7 @@ EOT fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $status $extractdir + rm -rf $catfile $ef_stat_log $ef_extr_dir # Reload nginx if all good and report result if nginx -t 2>/dev/null; then @@ -206,23 +214,23 @@ write_apache_vhost () { appsvhost=/etc/apache2/sites-available/ispconfig.conf basename=$(basename $appsvhost) confvhost=apache_ispconfig.conf.master - # Create conf-custom directory if it doesn't exist + # Create conf-custom folder if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy ispconfig vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install directory + # Check conf-custom/install folder if [ ! -d $confcustominstalldir ]; then - # Force symlink to install directory, if it doesn't exist + # Force symlink to install folder, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink ispconfig file from custom-conf to install directory + # Force symlink ispconfig file from custom-conf to install folder ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom directory + # Go to the conf-custom folder cd $confcustomdir # Add content to the defined dummy file @@ -347,7 +355,7 @@ END if [ ! -f $elfinderedir/$elfinderconf ]; then a2enconf filemanager; fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $catfile2 $status $extractdir + rm -rf $catfile $catfile2 $ef_stat_log $ef_extr_dir # Reload apache2 if all good and report result if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then -- GitLab From 557d13f57e0fb72046fe4fe362d2ddb41f87603a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 01:49:17 +0000 Subject: [PATCH 064/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index c253085..df428ad 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -66,6 +66,7 @@ if [ -d "$ef_main_dir" ]; then # Existing elFinder is outdated get_elfinder new_elfinder + fi else # No existing elFinder package get_elfinder -- GitLab From c0e748d2df91384fe9773abab5ee2dc1e5496559 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 01:50:18 +0000 Subject: [PATCH 065/110] Update elfinder_install_update.sh -- GitLab From a2684045e535647c7cd785120945836c7522c169 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 01:54:07 +0000 Subject: [PATCH 066/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 133 +++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 71 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index df428ad..43dc46a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -5,95 +5,86 @@ # Updated on 20230916-103205 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install - -## INSTALLATION / UPDATE FOR ELFINDER FILE MANAGER -# Function to download and extract elFinder +# Define elfinder and its extract dir +elfinderdir=/usr/share/elfinder +extractdir=/tmp/elfinder get_elfinder () { # Create extract dir if doesn't exist - if [ ! -d "$ef_extr_dir" ]; then mkdir -p $ef_extr_dir; fi - if [ ! -d "$ef_main_dir" ]; then mkdir -p $ef_main_dir; fi + if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi + if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi # Go to the defined extract dir - cd $ef_extr_dir + cd $extractdir # Download lattest elfinder package - wget https://github.com/Studio-42/elFinder/archive/$ef_late_ver.tar.gz + wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz # Extract, overwriting current files and folders, if any, thus updating as well. - tar -xzf $ef_late_ver.tar.gz --strip-components=1 + tar -xzf $lattestversion.tar.gz --strip-components=1 # Make elfinder open full in browser sed -i "/defaultOpts/a \\\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false," elfinder.html # Symlink, which is preferred rather than rename ln -sf elfinder.html index.html cp php/connector.minimal.php-dist php/connector.minimal.php rm *.tar.gz + hasbeen="elFinder filemanager has been" } -# Function to install or update elFinder via overwriting -new_elfinder () { - if [ -d $ef_ext_dir ]; then - cp -R $ef_ext_dir/* $ef_main_dir - if [ -f "package.json" ]; then - echo -e ""$ef_exist" "$ef_curr_ver"\n"$ef_outdated" "$ef_late_ver"." | tee $ef_stat_log - else - echo -e ""$ef_none" "$ef_uptodate"" | tee $ef_stat_log - fi - else - echo $ef_failed - fi -} - - -if [ -d "$ef_main_dir" ]; then - # Get into elFinder folder - cd $ef_main_dir - - # Define elFinder main & extract folder & latest version & install messages - ef_late_ver=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) - ef_main_dir=/usr/share/elfinder - ef_extr_dir=/tmp/elfinder - ef_stat_log=$ef_main_dir/temp-status.log - ef_exist="elFinder filemanager install exists with version" - ef_uptodate="It is up-to-date. Neither new install nor update is needed." - ef_outdated="This old insrall has been updated to latest version" - ef_none="We've setup new elFinder filemanager as none is found i.e. version" - ef_failed="Failed to download and install / download elFinder filemanager." - +# Define latest version and create status dummy file +lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) +status=$elfinderdir/status.txt +if [ -d "$elfinderdir" ]; then + cd $elfinderdir if [ -f "package.json" ]; then - ef_curr_ver=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) - if [[ "$ef_curr_ver" == "$ef_late_ver" ]]; then - if [[ $ef_curr_ver == $ef_late_ver ]]; then - # Existing elFinder is up-to-date - echo -e ""$ef_exist" "$ef_late_ver".\n"$ef_uptodate"" | tee $ef_stat_log + currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) + if [[ "$currentversion" == "$lattestversion" ]]; then + # Existing elfinder is up-to-date + echo "Existing install is up-to-date with the latest version of "$lattestversion"" >> $status + cat "$status" else - # Existing elFinder is outdated get_elfinder - new_elfinder + if [ -d "$extractdir" ]; then + cp -R $extractdir/* $elfinderdir + echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." >> $status + cat "$status" + else + echo "Failed. $extractdir is missing." + fi fi else - # No existing elFinder package get_elfinder - new_elfinder + if [ -d "$extractdir" ]; then + cp -R $extractdir/* $elfinderdir + echo "$hasbeen installed with version "$lattestversion"." >> $status + cat "$status" + else + echo "Failed. $extractdir is missing." + fi fi else - # No existing elFinder folder get_elfinder - new_elfinder + if [ -d "$extractdir" ]; then + cp -R $extractdir/* $elfinderdir + echo "$hasbeen installed with version "$lattestversion"." >> $status + cat "$status" + else + echo "Failed. $extractdir is missing." + fi fi -## FILE MANAGER CREATE / OVERWRITE, TO BACKUP IF EXIST & NEITHER EMPTY NOR LINKED -# Define filemanager folder and its backup -ef_fm_dir=/usr/share/filemanager -ef_fm_bak_dir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") -if [ -d $ef_fm_dir ]; then - # Backup then force symlink if folder exist but not empty and also not a link - if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak_dir; fi - ln -sf $ef_main_dir $ef_fm_dir +## FILE MANAGER CREATE OR OVERWRITE, THUS TO BACKUP IF EXIST AND IS NEITHER EMPTY NOR LINKED ## +# Define filemanager directory and its backup +filemanagerdir=/usr/share/filemanager +filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") +if [ -d $filemanagerdir ]; then + # Backup then force symlink if directory exist but not empty and also not a link + if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp -R $filemanagerdir $filemanagerbakdir; fi + ln -sf $elfinderdir $filemanagerdir else - ln -sf $ef_main_dir $ef_fm_dir + ln -sf $elfinderdir $filemanagerdir fi ## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## -# Define conf folders, cat dummy files and other messages +# Define conf directories, cat dummy files and other messages confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install @@ -115,23 +106,23 @@ write_nginx_vhost () { # Define custom and apps vhost files appsvhost=/etc/nginx/sites-available/apps.vhost confvhost=nginx_apps.vhost.master - # Create conf-custom folder if it doesn't exist + # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy apps vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install folder + # Check conf-custom/install directory if [ ! -d $confcustominstalldir ]; then - # Force symlink to install folder, if it doesn't exist + # Force symlink to install directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink apps file from custom-conf to install folder + # Force symlink apps file from custom-conf to install directory ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom folder + # Go to the conf-custom directory cd $confcustomdir # Add content to the defined dummy file @@ -195,7 +186,7 @@ EOT fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $ef_stat_log $ef_extr_dir + rm -rf $catfile $status $extractdir # Reload nginx if all good and report result if nginx -t 2>/dev/null; then @@ -215,23 +206,23 @@ write_apache_vhost () { appsvhost=/etc/apache2/sites-available/ispconfig.conf basename=$(basename $appsvhost) confvhost=apache_ispconfig.conf.master - # Create conf-custom folder if it doesn't exist + # Create conf-custom directory if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy ispconfig vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install folder + # Check conf-custom/install directory if [ ! -d $confcustominstalldir ]; then - # Force symlink to install folder, if it doesn't exist + # Force symlink to install directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink ispconfig file from custom-conf to install folder + # Force symlink ispconfig file from custom-conf to install directory ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom folder + # Go to the conf-custom directory cd $confcustomdir # Add content to the defined dummy file @@ -356,7 +347,7 @@ END if [ ! -f $elfinderedir/$elfinderconf ]; then a2enconf filemanager; fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $catfile2 $ef_stat_log $ef_extr_dir + rm -rf $catfile $catfile2 $status $extractdir # Reload apache2 if all good and report result if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then -- GitLab From da9932f6e852cd8f8cfd75bbb36e4b5c5020fc5c Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 02:33:43 +0000 Subject: [PATCH 067/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 43dc46a..079a9ac 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -189,9 +189,10 @@ EOT rm -rf $catfile $status $extractdir # Reload nginx if all good and report result + ef_port=$(grep -i "listen \*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "\nNginx "$success"\n\n"$browse"8081/filemanager" + echo -e "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" else echo -e "\nNginx "$failed"\n\n"$manual"" fi @@ -350,9 +351,10 @@ END rm -rf $catfile $catfile2 $status $extractdir # Reload apache2 if all good and report result + ef_port=$(grep -i "listen \*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then systemctl reload apache2 - echo -e "\nApache2 "$success"\n\n"$browse"8080/filemanager" + echo -e "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" else echo -e "\nApache2 "$failed"\n\n"$manual"" fi -- GitLab From d9aa3dd93b6200c394d553001bd215c834299bbd Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 02:39:45 +0000 Subject: [PATCH 068/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 079a9ac..1142168 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -2,7 +2,7 @@ # Name: elfinder_install_update.sh # Description: Install or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail -# Updated on 20230916-103205 +# Updated on 20230918-103930 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install # Define elfinder and its extract dir @@ -351,7 +351,8 @@ END rm -rf $catfile $catfile2 $status $extractdir # Reload apache2 if all good and report result - ef_port=$(grep -i "listen \*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) + ispcvhost=/etc/apache2/sites-available/ispconfig.vhost + ef_port=$(grep -i "listen \*:" $ispcvhost | cut -d : -f 2,3 | cut -d " " -f1) if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then systemctl reload apache2 echo -e "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" -- GitLab From c5a825c9ee78dd61ad5d64c943974dc74d21a19a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 02:41:19 +0000 Subject: [PATCH 069/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 1142168..a6ce498 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -2,6 +2,7 @@ # Name: elfinder_install_update.sh # Description: Install or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail +# BSD 3 License # Updated on 20230918-103930 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install -- GitLab From 6542b7754a1b3393311b1299319b107dc02d6fcc Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 02:46:21 +0000 Subject: [PATCH 070/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index a6ce498..af658f4 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -98,7 +98,7 @@ failed="configuration test failed." manual="Please double check and manually fix the vhost file(s), if needed." browse="Your may now try browsing the elfinder file manager at \nhttps://$(hostname -f):" nosupport="You are not on a supported ISPConfig web server!" -previous="Previous install could have set this up." +previous="Previous install could have set this up BUT who knows!?" ooops="Something is wrong!" @@ -352,8 +352,7 @@ END rm -rf $catfile $catfile2 $status $extractdir # Reload apache2 if all good and report result - ispcvhost=/etc/apache2/sites-available/ispconfig.vhost - ef_port=$(grep -i "listen \*:" $ispcvhost | cut -d : -f 2,3 | cut -d " " -f1) + ef_port=$(grep -i "listen \*:" /etc/apache2/sites-available/ispconfig.vhost | cut -d : -f 2,3 | cut -d " " -f1) if AOUTPUT=$(/usr/sbin/apache2ctl -t 2>&1); then systemctl reload apache2 echo -e "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" -- GitLab From df3d6c07f0f3cd16b1b4edd07524bc12046847ef Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 02:54:49 +0000 Subject: [PATCH 071/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index af658f4..a45952b 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -190,7 +190,7 @@ EOT rm -rf $catfile $status $extractdir # Reload nginx if all good and report result - ef_port=$(grep -i "listen \*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) + ef_port=$(grep -i "\*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) if nginx -t 2>/dev/null; then systemctl reload nginx echo -e "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" @@ -352,7 +352,8 @@ END rm -rf $catfile $catfile2 $status $extractdir # Reload apache2 if all good and report result - ef_port=$(grep -i "listen \*:" /etc/apache2/sites-available/ispconfig.vhost | cut -d : -f 2,3 | cut -d " " -f1) + 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 "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" -- GitLab From 853ed8be86947774fb523a4ea21eaa16b1b68697 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 04:41:19 +0000 Subject: [PATCH 072/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 107 +++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index a45952b..836d2d9 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -3,71 +3,74 @@ # Description: Install or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail # BSD 3 License -# Updated on 20230918-103930 +# Updated on 20230918-124030 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install -# Define elfinder and its extract dir -elfinderdir=/usr/share/elfinder -extractdir=/tmp/elfinder + +# Always start working from /tmp folder, so no messing up +cd /tmp + +# Define latest elfinder source url, get its version and tar.gz file +ef_github_url=https://api.github.com/repos/Studio-42/elFinder/releases/latest +ef_latest_ver=$(curl -s $ef_github_url | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) +ef_tar_gz=https://github.com/Studio-42/elFinder/archive/$ef_latest_ver.tar.gz +# Define elfinder main & temp (extract) dir & temp log file +ef_main_dir=/usr/share/elfinder +ef_temp_dir=/tmp/elfinder +ef_temp_log=$ef_main_dir/ef_temp.log + get_elfinder () { - # Create extract dir if doesn't exist - if [ ! -d "$extractdir" ]; then mkdir -p $extractdir; fi - if [ ! -d "$elfinderdir" ]; then mkdir -p $elfinderdir; fi - # Go to the defined extract dir - cd $extractdir - # Download lattest elfinder package - wget https://github.com/Studio-42/elFinder/archive/$lattestversion.tar.gz - # Extract, overwriting current files and folders, if any, thus updating as well. - tar -xzf $lattestversion.tar.gz --strip-components=1 + # Create elfinder main and temp dir, if they don't exist + if [ ! -d "$ef_temp_dir" ]; then mkdir -p $ef_temp_dir; fi + if [ ! -d "$ef_main_dir" ]; then mkdir -p $ef_main_dir; fi + # Go to the temp extract dir, get latest elfinder & extract it + cd $ef_temp_dir && wget $ef_tar_gz && tar -xzf $ef_latest_ver.tar.gz --strip-components=1 # Make elfinder open full in browser sed -i "/defaultOpts/a \\\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false," elfinder.html - # Symlink, which is preferred rather than rename + # index.html is web server default, so symlink is preferred ln -sf elfinder.html index.html cp php/connector.minimal.php-dist php/connector.minimal.php - rm *.tar.gz - hasbeen="elFinder filemanager has been" + rm $ef_latest_ver.tar.gz } -# Define latest version and create status dummy file -lattestversion=$(curl -s https://api.github.com/repos/Studio-42/elFinder/releases/latest | grep "tag_name*" | cut -d : -f 2,3 | cut -d '"' -f2) -status=$elfinderdir/status.txt -if [ -d "$elfinderdir" ]; then - cd $elfinderdir - if [ -f "package.json" ]; then - currentversion=$(grep -i "version" package.json | cut -d : -f 2,3 | cut -d '"' -f2) - if [[ "$currentversion" == "$lattestversion" ]]; then - # Existing elfinder is up-to-date - echo "Existing install is up-to-date with the latest version of "$lattestversion"" >> $status - cat "$status" +# Function to install or update elFinder via overwriting +set_elfinder () { + if [ -d $ef_temp_dir ]; then + cp -R $ef_temp_dir/* $ef_main_dir + if [ -z "$ef_json" ]; then + echo -e ""$ef_exist" "$ef_curr_ver"\n"$ef_outdated" "$ef_late_ver"." | tee $ef_temp_log else - get_elfinder - if [ -d "$extractdir" ]; then - cp -R $extractdir/* $elfinderdir - echo "$hasbeen updated from version "$currentversion" to "$lattestversion"." >> $status - cat "$status" - else - echo "Failed. $extractdir is missing." - fi + echo -e ""$ef_none" "$ef_uptodate"" | tee $ef_temp_log fi else - get_elfinder - if [ -d "$extractdir" ]; then - cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version "$lattestversion"." >> $status - cat "$status" + echo $ef_failed + fi +} + +ef_exist="elFinder filemanager install exists with version" +ef_uptodate="It is up-to-date. Neither new install nor update is needed." +ef_outdated="This old insrall has been updated to latest version" +ef_none="We've setup new elFinder filemanager as none is found i.e. version" +ef_failed="Failed to download and install / download elFinder filemanager." + +if [ -d "$ef_main_dir" ]; then + ef_json=$ef_main_dir/package.json + if [ -f "$ef_json" ]; then + ef_setup_ver=$(grep -i "version" $ef_json | cut -d : -f 2,3 | cut -d '"' -f2) + if [[ "$ef_setup_ver" == "$ef_latest_ver" ]]; then + # Existing elFinder is up-to-date + echo -e ""$ef_exist" "$ef_late_ver".\n"$ef_uptodate"" | tee $ef_temp_log else - echo "Failed. $extractdir is missing." + get_elfinder + set_elfinder fi + else + get_elfinder + set_elfinder fi else get_elfinder - if [ -d "$extractdir" ]; then - cp -R $extractdir/* $elfinderdir - echo "$hasbeen installed with version "$lattestversion"." >> $status - cat "$status" - else - echo "Failed. $extractdir is missing." - fi + set_elfinder fi @@ -78,9 +81,9 @@ filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") if [ -d $filemanagerdir ]; then # Backup then force symlink if directory exist but not empty and also not a link if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp -R $filemanagerdir $filemanagerbakdir; fi - ln -sf $elfinderdir $filemanagerdir + ln -sf $ef_main_dir $filemanagerdir else - ln -sf $elfinderdir $filemanagerdir + ln -sf $ef_main_dir $filemanagerdir fi @@ -187,7 +190,7 @@ EOT fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $status $extractdir + rm -rf $catfile $ef_temp_log $ef_temp_dir # Reload nginx if all good and report result ef_port=$(grep -i "\*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) @@ -349,7 +352,7 @@ END if [ ! -f $elfinderedir/$elfinderconf ]; then a2enconf filemanager; fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $catfile2 $status $extractdir + rm -rf $catfile $catfile2 $ef_temp_log $ef_temp_dir # Reload apache2 if all good and report result ispcvhost=/etc/apache2/sites-available/ispconfig.vhost -- GitLab From 5602225d463a7cd49fc9cc38224e9749a399c74a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 04:46:32 +0000 Subject: [PATCH 073/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 836d2d9..c30edbc 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -1,6 +1,6 @@ #!/bin/bash # Name: elfinder_install_update.sh -# Description: Install or update elFinder File Manager in ISPConfig web server. +# Description: Setup or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail # BSD 3 License # Updated on 20230918-124030 @@ -33,12 +33,12 @@ get_elfinder () { rm $ef_latest_ver.tar.gz } -# Function to install or update elFinder via overwriting +# Function to setup or update elFinder via overwriting set_elfinder () { if [ -d $ef_temp_dir ]; then cp -R $ef_temp_dir/* $ef_main_dir if [ -z "$ef_json" ]; then - echo -e ""$ef_exist" "$ef_curr_ver"\n"$ef_outdated" "$ef_late_ver"." | tee $ef_temp_log + echo -e ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else echo -e ""$ef_none" "$ef_uptodate"" | tee $ef_temp_log fi @@ -47,11 +47,11 @@ set_elfinder () { fi } -ef_exist="elFinder filemanager install exists with version" -ef_uptodate="It is up-to-date. Neither new install nor update is needed." +ef_exist="elFinder filemanager setup exists with version" +ef_uptodate="It is up-to-date. Neither new setup nor update is needed." ef_outdated="This old insrall has been updated to latest version" ef_none="We've setup new elFinder filemanager as none is found i.e. version" -ef_failed="Failed to download and install / download elFinder filemanager." +ef_failed="Failed to download and setup / download elFinder filemanager." if [ -d "$ef_main_dir" ]; then ef_json=$ef_main_dir/package.json @@ -59,7 +59,7 @@ if [ -d "$ef_main_dir" ]; then ef_setup_ver=$(grep -i "version" $ef_json | cut -d : -f 2,3 | cut -d '"' -f2) if [[ "$ef_setup_ver" == "$ef_latest_ver" ]]; then # Existing elFinder is up-to-date - echo -e ""$ef_exist" "$ef_late_ver".\n"$ef_uptodate"" | tee $ef_temp_log + echo -e ""$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log else get_elfinder set_elfinder @@ -101,7 +101,7 @@ failed="configuration test failed." manual="Please double check and manually fix the vhost file(s), if needed." browse="Your may now try browsing the elfinder file manager at \nhttps://$(hostname -f):" nosupport="You are not on a supported ISPConfig web server!" -previous="Previous install could have set this up BUT who knows!?" +previous="Previous setup could have set this up BUT who knows!?" ooops="Something is wrong!" @@ -117,10 +117,10 @@ write_nginx_vhost () { cp $confdefaultdir/$confvhost $confcustomdir/ # Check conf-custom/install directory if [ ! -d $confcustominstalldir ]; then - # Force symlink to install directory, if it doesn't exist + # Force symlink to setup directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink apps file from custom-conf to install directory + # Force symlink apps file from custom-conf to setup directory ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi @@ -218,10 +218,10 @@ write_apache_vhost () { cp $confdefaultdir/$confvhost $confcustomdir/ # Check conf-custom/install directory if [ ! -d $confcustominstalldir ]; then - # Force symlink to install directory, if it doesn't exist + # Force symlink to setup directory, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink ispconfig file from custom-conf to install directory + # Force symlink ispconfig file from custom-conf to setup directory ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi -- GitLab From 6665b0ed2a85a091e766e7b6affd0937d7630859 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 04:50:07 +0000 Subject: [PATCH 074/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index c30edbc..beea74c 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -40,7 +40,7 @@ set_elfinder () { if [ -z "$ef_json" ]; then echo -e ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else - echo -e ""$ef_none" "$ef_uptodate"" | tee $ef_temp_log + echo -e ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log fi else echo $ef_failed -- GitLab From 1cec510a81b4647548dfc4d7859a99c6e0f6e292 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 04:54:43 +0000 Subject: [PATCH 075/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index beea74c..7f18ea2 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -37,7 +37,7 @@ get_elfinder () { set_elfinder () { if [ -d $ef_temp_dir ]; then cp -R $ef_temp_dir/* $ef_main_dir - if [ -z "$ef_json" ]; then + if [ ! -z "$ef_json" ]; then echo -e ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else echo -e ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log @@ -47,12 +47,14 @@ set_elfinder () { fi } +# Define setup / update messages ef_exist="elFinder filemanager setup exists with version" ef_uptodate="It is up-to-date. Neither new setup nor update is needed." ef_outdated="This old insrall has been updated to latest version" ef_none="We've setup new elFinder filemanager as none is found i.e. version" ef_failed="Failed to download and setup / download elFinder filemanager." +# We run elfinder setup / update here if it is not up-to-date if [ -d "$ef_main_dir" ]; then ef_json=$ef_main_dir/package.json if [ -f "$ef_json" ]; then -- GitLab From aa1e719036f99bcf2f4a8c5650f321ca484cc1c5 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 04:56:01 +0000 Subject: [PATCH 076/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 7f18ea2..896b4c1 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -50,7 +50,7 @@ set_elfinder () { # Define setup / update messages ef_exist="elFinder filemanager setup exists with version" ef_uptodate="It is up-to-date. Neither new setup nor update is needed." -ef_outdated="This old insrall has been updated to latest version" +ef_outdated="This old setup has been updated to latest version" ef_none="We've setup new elFinder filemanager as none is found i.e. version" ef_failed="Failed to download and setup / download elFinder filemanager." -- GitLab From 848fde9494d221559cae571df04ec8f4e17c5962 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 05:03:09 +0000 Subject: [PATCH 077/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 896b4c1..a93c407 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -24,7 +24,7 @@ get_elfinder () { if [ ! -d "$ef_temp_dir" ]; then mkdir -p $ef_temp_dir; fi if [ ! -d "$ef_main_dir" ]; then mkdir -p $ef_main_dir; fi # Go to the temp extract dir, get latest elfinder & extract it - cd $ef_temp_dir && wget $ef_tar_gz && tar -xzf $ef_latest_ver.tar.gz --strip-components=1 + cd $ef_temp_dir && wget -q --show-progress $ef_tar_gz && tar -xzf $ef_latest_ver.tar.gz --strip-components=1 # Make elfinder open full in browser sed -i "/defaultOpts/a \\\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '99.7%',\n\t\t\t\t\tresizable: false," elfinder.html # index.html is web server default, so symlink is preferred -- GitLab From ff75c33d19698bbb1bc4646fb58c5999c66771a8 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 05:06:47 +0000 Subject: [PATCH 078/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index a93c407..99a36aa 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -38,9 +38,9 @@ set_elfinder () { if [ -d $ef_temp_dir ]; then cp -R $ef_temp_dir/* $ef_main_dir if [ ! -z "$ef_json" ]; then - echo -e ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log + echo -ne ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else - echo -e ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log + echo -ne ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log fi else echo $ef_failed @@ -61,7 +61,7 @@ if [ -d "$ef_main_dir" ]; then ef_setup_ver=$(grep -i "version" $ef_json | cut -d : -f 2,3 | cut -d '"' -f2) if [[ "$ef_setup_ver" == "$ef_latest_ver" ]]; then # Existing elFinder is up-to-date - echo -e ""$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log + echo -ne ""$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log else get_elfinder set_elfinder @@ -172,23 +172,23 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" + echo -ne "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/location \/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi + if grep -q "filemanager" $confvhost; then echo -ne "\n"$added" "$confvhost" file."; else echo -ne "\n"$ooops" "$manual"" && exit; fi fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo -e "\n"$exist" "$appsvhost" file.\n"$previous"\n"$manual"" + echo -ne "\n"$exist" "$appsvhost" file.\n"$previous"\n"$manual"" # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$appsvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi + if grep -q "filemanager" $appsvhost; then echo -ne "\n"$added" "$appsvhost" file."; else echo -ne "\n"$ooops" "$manual"" && exit; fi fi # Both vhosts modifications are done. Remove the unneeded files @@ -198,9 +198,9 @@ EOT ef_port=$(grep -i "\*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" + echo -ne "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" else - echo -e "\nNginx "$failed"\n\n"$manual"" + echo -ne "\nNginx "$failed"\n\n"$manual"" fi fi @@ -251,11 +251,11 @@ END # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" + echo -ne "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/\/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi + if grep -q "filemanager" $confvhost; then echo -ne "\n"$added" "$confvhost" file."; else echo -ne "\n"$ooops" "$manual"" && exit; fi fi tee $catfile2 >/dev/null << END @@ -271,11 +271,11 @@ END # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo -e "\n"$exist" "$basename" file.\n"$previous"\n"$manual"\n" + echo -ne "\n"$exist" "$basename" file.\n"$previous"\n"$manual"\n" # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else sed -i "/\/squirrelmail/e cat $catfile2" $appsvhost - if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$basename" file.\n"; else echo -e "\n"$ooops" "$manual"\n" && exit; fi + if grep -q "filemanager" $appsvhost; then echo -ne "\n"$added" "$basename" file.\n"; else echo -ne "\n"$ooops" "$manual"\n" && exit; fi fi @@ -361,9 +361,9 @@ END 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 "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" + echo -ne "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" else - echo -e "\nApache2 "$failed"\n\n"$manual"" + echo -ne "\nApache2 "$failed"\n\n"$manual"" fi fi } -- GitLab From f5ff6c592c10f3d4453de8885c4556715eeb4da5 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 05:20:53 +0000 Subject: [PATCH 079/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 86 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 99a36aa..3a53909 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -3,10 +3,12 @@ # Description: Setup or update elFinder File Manager in ISPConfig web server. # Author: Hj Ahmad Rasyid bin Hj Ismail # BSD 3 License -# Updated on 20230918-124030 +# Updated on 20230918-132030 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install +## SETUP / UPDATE ELFINDER AS ISPCONFIG FILE MANAGER + # Always start working from /tmp folder, so no messing up cd /tmp @@ -19,6 +21,7 @@ ef_main_dir=/usr/share/elfinder ef_temp_dir=/tmp/elfinder ef_temp_log=$ef_main_dir/ef_temp.log +# Function to download and extract latest elFinder get_elfinder () { # Create elfinder main and temp dir, if they don't exist if [ ! -d "$ef_temp_dir" ]; then mkdir -p $ef_temp_dir; fi @@ -33,35 +36,35 @@ get_elfinder () { rm $ef_latest_ver.tar.gz } -# Function to setup or update elFinder via overwriting +# Function to setup elFinder or update (overwrite) set_elfinder () { if [ -d $ef_temp_dir ]; then cp -R $ef_temp_dir/* $ef_main_dir if [ ! -z "$ef_json" ]; then - echo -ne ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log + echo -e ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else - echo -ne ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log + echo -e ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log fi else echo $ef_failed fi } -# Define setup / update messages +# Define elFinder setup / update messages ef_exist="elFinder filemanager setup exists with version" ef_uptodate="It is up-to-date. Neither new setup nor update is needed." ef_outdated="This old setup has been updated to latest version" ef_none="We've setup new elFinder filemanager as none is found i.e. version" ef_failed="Failed to download and setup / download elFinder filemanager." -# We run elfinder setup / update here if it is not up-to-date +# Run elFinder setup / update here if it is not up-to-date if [ -d "$ef_main_dir" ]; then ef_json=$ef_main_dir/package.json if [ -f "$ef_json" ]; then ef_setup_ver=$(grep -i "version" $ef_json | cut -d : -f 2,3 | cut -d '"' -f2) if [[ "$ef_setup_ver" == "$ef_latest_ver" ]]; then # Existing elFinder is up-to-date - echo -ne ""$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log + echo -e ""$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log else get_elfinder set_elfinder @@ -75,22 +78,21 @@ else set_elfinder fi - -## FILE MANAGER CREATE OR OVERWRITE, THUS TO BACKUP IF EXIST AND IS NEITHER EMPTY NOR LINKED ## -# Define filemanager directory and its backup -filemanagerdir=/usr/share/filemanager -filemanagerbakdir=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") -if [ -d $filemanagerdir ]; then - # Backup then force symlink if directory exist but not empty and also not a link - if [ ! -z $filemanagerdir ] || [ ! -L $filemanagerdir ]; then cp -R $filemanagerdir $filemanagerbakdir; fi - ln -sf $ef_main_dir $filemanagerdir +# Define filemanager folder and its backup +ef_fm_dir=/usr/share/filemanager +ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") +if [ -d $ef_fm_dir ]; then + # Backup then force symlink if folder exist but not empty and also not a link + if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak; fi + ln -sf $ef_main_dir $ef_fm_dir else - ln -sf $ef_main_dir $filemanagerdir + ln -sf $ef_main_dir $ef_fm_dir fi -## ADD IF CONFIG DOESN'T EXIST IN ISPCONFIG VHOST ## -# Define conf directories, cat dummy files and other messages +## ADD CONFIGS IF THEY DON'T EXIST IN VHOST & CONF FILES + +# Define conf folders, cat dummy files and other messages confdefaultdir=/usr/local/ispconfig/server/conf confcustomdir=/usr/local/ispconfig/server/conf-custom confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install @@ -112,23 +114,23 @@ write_nginx_vhost () { # Define custom and apps vhost files appsvhost=/etc/nginx/sites-available/apps.vhost confvhost=nginx_apps.vhost.master - # Create conf-custom directory if it doesn't exist + # Create conf-custom folder if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy apps vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install directory + # Check conf-custom/install folder if [ ! -d $confcustominstalldir ]; then - # Force symlink to setup directory, if it doesn't exist + # Force symlink to setup folder, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink apps file from custom-conf to setup directory + # Force symlink apps file from custom-conf to setup folder ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom directory + # Go to the conf-custom folder cd $confcustomdir # Add content to the defined dummy file @@ -172,23 +174,23 @@ EOT # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo -ne "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/location \/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo -ne "\n"$added" "$confvhost" file."; else echo -ne "\n"$ooops" "$manual"" && exit; fi + if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi fi # Then search for filemanager in the apps vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo -ne "\n"$exist" "$appsvhost" file.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$appsvhost" file.\n"$previous"\n"$manual"" # Finally, if it is safe, modify the apps vhost file, with some edits for it to work else sed -i 's/{use_tcp}/#/g' $catfile phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo -ne "\n"$added" "$appsvhost" file."; else echo -ne "\n"$ooops" "$manual"" && exit; fi + if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$appsvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi fi # Both vhosts modifications are done. Remove the unneeded files @@ -198,9 +200,9 @@ EOT ef_port=$(grep -i "\*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) if nginx -t 2>/dev/null; then systemctl reload nginx - echo -ne "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" + echo -e "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" else - echo -ne "\nNginx "$failed"\n\n"$manual"" + echo -e "\nNginx "$failed"\n\n"$manual"" fi fi @@ -213,23 +215,23 @@ write_apache_vhost () { appsvhost=/etc/apache2/sites-available/ispconfig.conf basename=$(basename $appsvhost) confvhost=apache_ispconfig.conf.master - # Create conf-custom directory if it doesn't exist + # Create conf-custom folder if it doesn't exist if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi # Copy ispconfig vhost from conf to conf-custom if it doesn't exist if [ ! -f $confcustomdir/$confvhost ]; then cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install directory + # Check conf-custom/install folder if [ ! -d $confcustominstalldir ]; then - # Force symlink to setup directory, if it doesn't exist + # Force symlink to setup folder, if it doesn't exist ln -sf $confcustomdir $confcustominstalldir else - # Force symlink ispconfig file from custom-conf to setup directory + # Force symlink ispconfig file from custom-conf to setup folder ln -sf $confcustomdir/$confvhost $confcustominstalldir/ fi fi if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom directory + # Go to the conf-custom folder cd $confcustomdir # Add content to the defined dummy file @@ -251,11 +253,11 @@ END # Search for filemanager in the conf vhost file if grep -q "filemanager" $confvhost; then - echo -ne "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" + echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" else # First modify the conf vhost file and report result sed -i "/\/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo -ne "\n"$added" "$confvhost" file."; else echo -ne "\n"$ooops" "$manual"" && exit; fi + if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi fi tee $catfile2 >/dev/null << END @@ -271,11 +273,11 @@ END # Then search for filemanager in the ISPConfig vhost file, before we proceed further if grep -q "filemanager" $appsvhost; then - echo -ne "\n"$exist" "$basename" file.\n"$previous"\n"$manual"\n" + echo -e "\n"$exist" "$basename" file.\n"$previous"\n"$manual"\n" # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else sed -i "/\/squirrelmail/e cat $catfile2" $appsvhost - if grep -q "filemanager" $appsvhost; then echo -ne "\n"$added" "$basename" file.\n"; else echo -ne "\n"$ooops" "$manual"\n" && exit; fi + if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$basename" file.\n"; else echo -e "\n"$ooops" "$manual"\n" && exit; fi fi @@ -290,7 +292,7 @@ Alias /filemanager /usr/share/filemanager Options FollowSymLinks - DirectoryIndex index.html + folderIndex index.html AllowOverride All @@ -361,9 +363,9 @@ END 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 -ne "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" + echo -e "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" else - echo -ne "\nApache2 "$failed"\n\n"$manual"" + echo -e "\nApache2 "$failed"\n\n"$manual"" fi fi } -- GitLab From 1d353103b9d7b7039b8302610cded43dbfed9be1 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 05:26:47 +0000 Subject: [PATCH 080/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 112 ++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 3a53909..56c05e1 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -291,66 +291,66 @@ END Alias /filemanager /usr/share/filemanager - Options FollowSymLinks - folderIndex index.html - - AllowOverride All - - = 2.3> - Require all granted - - - - Order allow,deny - Allow from all - - - # Clear PHP settings of this website - # - # SetHandler None - # - - Require all granted - - - - - - - SetHandler php-fcgi - - - - - - - - SetHandler php-fcgi - - - - - Action php-fcgi /php-fcgi virtual - - - - - Header set Content-Security-Policy "script-src 'self' https://cdnjs.cloudflare.com/" - Header set Content-Security-Policy "img-src 'self'" - - - - AddType application/x-httpd-php .php - php_flag magic_quotes_gpc Off - php_flag track_vars On - php_flag register_globals Off - php_value include_path . - + Options FollowSymLinks + DirectoryIndex index.html + + AllowOverride All + + = 2.3> + Require all granted + + + + Order allow,deny + Allow from all + + + # Clear PHP settings of this website + # + # SetHandler None + # + + Require all granted + + + + + + + SetHandler php-fcgi + + + + + + + + SetHandler php-fcgi + + + + + Action php-fcgi /php-fcgi virtual + + + + + Header set Content-Security-Policy "script-src 'self' https://cdnjs.cloudflare.com/" + Header set Content-Security-Policy "img-src 'self'" + + + + AddType application/x-httpd-php .php + php_flag magic_quotes_gpc Off + php_flag track_vars On + php_flag register_globals Off + php_value include_path . + - SSLStaplingCache shmcb:/var/run/ocsp(128000) + SSLStaplingCache shmcb:/var/run/ocsp(128000) END -- GitLab From ede43356a2425f9cf8a493c481fbdc1917f20f97 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:19:04 +0000 Subject: [PATCH 081/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 207 ++++++++++++++++++++----------------- 1 file changed, 115 insertions(+), 92 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 56c05e1..676c3cb 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 20230918-132030 +# Updated on 20230918-151830 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install @@ -19,7 +19,7 @@ ef_tar_gz=https://github.com/Studio-42/elFinder/archive/$ef_latest_ver.tar.gz # Define elfinder main & temp (extract) dir & temp log file ef_main_dir=/usr/share/elfinder ef_temp_dir=/tmp/elfinder -ef_temp_log=$ef_main_dir/ef_temp.log +ef_temp_log=$ef_main_dir/ef-temp.log # Function to download and extract latest elFinder get_elfinder () { @@ -78,7 +78,7 @@ else set_elfinder fi -# Define filemanager folder and its backup +# Define filemanager folder and its backup, backup if needed, then force create its symlink ef_fm_dir=/usr/share/filemanager ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") if [ -d $ef_fm_dir ]; then @@ -93,51 +93,47 @@ fi ## ADD CONFIGS IF THEY DON'T EXIST IN VHOST & CONF FILES # Define conf folders, cat dummy files and other messages -confdefaultdir=/usr/local/ispconfig/server/conf -confcustomdir=/usr/local/ispconfig/server/conf-custom -confcustominstalldir=/usr/local/ispconfig/server/conf-custom/install -catfile=elfinder_cat.txt -catfile2=elfinder_cat2.txt -exist="Not overwriting as string (filemanager) exists in the" -added="Added elFinder filemanager config successfully in the" -success="has been successfully reloaded." -failed="configuration test failed." -manual="Please double check and manually fix the vhost file(s), if needed." -browse="Your may now try browsing the elfinder file manager at \nhttps://$(hostname -f):" -nosupport="You are not on a supported ISPConfig web server!" -previous="Previous setup could have set this up BUT who knows!?" -ooops="Something is wrong!" +ispc_conf_dir=/usr/local/ispconfig/server/conf +ispc_custom_dir=/usr/local/ispconfig/server/conf-custom +ispc_install_dir=/usr/local/ispconfig/server/conf-custom/install +ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) +ef_temp_conf=ef-temp.conf +ef_temp_conf2=elfinder_cat2.txt +ef_word="filemanager" +ef_exist="Not overwriting as string (filemanager) exists in the" +ef_added="Added elFinder filemanager config successfully in the" +ef_reload="has been successfully reloaded." +ef_failed="configuration test failed." +ef_manual="Please double check and manually fix the vhost file(s), if needed." +ef_browse="Your may now try browsing the elfinder file manager at \nhttps://$(hostname -f):" +ef_nosupport="You are not on a supported ISPConfig web server!" +ef_old_setup="Previous setup could have set this up BUT who knows!?" +ef_oops="Something is wrong!" - -# Nginx write to custom and apps vhost files function -write_nginx_vhost () { - # Define custom and apps vhost files - appsvhost=/etc/nginx/sites-available/apps.vhost - confvhost=nginx_apps.vhost.master - # Create conf-custom folder if it doesn't exist - if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi - # Copy apps vhost from conf to conf-custom if it doesn't exist - if [ ! -f $confcustomdir/$confvhost ]; then - cp $confdefaultdir/$confvhost $confcustomdir/ - # Check conf-custom/install folder - if [ ! -d $confcustominstalldir ]; then - # Force symlink to setup folder, if it doesn't exist - ln -sf $confcustomdir $confcustominstalldir +# Function to download and extract latest elFinder +set_custom_conf () { + # Create conf-custom directory if it doesn't exist + if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi + # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist + if [ ! -f $ispc_custom_dir/$master_vhost ]; then + cp $ispc_conf_dir/$master_vhost $ispc_custom_dir/ + # Check conf-custom/install directory + if [ ! -d $isp_cust_inst_dir ]; then + # Force symlink to install directory, if it doesn't exist + ln -sf $ispc_custom_dir $isp_cust_inst_dir else - # Force symlink apps file from custom-conf to setup folder - ln -sf $confcustomdir/$confvhost $confcustominstalldir/ + # Force symlink apps file from custom-conf to install directory + ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ fi fi - - if [ -f $confcustomdir/$confvhost ]; then - # Go to the conf-custom folder - cd $confcustomdir +} - # Add content to the defined dummy file - cat <<"EOT" > $catfile +# Create nginx config +nginx_create_conf () { + cat <<"EOT" > $ef_temp_conf - ## ELFINDER FILE MANAGER ## + ## ELFINDER FILE MANAGER CONFIG STARTS ## location /filemanager { root /usr/share/; @@ -168,41 +164,68 @@ write_nginx_vhost () { location /file { rewrite ^/* /filemanager last; } + + ## ELFINDER FILE MANAGER CONFIG STARTS ## EOT - # Search for filemanager in the conf vhost file - if grep -q "filemanager" $confvhost; then - echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" - else - # First modify the conf vhost file and report result - sed -i "/location \/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi - fi - - # Then search for filemanager in the apps vhost file, before we proceed further - if grep -q "filemanager" $appsvhost; then - echo -e "\n"$exist" "$appsvhost" file.\n"$previous"\n"$manual"" - # Finally, if it is safe, modify the apps vhost file, with some edits for it to work - else - sed -i 's/{use_tcp}/#/g' $catfile - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\$phpfpm;" $catfile - sed -i "/location \/squirrelmail/e cat $catfile" $appsvhost - if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$appsvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi - fi - - # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $ef_temp_log $ef_temp_dir +# Function to add config in the custom-conf master file +master_add_conf () { + if grep -q $ef_word $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + else + # First modify the conf vhost file and report result + sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + fi +} + +# Function to add config in the custom-conf target file +target_add_conf () { + # Then search for filemanager in the vhost / conf file, before we proceed further + if grep -q $ef_word $target_vhost; then + echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" + # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work + else + # Change for nginx only output to dev null + sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 + + # Change for both nginx and apache + sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost + if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + fi + + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir +} + +# Nginx write to custom and apps vhost files function +write_nginx_vhost () { + # Define nginx master & target files & edit string + master_vhost=nginx_apps.vhost.master + target_vhost=/etc/nginx/sites-available/apps.vhost + target_base=$(basename $target_vhost) + sm_search="location \/squirrelmail" + + set_custom_conf + + if [ -f $ispc_custom_dir/$master_vhost ]; then + # Go to the conf-custom folder + cd $ispc_custom_dir + + nginx_create_conf + master_add_conf + target_add_conf # Reload nginx if all good and report result - ef_port=$(grep -i "\*:" $appsvhost | cut -d : -f 2,3 | cut -d " " -f1) if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "\nNginx "$success"\n\n"$browse""$ef_port"/filemanager" + echo -e "\nNginx "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager" else - echo -e "\nNginx "$failed"\n\n"$manual"" + echo -e "\nNginx "$ef_failed"\n\n"$ef_manual"" fi fi @@ -212,30 +235,30 @@ EOT # Apache write to custom and ispconfig vhost files function write_apache_vhost () { # Define custom and ispconfig vhost files - appsvhost=/etc/apache2/sites-available/ispconfig.conf - basename=$(basename $appsvhost) - confvhost=apache_ispconfig.conf.master + target_vhost=/etc/apache2/sites-available/ispconfig.conf + basename=$(basename $target_vhost) + master_vhost=apache_ispconfig.conf.master # Create conf-custom folder if it doesn't exist - if [ ! -d $confcustomdir ]; then mkdir -p $confcustomdir; fi + if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi # Copy ispconfig vhost from conf to conf-custom if it doesn't exist - if [ ! -f $confcustomdir/$confvhost ]; then - cp $confdefaultdir/$confvhost $confcustomdir/ + if [ ! -f $ispc_custom_dir/$master_vhost ]; then + cp $ispc_conf_dir/$master_vhost $ispc_custom_dir/ # Check conf-custom/install folder - if [ ! -d $confcustominstalldir ]; then + if [ ! -d $ispc_install_dir ]; then # Force symlink to setup folder, if it doesn't exist - ln -sf $confcustomdir $confcustominstalldir + ln -sf $ispc_custom_dir $ispc_install_dir else # Force symlink ispconfig file from custom-conf to setup folder - ln -sf $confcustomdir/$confvhost $confcustominstalldir/ + ln -sf $ispc_custom_dir/$master_vhost $ispc_install_dir/ fi fi - if [ -f $confcustomdir/$confvhost ]; then + if [ -f $ispc_custom_dir/$master_vhost ]; then # Go to the conf-custom folder - cd $confcustomdir + cd $ispc_custom_dir # Add content to the defined dummy file - tee $catfile >/dev/null << END + tee $ef_temp_conf >/dev/null << END ## ELFINDER FILE MANAGER ## @@ -252,15 +275,15 @@ write_apache_vhost () { END # Search for filemanager in the conf vhost file - if grep -q "filemanager" $confvhost; then - echo -e "\n"$exist" "$confvhost" file.\n"$previous"\n"$manual"" + if grep -q "filemanager" $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else # First modify the conf vhost file and report result - sed -i "/\/squirrelmail/e cat $catfile" $confvhost - if grep -q "filemanager" $confvhost; then echo -e "\n"$added" "$confvhost" file."; else echo -e "\n"$ooops" "$manual"" && exit; fi + sed -i "/\/squirrelmail/e cat $ef_temp_conf" $master_vhost + if grep -q "filemanager" $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi fi - tee $catfile2 >/dev/null << END + tee $ef_temp_conf2 >/dev/null << END ## ELFINDER FILE MANAGER ## @@ -272,12 +295,12 @@ END END # Then search for filemanager in the ISPConfig vhost file, before we proceed further - if grep -q "filemanager" $appsvhost; then - echo -e "\n"$exist" "$basename" file.\n"$previous"\n"$manual"\n" + if grep -q "filemanager" $target_vhost; then + echo -e "\n"$ef_exist" "$basename" file.\n"$ef_old_setup"\n"$ef_manual"\n" # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work else - sed -i "/\/squirrelmail/e cat $catfile2" $appsvhost - if grep -q "filemanager" $appsvhost; then echo -e "\n"$added" "$basename" file.\n"; else echo -e "\n"$ooops" "$manual"\n" && exit; fi + sed -i "/\/squirrelmail/e cat $ef_temp_conf2" $target_vhost + if grep -q "filemanager" $target_vhost; then echo -e "\n"$ef_added" "$basename" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi fi @@ -356,16 +379,16 @@ END if [ ! -f $elfinderedir/$elfinderconf ]; then a2enconf filemanager; fi # Both vhosts modifications are done. Remove the unneeded files - rm -rf $catfile $catfile2 $ef_temp_log $ef_temp_dir + rm -rf $ef_temp_conf $ef_temp_conf2 $ef_temp_log $ef_temp_dir # 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 "\nApache2 "$success"\n\n"$browse""$ef_port"/filemanager" + echo -e "\nApache2 "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager" else - echo -e "\nApache2 "$failed"\n\n"$manual"" + echo -e "\nApache2 "$ef_failed"\n\n"$ef_manual"" fi fi } @@ -390,5 +413,5 @@ elif which yum &> /dev/null 2>&1; then write_apache_vhost fi else - echo $nosupport + echo $ef_nosupport fi -- GitLab From fe528e4165b72fdf408053a4e8f431a436f602e2 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:22:35 +0000 Subject: [PATCH 082/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 676c3cb..a53b996 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -96,7 +96,6 @@ fi ispc_conf_dir=/usr/local/ispconfig/server/conf ispc_custom_dir=/usr/local/ispconfig/server/conf-custom ispc_install_dir=/usr/local/ispconfig/server/conf-custom/install -ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) ef_temp_conf=ef-temp.conf ef_temp_conf2=elfinder_cat2.txt ef_word="filemanager" @@ -208,6 +207,7 @@ write_nginx_vhost () { master_vhost=nginx_apps.vhost.master target_vhost=/etc/nginx/sites-available/apps.vhost target_base=$(basename $target_vhost) + ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) sm_search="location \/squirrelmail" set_custom_conf -- GitLab From fdae4bb4c6d3e3f0a0b0777bcdb3a21c39a81b2b Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:24:07 +0000 Subject: [PATCH 083/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index a53b996..e10a2a6 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -96,6 +96,7 @@ fi ispc_conf_dir=/usr/local/ispconfig/server/conf ispc_custom_dir=/usr/local/ispconfig/server/conf-custom ispc_install_dir=/usr/local/ispconfig/server/conf-custom/install +ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) ef_temp_conf=ef-temp.conf ef_temp_conf2=elfinder_cat2.txt ef_word="filemanager" @@ -168,6 +169,7 @@ nginx_create_conf () { EOT +} # Function to add config in the custom-conf master file master_add_conf () { @@ -207,7 +209,6 @@ write_nginx_vhost () { master_vhost=nginx_apps.vhost.master target_vhost=/etc/nginx/sites-available/apps.vhost target_base=$(basename $target_vhost) - ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) sm_search="location \/squirrelmail" set_custom_conf -- GitLab From 60962651e43a8f43943af5fd4fbc41d5a0bbac27 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:26:46 +0000 Subject: [PATCH 084/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index e10a2a6..f4c3ba7 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -218,8 +218,31 @@ write_nginx_vhost () { cd $ispc_custom_dir nginx_create_conf - master_add_conf - target_add_conf + if grep -q $ef_word $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + else + # First modify the conf vhost file and report result + sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + fi + + # Then search for filemanager in the vhost / conf file, before we proceed further + if grep -q $ef_word $target_vhost; then + echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" + # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work + else + # Change for nginx only output to dev null + sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 + + # Change for both nginx and apache + sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost + if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + fi + + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir # Reload nginx if all good and report result if nginx -t 2>/dev/null; then -- GitLab From 88ec03a1f6912fbe77a012a63e26594cc34b45e6 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:29:11 +0000 Subject: [PATCH 085/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index f4c3ba7..f4d6381 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -211,13 +211,27 @@ write_nginx_vhost () { target_base=$(basename $target_vhost) sm_search="location \/squirrelmail" - set_custom_conf + # Create conf-custom directory if it doesn't exist + if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi + # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist + if [ ! -f $ispc_custom_dir/$master_vhost ]; then + cp $ispc_conf_dir/$master_vhost $ispc_custom_dir/ + # Check conf-custom/install directory + if [ ! -d $isp_cust_inst_dir ]; then + # Force symlink to install directory, if it doesn't exist + ln -sf $ispc_custom_dir $isp_cust_inst_dir + else + # Force symlink apps file from custom-conf to install directory + ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ + fi + fi if [ -f $ispc_custom_dir/$master_vhost ]; then # Go to the conf-custom folder cd $ispc_custom_dir nginx_create_conf + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else -- GitLab From 7243ea48969a6ac3561522e0b5cbd941b7036461 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:31:17 +0000 Subject: [PATCH 086/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index f4d6381..f2665c3 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -230,7 +230,45 @@ write_nginx_vhost () { # Go to the conf-custom folder cd $ispc_custom_dir - nginx_create_conf + cat <<"EOT" > $ef_temp_conf + + + ## ELFINDER FILE MANAGER CONFIG STARTS ## + + location /filemanager { + root /usr/share/; + index index.php index.html index.htm; + location ~ ^/filemanager/(.+\.php)$ { + try_files $uri =404; + root /usr/share/; + include /etc/nginx/fastcgi_params; + + # To access filemanager, create ftp users in ISPConfig UI + {use_tcp}fastcgi_pass 127.0.0.1:9000; + {use_socket}fastcgi_pass unix:{fpm_socket}; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_buffer_size 128k; + fastcgi_buffers 256 4k; + fastcgi_busy_buffers_size 256k; + fastcgi_temp_file_write_size 256k; + fastcgi_read_timeout 1200; + } + location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { + root /usr/share/; + access_log off; + log_not_found off; + expires max; + } + } + location /file { + rewrite ^/* /filemanager last; + } + + ## ELFINDER FILE MANAGER CONFIG STARTS ## + + +EOT if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" -- GitLab From 8efd0533f661ae640fa1511c5d4cf464549935c4 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:33:34 +0000 Subject: [PATCH 087/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 93 -------------------------------------- 1 file changed, 93 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index f2665c3..9ecf08b 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -110,99 +110,6 @@ ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" -# Function to download and extract latest elFinder -set_custom_conf () { - # Create conf-custom directory if it doesn't exist - if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi - # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist - if [ ! -f $ispc_custom_dir/$master_vhost ]; then - cp $ispc_conf_dir/$master_vhost $ispc_custom_dir/ - # Check conf-custom/install directory - if [ ! -d $isp_cust_inst_dir ]; then - # Force symlink to install directory, if it doesn't exist - ln -sf $ispc_custom_dir $isp_cust_inst_dir - else - # Force symlink apps file from custom-conf to install directory - ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ - fi - fi -} - -# Create nginx config -nginx_create_conf () { - cat <<"EOT" > $ef_temp_conf - - - ## ELFINDER FILE MANAGER CONFIG STARTS ## - - location /filemanager { - root /usr/share/; - index index.php index.html index.htm; - location ~ ^/filemanager/(.+\.php)$ { - try_files $uri =404; - root /usr/share/; - include /etc/nginx/fastcgi_params; - - # To access filemanager, create ftp users in ISPConfig UI - {use_tcp}fastcgi_pass 127.0.0.1:9000; - {use_socket}fastcgi_pass unix:{fpm_socket}; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_buffer_size 128k; - fastcgi_buffers 256 4k; - fastcgi_busy_buffers_size 256k; - fastcgi_temp_file_write_size 256k; - fastcgi_read_timeout 1200; - } - location ~* ^/filemanager/(.+\.(ogg|ogv|svg|svgz|eot|ttf|otf|woff|woff2|mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|html|xml|txt|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)(\?ver=[0-9.]+)?$) { - root /usr/share/; - access_log off; - log_not_found off; - expires max; - } - } - location /file { - rewrite ^/* /filemanager last; - } - - ## ELFINDER FILE MANAGER CONFIG STARTS ## - - -EOT -} - -# Function to add config in the custom-conf master file -master_add_conf () { - if grep -q $ef_word $master_vhost; then - echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - else - # First modify the conf vhost file and report result - sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost - if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - fi -} - -# Function to add config in the custom-conf target file -target_add_conf () { - # Then search for filemanager in the vhost / conf file, before we proceed further - if grep -q $ef_word $target_vhost; then - echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" - # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work - else - # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 - - # Change for both nginx and apache - sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost - if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - fi - - # All modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir -} - # Nginx write to custom and apps vhost files function write_nginx_vhost () { # Define nginx master & target files & edit string -- GitLab From 44258521e26f4e15c08158853f88f5a8cc00ca8b Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:35:52 +0000 Subject: [PATCH 088/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 9ecf08b..3712cdf 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -77,7 +77,7 @@ else get_elfinder set_elfinder fi - +echo "0" # Define filemanager folder and its backup, backup if needed, then force create its symlink ef_fm_dir=/usr/share/filemanager ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") @@ -85,9 +85,12 @@ if [ -d $ef_fm_dir ]; then # Backup then force symlink if folder exist but not empty and also not a link if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak; fi ln -sf $ef_main_dir $ef_fm_dir + echo "1" else ln -sf $ef_main_dir $ef_fm_dir + echo "2" fi +echo "3" ## ADD CONFIGS IF THEY DON'T EXIST IN VHOST & CONF FILES @@ -109,6 +112,7 @@ ef_browse="Your may now try browsing the elfinder file manager at \nhttps://$(ho ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" +echo "4" # Nginx write to custom and apps vhost files function write_nginx_vhost () { -- GitLab From 951cc6c91b0905652b1d34411a4e6cd59d7dc63e Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:37:18 +0000 Subject: [PATCH 089/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 3712cdf..95e5ddf 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -99,7 +99,6 @@ echo "3" ispc_conf_dir=/usr/local/ispconfig/server/conf ispc_custom_dir=/usr/local/ispconfig/server/conf-custom ispc_install_dir=/usr/local/ispconfig/server/conf-custom/install -ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) ef_temp_conf=ef-temp.conf ef_temp_conf2=elfinder_cat2.txt ef_word="filemanager" @@ -120,6 +119,7 @@ write_nginx_vhost () { master_vhost=nginx_apps.vhost.master target_vhost=/etc/nginx/sites-available/apps.vhost target_base=$(basename $target_vhost) + ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) sm_search="location \/squirrelmail" # Create conf-custom directory if it doesn't exist -- GitLab From b59115fb3085f8d6ae3bce188e9aa190dd117f3f Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:42:26 +0000 Subject: [PATCH 090/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 95e5ddf..ae9622d 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -77,7 +77,7 @@ else get_elfinder set_elfinder fi -echo "0" + # Define filemanager folder and its backup, backup if needed, then force create its symlink ef_fm_dir=/usr/share/filemanager ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") @@ -85,12 +85,9 @@ if [ -d $ef_fm_dir ]; then # Backup then force symlink if folder exist but not empty and also not a link if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak; fi ln -sf $ef_main_dir $ef_fm_dir - echo "1" else ln -sf $ef_main_dir $ef_fm_dir - echo "2" fi -echo "3" ## ADD CONFIGS IF THEY DON'T EXIST IN VHOST & CONF FILES @@ -111,7 +108,6 @@ ef_browse="Your may now try browsing the elfinder file manager at \nhttps://$(ho ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" -echo "4" # Nginx write to custom and apps vhost files function write_nginx_vhost () { @@ -191,7 +187,7 @@ EOT # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then - echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" + echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null -- GitLab From 58788abf393d0a9c7eeb970e208f5b8eb8e7d6e5 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 07:50:49 +0000 Subject: [PATCH 091/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 91 ++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index ae9622d..9e56388 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -109,15 +109,8 @@ ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" -# Nginx write to custom and apps vhost files function -write_nginx_vhost () { - # Define nginx master & target files & edit string - master_vhost=nginx_apps.vhost.master - target_vhost=/etc/nginx/sites-available/apps.vhost - target_base=$(basename $target_vhost) - ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) - sm_search="location \/squirrelmail" - +# Function to download and extract latest elFinder +set_custom_conf () { # Create conf-custom directory if it doesn't exist if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist @@ -132,12 +125,11 @@ write_nginx_vhost () { ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ fi fi - - if [ -f $ispc_custom_dir/$master_vhost ]; then - # Go to the conf-custom folder - cd $ispc_custom_dir +} - cat <<"EOT" > $ef_temp_conf +# Create nginx config +set_nginx_conf () { + cat <<"EOT" > $ef_temp_conf ## ELFINDER FILE MANAGER CONFIG STARTS ## @@ -176,32 +168,55 @@ write_nginx_vhost () { EOT - - if grep -q $ef_word $master_vhost; then - echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - else - # First modify the conf vhost file and report result - sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost - if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - fi +} - # Then search for filemanager in the vhost / conf file, before we proceed further - if grep -q $ef_word $target_vhost; then - echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" - # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work - else - # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 - - # Change for both nginx and apache - sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost - if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - fi +# Function to add config in the custom-conf master file +add_nginx_conf () { + if grep -q $ef_word $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + else + # First modify the conf vhost file and report result + sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $master_vhost + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + fi + + # Then search for filemanager in the vhost / conf file, before we proceed further + if grep -q $ef_word $target_vhost; then + echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" + # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work + else + # Change for nginx only output to dev null + sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 + + # Change for both nginx and apache + sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $target_vhost + if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + fi + + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir + +} + +# Nginx write to custom and apps vhost files function +write_nginx_vhost () { + # Define nginx master & target files & edit string + master_vhost=nginx_apps.vhost.master + target_vhost=/etc/nginx/sites-available/apps.vhost + target_base=$(basename $target_vhost) + ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) + ef_search="location \/squirrelmail" + + set_custom_conf + + if [ -f $ispc_custom_dir/$master_vhost ]; then + # Go to the conf-custom folder + cd $ispc_custom_dir - # All modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir + set_nginx_conf + add_nginx_conf # Reload nginx if all good and report result if nginx -t 2>/dev/null; then -- GitLab From 8bc61711dba222673de6b061126cfb07ce7bb6f3 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:01:04 +0000 Subject: [PATCH 092/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 9e56388..769d7c1 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -172,6 +172,7 @@ EOT # Function to add config in the custom-conf master file add_nginx_conf () { + ef_search="location \/squirrelmail" if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else @@ -207,7 +208,6 @@ write_nginx_vhost () { target_vhost=/etc/nginx/sites-available/apps.vhost target_base=$(basename $target_vhost) ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) - ef_search="location \/squirrelmail" set_custom_conf -- GitLab From 7aed32afeb572219fbdb0f960cbbcd6c15402fa8 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:43:05 +0000 Subject: [PATCH 093/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 769d7c1..74abdba 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -187,9 +187,9 @@ add_nginx_conf () { # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 + sed -i 's/{use_tcp}/#/g' $ef_temp_conf phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf # Change for both nginx and apache sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $target_vhost -- GitLab From 1a94b92c6bc3bef9425c02fb86f5fa98025ec6c0 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:44:34 +0000 Subject: [PATCH 094/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 55 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 74abdba..8c5abc9 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -172,33 +172,6 @@ EOT # Function to add config in the custom-conf master file add_nginx_conf () { - ef_search="location \/squirrelmail" - if grep -q $ef_word $master_vhost; then - echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - else - # First modify the conf vhost file and report result - sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $master_vhost - if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - fi - - # Then search for filemanager in the vhost / conf file, before we proceed further - if grep -q $ef_word $target_vhost; then - echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" - # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work - else - # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf - - # Change for both nginx and apache - sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $target_vhost - if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - fi - - # All modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir - } # Nginx write to custom and apps vhost files function @@ -216,7 +189,33 @@ write_nginx_vhost () { cd $ispc_custom_dir set_nginx_conf - add_nginx_conf + + ef_search="location \/squirrelmail" + if grep -q $ef_word $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + else + # First modify the conf vhost file and report result + sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $master_vhost + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + fi + + # Then search for filemanager in the vhost / conf file, before we proceed further + if grep -q $ef_word $target_vhost; then + echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" + # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work + else + # Change for nginx only output to dev null + sed -i 's/{use_tcp}/#/g' $ef_temp_conf + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf + + # Change for both nginx and apache + sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $target_vhost + if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + fi + + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir # Reload nginx if all good and report result if nginx -t 2>/dev/null; then -- GitLab From 7d5f8091ac8c31df83c85fcdd25f3ba920c80867 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:45:33 +0000 Subject: [PATCH 095/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 8c5abc9..4314d7c 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -171,8 +171,8 @@ EOT } # Function to add config in the custom-conf master file -add_nginx_conf () { -} +#add_nginx_conf () { +#} # Nginx write to custom and apps vhost files function write_nginx_vhost () { -- GitLab From 48493b4b2942875e7e136f14c6940a992eca6a5d Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:47:49 +0000 Subject: [PATCH 096/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 44 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 4314d7c..1668490 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -171,8 +171,36 @@ EOT } # Function to add config in the custom-conf master file -#add_nginx_conf () { -#} +master_add_conf () { + if grep -q $ef_word $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + else + # First modify the conf vhost file and report result + sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + fi +} + +# Function to add config in the custom-conf target file +target_add_conf () { + # Then search for filemanager in the vhost / conf file, before we proceed further + if grep -q $ef_word $target_vhost; then + echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" + # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work + else + # Change for nginx only output to dev null + sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 + + # Change for both nginx and apache + sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost + if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + fi + + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir +} # Nginx write to custom and apps vhost files function write_nginx_vhost () { @@ -181,6 +209,7 @@ write_nginx_vhost () { target_vhost=/etc/nginx/sites-available/apps.vhost target_base=$(basename $target_vhost) ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) + ef_search="location \/squirrelmail" set_custom_conf @@ -189,8 +218,7 @@ write_nginx_vhost () { cd $ispc_custom_dir set_nginx_conf - - ef_search="location \/squirrelmail" + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else @@ -205,17 +233,17 @@ write_nginx_vhost () { # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf + sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 # Change for both nginx and apache sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $target_vhost if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi fi - # All modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir # Reload nginx if all good and report result if nginx -t 2>/dev/null; then -- GitLab From c58b4746ece9b6ab60b3b9145ca18d44aaefa28c Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:49:27 +0000 Subject: [PATCH 097/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 70 ++++++++------------------------------ 1 file changed, 14 insertions(+), 56 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 1668490..107224b 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -109,8 +109,15 @@ ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" -# Function to download and extract latest elFinder -set_custom_conf () { +# Nginx write to custom and apps vhost files function +write_nginx_vhost () { + # Define nginx master & target files & edit string + master_vhost=nginx_apps.vhost.master + target_vhost=/etc/nginx/sites-available/apps.vhost + target_base=$(basename $target_vhost) + ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) + ef_search="location \/squirrelmail" + # Create conf-custom directory if it doesn't exist if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist @@ -125,11 +132,12 @@ set_custom_conf () { ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ fi fi -} + + if [ -f $ispc_custom_dir/$master_vhost ]; then + # Go to the conf-custom folder + cd $ispc_custom_dir -# Create nginx config -set_nginx_conf () { - cat <<"EOT" > $ef_temp_conf + cat <<"EOT" > $ef_temp_conf ## ELFINDER FILE MANAGER CONFIG STARTS ## @@ -168,56 +176,6 @@ set_nginx_conf () { EOT -} - -# Function to add config in the custom-conf master file -master_add_conf () { - if grep -q $ef_word $master_vhost; then - echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - else - # First modify the conf vhost file and report result - sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost - if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - fi -} - -# Function to add config in the custom-conf target file -target_add_conf () { - # Then search for filemanager in the vhost / conf file, before we proceed further - if grep -q $ef_word $target_vhost; then - echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" - # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work - else - # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 - - # Change for both nginx and apache - sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost - if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - fi - - # All modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir -} - -# Nginx write to custom and apps vhost files function -write_nginx_vhost () { - # Define nginx master & target files & edit string - master_vhost=nginx_apps.vhost.master - target_vhost=/etc/nginx/sites-available/apps.vhost - target_base=$(basename $target_vhost) - ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) - ef_search="location \/squirrelmail" - - set_custom_conf - - if [ -f $ispc_custom_dir/$master_vhost ]; then - # Go to the conf-custom folder - cd $ispc_custom_dir - - set_nginx_conf if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" -- GitLab From 1a0f0e6f601005389bf90bde9d4de2a6d957196a Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:50:46 +0000 Subject: [PATCH 098/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 107224b..95e5ddf 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -77,7 +77,7 @@ else get_elfinder set_elfinder fi - +echo "0" # Define filemanager folder and its backup, backup if needed, then force create its symlink ef_fm_dir=/usr/share/filemanager ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") @@ -85,9 +85,12 @@ if [ -d $ef_fm_dir ]; then # Backup then force symlink if folder exist but not empty and also not a link if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak; fi ln -sf $ef_main_dir $ef_fm_dir + echo "1" else ln -sf $ef_main_dir $ef_fm_dir + echo "2" fi +echo "3" ## ADD CONFIGS IF THEY DON'T EXIST IN VHOST & CONF FILES @@ -108,6 +111,7 @@ ef_browse="Your may now try browsing the elfinder file manager at \nhttps://$(ho ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" +echo "4" # Nginx write to custom and apps vhost files function write_nginx_vhost () { @@ -116,7 +120,7 @@ write_nginx_vhost () { target_vhost=/etc/nginx/sites-available/apps.vhost target_base=$(basename $target_vhost) ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) - ef_search="location \/squirrelmail" + sm_search="location \/squirrelmail" # Create conf-custom directory if it doesn't exist if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi @@ -181,13 +185,13 @@ EOT echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else # First modify the conf vhost file and report result - sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $master_vhost + sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi fi # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then - echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" + echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null @@ -196,7 +200,7 @@ EOT sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 # Change for both nginx and apache - sed -i "/"$ef_search"/e cat "$ef_temp_conf"" $target_vhost + sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi fi -- GitLab From c5b1d0b7fb568c7df8f0217aade84b7cb75f3451 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 08:52:37 +0000 Subject: [PATCH 099/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 95e5ddf..c6ace57 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -77,7 +77,7 @@ else get_elfinder set_elfinder fi -echo "0" + # Define filemanager folder and its backup, backup if needed, then force create its symlink ef_fm_dir=/usr/share/filemanager ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") @@ -85,12 +85,9 @@ if [ -d $ef_fm_dir ]; then # Backup then force symlink if folder exist but not empty and also not a link if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak; fi ln -sf $ef_main_dir $ef_fm_dir - echo "1" else ln -sf $ef_main_dir $ef_fm_dir - echo "2" fi -echo "3" ## ADD CONFIGS IF THEY DON'T EXIST IN VHOST & CONF FILES @@ -111,7 +108,6 @@ ef_browse="Your may now try browsing the elfinder file manager at \nhttps://$(ho ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" -echo "4" # Nginx write to custom and apps vhost files function write_nginx_vhost () { @@ -185,7 +181,7 @@ EOT echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else # First modify the conf vhost file and report result - sed -i "/"$sm_search"/e cat "$ef_temp"" $master_vhost + sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $master_vhost if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi fi -- GitLab From 492008394a93da418d9459f5dcd3a759cef58fb8 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 09:26:22 +0000 Subject: [PATCH 100/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index c6ace57..dd717d4 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -187,7 +187,7 @@ EOT # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then - echo -e "\n"$fm_exist" "$target_base" file.\n"$ef_old_inst"\n"$ef_manual"\n" + echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null -- GitLab From 4b40e42ec00e0e2bb9a39af141de35be7cced24e Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 09:33:14 +0000 Subject: [PATCH 101/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index dd717d4..3dc1428 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -117,7 +117,7 @@ write_nginx_vhost () { target_base=$(basename $target_vhost) ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) sm_search="location \/squirrelmail" - + echo "0" # Create conf-custom directory if it doesn't exist if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist @@ -132,11 +132,13 @@ write_nginx_vhost () { ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ fi fi + echo "1" if [ -f $ispc_custom_dir/$master_vhost ]; then # Go to the conf-custom folder cd $ispc_custom_dir + echo "2" cat <<"EOT" > $ef_temp_conf @@ -177,17 +179,23 @@ write_nginx_vhost () { EOT + echo "3" if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + + echo "4" else # First modify the conf vhost file and report result sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $master_vhost if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + + echo "5" fi # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" + echo "6" # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null @@ -198,6 +206,7 @@ EOT # Change for both nginx and apache sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + echo "7" fi # All modifications are done. Remove the unneeded files -- GitLab From b860514276b07375f6f4c7da4426f8be53f6cba7 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 09:38:56 +0000 Subject: [PATCH 102/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 3dc1428..018781a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -186,7 +186,7 @@ EOT echo "4" else # First modify the conf vhost file and report result - sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $master_vhost + sed -i "/$sm_search/e cat "$ef_temp_conf"" $master_vhost if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi echo "5" @@ -204,7 +204,7 @@ EOT sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 # Change for both nginx and apache - sed -i "/"$sm_search"/e cat "$ef_temp_conf"" $target_vhost + sed -i "/$sm_search/e cat "$ef_temp_conf"" $target_vhost if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi echo "7" fi -- GitLab From 81c9d89cb40682f347f3b556e7f2fe4f8c93ab69 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 09:49:50 +0000 Subject: [PATCH 103/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 48 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 018781a..b6e635f 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -109,15 +109,8 @@ ef_nosupport="You are not on a supported ISPConfig web server!" ef_old_setup="Previous setup could have set this up BUT who knows!?" ef_oops="Something is wrong!" -# Nginx write to custom and apps vhost files function -write_nginx_vhost () { - # Define nginx master & target files & edit string - master_vhost=nginx_apps.vhost.master - target_vhost=/etc/nginx/sites-available/apps.vhost - target_base=$(basename $target_vhost) - ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) - sm_search="location \/squirrelmail" - echo "0" +# Function to create, copy & symlink custom conf dir, file and/or sub install dir +set_custom_conf () { # Create conf-custom directory if it doesn't exist if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi # Copy the specified .vhost / .conf file from conf to conf-custom, if it doesn't exist @@ -132,14 +125,11 @@ write_nginx_vhost () { ln -sf $ispc_custom_dir/$master_vhost $isp_cust_inst_dir/ fi fi - echo "1" - - if [ -f $ispc_custom_dir/$master_vhost ]; then - # Go to the conf-custom folder - cd $ispc_custom_dir +} - echo "2" - cat <<"EOT" > $ef_temp_conf +# Function to create nginx config +set_nginx_conf () { + cat <<"EOT" > $ef_temp_conf ## ELFINDER FILE MANAGER CONFIG STARTS ## @@ -178,24 +168,37 @@ write_nginx_vhost () { EOT +} + +# Nginx write to custom and apps vhost files function +write_nginx_vhost () { + # Define nginx master & target files & edit string + master_vhost=nginx_apps.vhost.master + target_vhost=/etc/nginx/sites-available/apps.vhost + target_base=$(basename $target_vhost) + ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) + sm_search="location \/squirrelmail" + + # Run custom conf function + set_custom_conf + + if [ -f $ispc_custom_dir/$master_vhost ]; then + # Go to the conf-custom folder + cd $ispc_custom_dir + + set_nginx_conf - echo "3" if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - - echo "4" else # First modify the conf vhost file and report result sed -i "/$sm_search/e cat "$ef_temp_conf"" $master_vhost if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - - echo "5" fi # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" - echo "6" # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work else # Change for nginx only output to dev null @@ -206,7 +209,6 @@ EOT # Change for both nginx and apache sed -i "/$sm_search/e cat "$ef_temp_conf"" $target_vhost if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - echo "7" fi # All modifications are done. Remove the unneeded files -- GitLab From 129e10872b4b47e4dc592616575600dbdc40186c Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 10:11:24 +0000 Subject: [PATCH 104/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 64 ++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index b6e635f..9a1dff2 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 20230918-151830 +# Updated on 20230918-181045 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install @@ -64,7 +64,7 @@ if [ -d "$ef_main_dir" ]; then ef_setup_ver=$(grep -i "version" $ef_json | cut -d : -f 2,3 | cut -d '"' -f2) if [[ "$ef_setup_ver" == "$ef_latest_ver" ]]; then # Existing elFinder is up-to-date - echo -e ""$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log + echo -e "\n"$ef_exist" "$ef_latest_ver".\n"$ef_uptodate"" | tee $ef_temp_log else get_elfinder set_elfinder @@ -170,6 +170,35 @@ set_nginx_conf () { EOT } +# Function to add config in the custom-conf master file +add_vhost_conf () { + if grep -q $ef_word $master_vhost; then + echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" + else + # First modify the conf vhost file and report result + sed -i "/$sm_search/e cat "$ef_temp_conf"" $master_vhost + if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi + fi + + # Then search for filemanager in the vhost / conf file, before we proceed further + if grep -q $ef_word $target_vhost; then + echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" + # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work + else + # Change for nginx only output to dev null + sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 + phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" + sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 + + # Change for both nginx and apache + sed -i "/$sm_search/e cat "$ef_temp_conf"" $target_vhost + if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi + fi + + # All modifications are done. Remove the unneeded files + rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir +} + # Nginx write to custom and apps vhost files function write_nginx_vhost () { # Define nginx master & target files & edit string @@ -187,39 +216,14 @@ write_nginx_vhost () { cd $ispc_custom_dir set_nginx_conf - - if grep -q $ef_word $master_vhost; then - echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - else - # First modify the conf vhost file and report result - sed -i "/$sm_search/e cat "$ef_temp_conf"" $master_vhost - if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - fi - - # Then search for filemanager in the vhost / conf file, before we proceed further - if grep -q $ef_word $target_vhost; then - echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" - # Finally, if it is safe, modify the vhost / conf file, with some edits for it to work - else - # Change for nginx only output to dev null - sed -i 's/{use_tcp}/#/g' $ef_temp_conf >/dev/null 2>&1 - phpfpm="\t\t\tfastcgi_pass unix:/var/lib/php$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.')-fpm/apps.sock" - sed -i "/{fpm_socket}/c\\"$phpfpm";" $ef_temp_conf >/dev/null 2>&1 - - # Change for both nginx and apache - sed -i "/$sm_search/e cat "$ef_temp_conf"" $target_vhost - if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_added" "$target_base" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - fi - - # All modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_log $ef_temp_dir + add_vhost_conf # Reload nginx if all good and report result if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "\nNginx "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager" + echo -e "\nNginx "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager\n" else - echo -e "\nNginx "$ef_failed"\n\n"$ef_manual"" + echo -e "\nNginx "$ef_failed"\n\n"$ef_manual"\n" fi fi -- GitLab From 1641caacb6dc7a608d7b07b10dba9e3a3ad76813 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 10:15:57 +0000 Subject: [PATCH 105/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 9a1dff2..4874942 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -41,12 +41,12 @@ set_elfinder () { if [ -d $ef_temp_dir ]; then cp -R $ef_temp_dir/* $ef_main_dir if [ ! -z "$ef_json" ]; then - echo -e ""$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log + echo -e "\n"$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else - echo -e ""$ef_none" "$ef_latest_ver"" | tee $ef_temp_log + echo -e "\n"$ef_none" "$ef_latest_ver"" | tee $ef_temp_log fi else - echo $ef_failed + echo "\n"$ef_failed"" fi } @@ -221,9 +221,9 @@ write_nginx_vhost () { # Reload nginx if all good and report result if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "\nNginx "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager\n" + echo -e "Nginx "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager\n" else - echo -e "\nNginx "$ef_failed"\n\n"$ef_manual"\n" + echo -e "Nginx "$ef_failed"\n\n"$ef_manual"\n" fi fi -- GitLab From 91d39b9414417b9809f01c35ec2bc455ed35227c Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 10:41:18 +0000 Subject: [PATCH 106/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 111 ++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 63 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 4874942..454349e 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -43,7 +43,7 @@ set_elfinder () { if [ ! -z "$ef_json" ]; then echo -e "\n"$ef_exist" "$ef_setup_ver"\n"$ef_outdated" "$ef_latest_ver"." | tee $ef_temp_log else - echo -e "\n"$ef_none" "$ef_latest_ver"" | tee $ef_temp_log + echo -e "\n"$ef_none" "$ef_latest_ver"." | tee $ef_temp_log fi else echo "\n"$ef_failed"" @@ -54,7 +54,7 @@ set_elfinder () { ef_exist="elFinder filemanager setup exists with version" ef_uptodate="It is up-to-date. Neither new setup nor update is needed." ef_outdated="This old setup has been updated to latest version" -ef_none="We've setup new elFinder filemanager as none is found i.e. version" +ef_none="We've setup latest elFinder as none existed i.e. version" ef_failed="Failed to download and setup / download elFinder filemanager." # Run elFinder setup / update here if it is not up-to-date @@ -171,7 +171,7 @@ EOT } # Function to add config in the custom-conf master file -add_vhost_conf () { +add_master_conf () { if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" else @@ -179,7 +179,10 @@ add_vhost_conf () { sed -i "/$sm_search/e cat "$ef_temp_conf"" $master_vhost if grep -q $ef_word $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi fi +} +# Function to add config in the custom-conf master file +add_master_conf () { # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" @@ -216,7 +219,8 @@ write_nginx_vhost () { cd $ispc_custom_dir set_nginx_conf - add_vhost_conf + add_master_conf + add_target_conf # Reload nginx if all good and report result if nginx -t 2>/dev/null; then @@ -229,34 +233,9 @@ write_nginx_vhost () { } - -# Apache write to custom and ispconfig vhost files function -write_apache_vhost () { - # Define custom and ispconfig vhost files - target_vhost=/etc/apache2/sites-available/ispconfig.conf - basename=$(basename $target_vhost) - master_vhost=apache_ispconfig.conf.master - # Create conf-custom folder if it doesn't exist - if [ ! -d $ispc_custom_dir ]; then mkdir -p $ispc_custom_dir; fi - # Copy ispconfig vhost from conf to conf-custom if it doesn't exist - if [ ! -f $ispc_custom_dir/$master_vhost ]; then - cp $ispc_conf_dir/$master_vhost $ispc_custom_dir/ - # Check conf-custom/install folder - if [ ! -d $ispc_install_dir ]; then - # Force symlink to setup folder, if it doesn't exist - ln -sf $ispc_custom_dir $ispc_install_dir - else - # Force symlink ispconfig file from custom-conf to setup folder - ln -sf $ispc_custom_dir/$master_vhost $ispc_install_dir/ - fi - fi - - if [ -f $ispc_custom_dir/$master_vhost ]; then - # Go to the conf-custom folder - cd $ispc_custom_dir - - # Add content to the defined dummy file - tee $ef_temp_conf >/dev/null << END +# Function to create nginx config +set_apache_conf () { + tee $ef_temp_conf >/dev/null << END ## ELFINDER FILE MANAGER ## @@ -271,17 +250,11 @@ write_apache_vhost () { END +} - # Search for filemanager in the conf vhost file - if grep -q "filemanager" $master_vhost; then - echo -e "\n"$ef_exist" "$master_vhost" file.\n"$ef_old_setup"\n"$ef_manual"" - else - # First modify the conf vhost file and report result - sed -i "/\/squirrelmail/e cat $ef_temp_conf" $master_vhost - if grep -q "filemanager" $master_vhost; then echo -e "\n"$ef_added" "$master_vhost" file."; else echo -e "\n"$ef_oops" "$ef_manual"" && exit; fi - fi - - tee $ef_temp_conf2 >/dev/null << END +# Function to create apache config 2 +set_apache_vhost () { + tee $ef_temp_conf >/dev/null << END ## ELFINDER FILE MANAGER ## @@ -291,22 +264,15 @@ END END - - # Then search for filemanager in the ISPConfig vhost file, before we proceed further - if grep -q "filemanager" $target_vhost; then - echo -e "\n"$ef_exist" "$basename" file.\n"$ef_old_setup"\n"$ef_manual"\n" - # Finally, if it is safe, modify the ISPConfig vhost file, with some edits for it to work - else - sed -i "/\/squirrelmail/e cat $ef_temp_conf2" $target_vhost - if grep -q "filemanager" $target_vhost; then echo -e "\n"$ef_added" "$basename" file.\n"; else echo -e "\n"$ef_oops" "$ef_manual"\n" && exit; fi - fi - +} - # Create basic filemanager config.file - elfinderadir=/etc/apache2/conf-available - elfinderedir=/etc/apache2/conf-enabled - elfinderconf=filemanager.conf - tee $elfinderadir/$elfinderconf >/dev/null << END +# 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_fm_conf=filemanager.conf + tee $ef_avail_dir/$ef_fm_conf >/dev/null << END # elFinder default Apache configuration Alias /filemanager /usr/share/filemanager @@ -374,19 +340,38 @@ Alias /filemanager /usr/share/filemanager SSLStaplingCache shmcb:/var/run/ocsp(128000) END - - if [ ! -f $elfinderedir/$elfinderconf ]; then a2enconf filemanager; fi - # Both vhosts modifications are done. Remove the unneeded files - rm -rf $ef_temp_conf $ef_temp_conf2 $ef_temp_log $ef_temp_dir + + if [ ! -f $ef_enabl_dir/$ef_fm_conf ]; then a2enconf filemanager; fi +} + +# Apache write to custom and ispconfig vhost files function +write_apache_vhost () { + # Define custom and ispconfig vhost files + target_vhost=/etc/apache2/sites-available/ispconfig.conf + basename=$(basename $target_vhost) + master_vhost=apache_ispconfig.conf.master + + # Run custom conf function + set_custom_conf + + if [ -f $ispc_custom_dir/$master_vhost ]; then + # Go to the conf-custom folder + cd $ispc_custom_dir + + set_apache_conf + add_master_conf + set_apache_vhost + add_target_conf + 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 "\nApache2 "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager" + echo -e "Apache2 "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager\n" else - echo -e "\nApache2 "$ef_failed"\n\n"$ef_manual"" + echo -e "Apache2 "$ef_failed"\n\n"$ef_manual"\n" fi fi } -- GitLab From 4ed77503b44bc4bbb0ea713c9bb8013ba11be5e0 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 10:43:14 +0000 Subject: [PATCH 107/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 454349e..0d4e53a 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -181,8 +181,8 @@ add_master_conf () { fi } -# Function to add config in the custom-conf master file -add_master_conf () { +# Function to add config in the custom-conf target file +add_target_conf () { # Then search for filemanager in the vhost / conf file, before we proceed further if grep -q $ef_word $target_vhost; then echo -e "\n"$ef_exist" "$target_base" file.\n"$ef_old_setup"\n"$ef_manual"\n" -- GitLab From ab93bcf261cd8a7ef05d010b6df78c233a02c4f9 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 10:46:57 +0000 Subject: [PATCH 108/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0d4e53a..72253fd 100644 --- a/elfinder_install_update.sh +++ b/elfinder_install_update.sh @@ -347,9 +347,11 @@ END # Apache write to custom and ispconfig vhost files function write_apache_vhost () { # Define custom and ispconfig vhost files - target_vhost=/etc/apache2/sites-available/ispconfig.conf - basename=$(basename $target_vhost) master_vhost=apache_ispconfig.conf.master + target_vhost=/etc/apache2/sites-available/ispconfig.conf + target_base=$(basename $target_vhost) + ef_port=$(grep -i "\*:" $target_vhost | cut -d : -f 2,3 | cut -d " " -f1) + sm_search="\/squirrelmail" # Run custom conf function set_custom_conf -- GitLab From 8de42d84798e47cc09688aad3441d23a544dcf50 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Mon, 18 Sep 2023 10:50:39 +0000 Subject: [PATCH 109/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 72253fd..0ac0a47 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 20230918-181045 +# Updated on 20230918-185025 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install -- GitLab From 317f22fdc8e990f72791bc65d5fa60c2ea974e35 Mon Sep 17 00:00:00 2001 From: Hj Ahmad Rasyid Hj Ismail Date: Tue, 19 Sep 2023 02:34:21 +0000 Subject: [PATCH 110/110] Update elfinder_install_update.sh --- elfinder_install_update.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/elfinder_install_update.sh b/elfinder_install_update.sh index 0ac0a47..69123e9 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 20230918-185025 +# Updated on 20230919-103405 # Should work on systems that were installed according to HowToForge's Perfect Server guides for auto/manual install @@ -51,11 +51,12 @@ set_elfinder () { } # Define elFinder setup / update messages -ef_exist="elFinder filemanager setup exists with version" +ef_word="filemanager" +ef_exist="elFinder $ef_word setup exists with version" ef_uptodate="It is up-to-date. Neither new setup nor update is needed." ef_outdated="This old setup has been updated to latest version" ef_none="We've setup latest elFinder as none existed i.e. version" -ef_failed="Failed to download and setup / download elFinder filemanager." +ef_failed="Failed to download and setup / download elFinder $ef_word." # Run elFinder setup / update here if it is not up-to-date if [ -d "$ef_main_dir" ]; then @@ -79,8 +80,8 @@ else fi # Define filemanager folder and its backup, backup if needed, then force create its symlink -ef_fm_dir=/usr/share/filemanager -ef_fm_bak=/usr/share/filemanagerbak-$(date +"%Y%m%d-%H%M%S") +ef_fm_dir=/usr/share/$ef_word +ef_fm_bak=/usr/share/$ef_wordbak-$(date +"%Y%m%d-%H%M%S") if [ -d $ef_fm_dir ]; then # Backup then force symlink if folder exist but not empty and also not a link if [ ! -z $ef_fm_dir ] || [ ! -L $ef_fm_dir ]; then cp -R $ef_fm_dir $ef_fm_bak; fi @@ -97,10 +98,8 @@ ispc_conf_dir=/usr/local/ispconfig/server/conf ispc_custom_dir=/usr/local/ispconfig/server/conf-custom ispc_install_dir=/usr/local/ispconfig/server/conf-custom/install ef_temp_conf=ef-temp.conf -ef_temp_conf2=elfinder_cat2.txt -ef_word="filemanager" -ef_exist="Not overwriting as string (filemanager) exists in the" -ef_added="Added elFinder filemanager config successfully in the" +ef_exist="Not overwriting as string ($ef_word) exists in the" +ef_added="Added elFinder $ef_word config successfully in the" ef_reload="has been successfully reloaded." ef_failed="configuration test failed." ef_manual="Please double check and manually fix the vhost file(s), if needed." @@ -225,7 +224,7 @@ write_nginx_vhost () { # Reload nginx if all good and report result if nginx -t 2>/dev/null; then systemctl reload nginx - echo -e "Nginx "$ef_reload"\n\n"$ef_browse""$ef_port"/filemanager\n" + echo -e "Nginx "$ef_reload"\n\n"$ef_browse""$ef_port"/$ef_word\n" else echo -e "Nginx "$ef_failed"\n\n"$ef_manual"\n" fi @@ -271,7 +270,7 @@ set_elfinder_conf () { # Create basic filemanager config.file ef_avail_dir=/etc/apache2/conf-available ef_enabl_dir=/etc/apache2/conf-enabled - ef_fm_conf=filemanager.conf + ef_fm_conf=$ef_word.conf tee $ef_avail_dir/$ef_fm_conf >/dev/null << END # elFinder default Apache configuration @@ -341,7 +340,7 @@ Alias /filemanager /usr/share/filemanager END - if [ ! -f $ef_enabl_dir/$ef_fm_conf ]; then a2enconf filemanager; fi + if [ ! -f $ef_enabl_dir/$ef_fm_conf ]; then a2enconf $ef_word; fi } # Apache write to custom and ispconfig vhost files function @@ -371,7 +370,7 @@ write_apache_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"/filemanager\n" + echo -e "Apache2 "$ef_reload"\n\n"$ef_browse""$ef_port"/$ef_word\n" else echo -e "Apache2 "$ef_failed"\n\n"$ef_manual"\n" fi -- GitLab