diff --git a/create_summary_websites.sh b/create_summary_websites.sh index 84e1a24..9bc4d63 100755 --- a/create_summary_websites.sh +++ b/create_summary_websites.sh @@ -12,7 +12,7 @@ declare -a apache_vhost_dir_arr declare -a _all_vhost_files_arr declare -a _all_document_root_dirs_arr -PHP_VERIONS_SUPPORTED="5.3 5.4 5.5 5.6 7.0.7.1 7.2 7.3 7.4 8.0 8.1 8.2" +PHP_VERIONS_SUPPORTED="5.3 5.4 5.5 5.6 7.0.7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3" declare -i number_websites_53=0 declare -i number_websites_54=0 @@ -26,6 +26,7 @@ declare -i number_websites_74=0 declare -i number_websites_80=0 declare -i number_websites_81=0 declare -i number_websites_82=0 +declare -i number_websites_83=0 declare -i number_redirected=0 declare -i number_parked=0 declare -i number_mod_php=0 @@ -61,6 +62,7 @@ clean_up() { rm -f $_tmp_filename_php_80 rm -f $_tmp_filename_php_81 rm -f $_tmp_filename_php_82 + rm -f $_tmp_filename_php_83 rm -f $_tmp_filename_not_considered rm -f $_tmp_filename_no_php_assigned exit $1 @@ -112,29 +114,27 @@ if [[ -f "$conf_file" ]]; then fi -if [[ -z "$DST_PATH_PHP" ]]; then - if [[ -d "/var/www/html/dummy/htdocs" ]] ; then - DST_PATH_PHP="/var/www/html/dummy/htdocs" - elif [[ -d "/var/www/html/dummy" ]] ; then - DST_PATH_PHP="/var/www/html/dummy" - elif [[ -d "/var/www/default" ]] ; then - DST_PATH_PHP="$DST_PATH_PHP" - fi -else - if [[ ! -d "$DST_PATH_PHP" ]]; then - mkdir "$DST_PATH_PHP" > /dev/null 2>&1 - if [[ $? -ne 0 ]]; then - fatal "Creation of directory '$DST_PATH_PHP' failed!" - fi +if [[ -z "$WEB_DOCROOT" ]]; then + fatal "Missing value for variable 'WEB_DOCROOT'!" +fi + +if [[ -z "$DST_PATH_STATS" ]]; then + DST_PATH_STATS="${WEB_DOCROOT}/website-stats" +fi + +if [[ ! -d "$DST_PATH_STATS" ]]; then + mkdir "$DST_PATH_STATS" > /dev/null 2>&1 + if [[ $? -ne 0 ]]; then + fatal "Creation of directory '$DST_PATH_STATS' failed!" fi fi -if [[ -z "$DST_PATH_PHP" ]]; then - fatal "Destination Path for statistics (parameter 'DST_PATH_PHP') not found!" +if [[ -z "$DST_PATH_STATS" ]]; then + fatal "Destination Path for statistics (parameter 'DST_PATH_STATS') not found!" fi if [[ -z "$DST_DIR_CSV" ]] ; then - DST_DIR_CSV="${DST_PATH_PHP}/csv-files-website-stats" + DST_DIR_CSV="${DST_PATH_STATS}/csv-files-website-stats" fi if [[ ! -d "$DST_DIR_CSV" ]]; then @@ -144,9 +144,13 @@ if [[ ! -d "$DST_DIR_CSV" ]]; then fi fi +if [[ -z "${WEB_DIR_CSV}" ]]; then + WEB_DIR_CSV="/website-stats/csv-files-website-stats" +fi + _tmp_filename_summary=$(mktemp) filename_summary="${DST_DIR_CSV}/WEBSITES_SUMMARY.csv" -cat < ${DST_PATH_PHP}/websites_summary.php +cat < ${DST_PATH_STATS}/websites_summary.php > $filename_summary _tmp_filename_redirected=$(mktemp) filename_redirected="${DST_DIR_CSV}/WEBSITES_REDIRECTED.csv" -cat < ${DST_PATH_PHP}/websites_redirected.php +cat < ${DST_PATH_STATS}/websites_redirected.php > $filename_redirected _tmp_filename_parked=$(mktemp) filename_parked="${DST_DIR_CSV}/WEBSITES_PARKED.csv" -cat < ${DST_PATH_PHP}/websites_parked.php +cat < ${DST_PATH_STATS}/websites_parked.php > $filename_parked _tmp_filename_mod_php=$(mktemp) filename_mod_php="${DST_DIR_CSV}/WEBSITES_MOD_PHP.csv" -cat < ${DST_PATH_PHP}/websites_mod_php.php +cat < ${DST_PATH_STATS}/websites_mod_php.php > $filename_mod_php _tmp_filename_php_fpm=$(mktemp) filename_php_fpm="${DST_DIR_CSV}/WEBSITES_PHP_FPM.csv" -cat < ${DST_PATH_PHP}/websites_php_fpm.php +cat < ${DST_PATH_STATS}/websites_php_fpm.php > $filename_php_fpm _tmp_filename_php_fcgid=$(mktemp) filename_php_fcgid="${DST_DIR_CSV}/WEBSITES_PHP_FCGID.csv" -cat < ${DST_PATH_PHP}/websites_php_fcgid.php +cat < ${DST_PATH_STATS}/websites_php_fcgid.php > $filename_php_fcgid _tmp_filename_php_53=$(mktemp) filename_php_53="${DST_DIR_CSV}/WEBSITES_PHP_53.csv" -cat < ${DST_PATH_PHP}/websites_php_53.php +cat < ${DST_PATH_STATS}/websites_php_53.php > $filename_php_53 _tmp_filename_php_54=$(mktemp) filename_php_54="${DST_DIR_CSV}/WEBSITES_PHP_54.csv" -cat < ${DST_PATH_PHP}/websites_php_54.php +cat < ${DST_PATH_STATS}/websites_php_54.php > $filename_php_54 _tmp_filename_php_55=$(mktemp) filename_php_55="${DST_DIR_CSV}/WEBSITES_PHP_55.csv" -cat < ${DST_PATH_PHP}/websites_php_55.php +cat < ${DST_PATH_STATS}/websites_php_55.php > $filename_php_55 _tmp_filename_php_56=$(mktemp) filename_php_56="${DST_DIR_CSV}/WEBSITES_PHP_56.csv" -cat < ${DST_PATH_PHP}/websites_php_56.php +cat < ${DST_PATH_STATS}/websites_php_56.php > $filename_php_56 _tmp_filename_php_70=$(mktemp) filename_php_70="${DST_DIR_CSV}/WEBSITES_PHP_70.csv" -cat < ${DST_PATH_PHP}/websites_php_70.php +cat < ${DST_PATH_STATS}/websites_php_70.php > $filename_php_70 _tmp_filename_php_71=$(mktemp) filename_php_71="${DST_DIR_CSV}/WEBSITES_PHP_71.csv" -cat < ${DST_PATH_PHP}/websites_php_71.php +cat < ${DST_PATH_STATS}/websites_php_71.php > $filename_php_71 _tmp_filename_php_72=$(mktemp) filename_php_72="${DST_DIR_CSV}/WEBSITES_PHP_72.csv" -cat < ${DST_PATH_PHP}/websites_php_72.php +cat < ${DST_PATH_STATS}/websites_php_72.php > $filename_php_72 _tmp_filename_php_73=$(mktemp) filename_php_73="${DST_DIR_CSV}/WEBSITES_PHP_73.csv" -cat < ${DST_PATH_PHP}/websites_php_73.php +cat < ${DST_PATH_STATS}/websites_php_73.php > $filename_php_73 _tmp_filename_php_74=$(mktemp) filename_php_74="${DST_DIR_CSV}/WEBSITES_PHP_74.csv" -cat < ${DST_PATH_PHP}/websites_php_74.php +cat < ${DST_PATH_STATS}/websites_php_74.php > $filename_php_74 _tmp_filename_php_80=$(mktemp) filename_php_80="${DST_DIR_CSV}/WEBSITES_PHP_80.csv" -cat < ${DST_PATH_PHP}/websites_php_80.php +cat < ${DST_PATH_STATS}/websites_php_80.php > $filename_php_80 _tmp_filename_php_81=$(mktemp) filename_php_81="${DST_DIR_CSV}/WEBSITES_PHP_81.csv" -cat < ${DST_PATH_PHP}/websites_php_81.php +cat < ${DST_PATH_STATS}/websites_php_81.php > $filename_php_81 _tmp_filename_php_82=$(mktemp) filename_php_82="${DST_DIR_CSV}/WEBSITES_PHP_82.csv" -cat < ${DST_PATH_PHP}/websites_php_82.php +cat < ${DST_PATH_STATS}/websites_php_82.php $filename_php_82 echo ";" >> $filename_php_82 +_tmp_filename_php_83=$(mktemp) +filename_php_83="${DST_DIR_CSV}/WEBSITES_PHP_83.csv" +cat < ${DST_PATH_STATS}/websites_php_83.php + +EOF +echo "Website; ;PHP Version; ;PHP Engine; ;Database; ;CMS; ;DocumentRoot; ;VHost file; ;Server Alias(es)" > $filename_php_83 +echo ";" >> $filename_php_83 + _tmp_filename_not_considered=$(mktemp) filename_not_considered="${DST_DIR_CSV}/VHOST_FILES_NOT_CONSIDERED.csv" -cat < ${DST_PATH_PHP}/vhost_files_not_considered.php +cat < ${DST_PATH_STATS}/vhost_files_not_considered.php > $filename_not_considered _tmp_filename_no_php_assigned=$(mktemp) filename_no_php_assigned="${DST_DIR_CSV}/WEBSITES_NO_PHP_FOUND.csv" -cat < ${DST_PATH_PHP}/websites_no_php_found.php +cat < ${DST_PATH_STATS}/websites_no_php_found.php > $_tmp_filename_php_83 + + ((number_websites_83++)) + + fi + elif ! $_vhost_file_not_considered ; then _redirect_site="" _redirect_site=$(grep -E "^\s*RewriteRule" $_vhost_file 2> /dev/null | awk '{print$3}' | sed 's/"//g' | sed 's/\/$//' | sed 's/https\?:\/\///g' | sed 's/\$1//g' | sort -u) @@ -1131,94 +1156,170 @@ cat $_tmp_filename_no_php_assigned | sort >> $filename_no_php_assigned # - Create summary file index.php # ----- -cat < ${DST_PATH_PHP}/index.php +if [[ -f "${DST_PATH_STATS}/index.php" ]]; then + rm "${DST_PATH_STATS}/index.php" +fi + +cat < ${DST_PATH_STATS}/index.html Statistics websites $(hostname -f) + + +

$(hostname -f)

    -
  • full summary of all hosted websites: $number_overall
  • +EOF +if [[ $number_overall -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • full summary of all hosted websites: $number_overall
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • full summary of all hosted websites: $number_overall
  • +EOF +fi + cat <> ${DST_PATH_STATS}/index.html
    -
  • redirected websites: $number_redirected
  • -
  • parked websites: $number_parked
  • +EOF +if [[ $number_redirected -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • redirected websites: $number_redirected
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • redirected websites: $number_redirected
  • +EOF +fi +if [[ $number_parked -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • parked websites: $number_parked
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • parked websites: $number_parked
  • +EOF +fi + cat <> ${DST_PATH_STATS}/index.html
    -
  • websites mod_php: $number_mod_php
  • -
  • websites PHP-FPM: $number_php_fpm
  • -
  • websites FastCGI: $number_php_fcgid
  • +EOF +if [[ $number_mod_php -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • websites mod_php: $number_mod_php
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • websites mod_php: $number_mod_php
  • +EOF +fi +if [[ $number_php_fpm -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP-FPM: $number_php_fpm
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP-FPM: $number_php_fpm
  • +EOF +fi +if [[ $number_php_fcgid -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • websites FastCGI: $number_php_fcgid
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • websites FastCGI: $number_php_fcgid
  • +EOF +fi + cat <> ${DST_PATH_STATS}/index.html
    -
  • websites no PHP assigned: $number_no_php_assigned
  • +EOF +if [[ $number_no_php_assigned -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • websites no PHP assigned: $number_no_php_assigned
  • +EOF +else + cat <> ${DST_PATH_STATS}/index.html +
  • websites no PHP assigned: $number_no_php_assigned
  • +EOF +fi + cat <> ${DST_PATH_STATS}/index.html


PHP versions supported by this script:
    $PHP_VERIONS_SUPPORTED
    EOF if [[ $number_websites_53 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v5.3: $number_websites_53
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v5.3: $number_websites_53
  • EOF fi if [[ $number_websites_54 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v5.4: $number_websites_54
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v5.4: $number_websites_54
  • EOF fi if [[ $number_websites_55 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v5.5: $number_websites_55
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v5.5: $number_websites_55
  • EOF fi if [[ $number_websites_56 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v5.6: $number_websites_56
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v5.6: $number_websites_56
  • EOF fi if [[ $number_websites_70 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v7.0: $number_websites_70
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v7.0: $number_websites_70
  • EOF fi if [[ $number_websites_71 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v7.1: $number_websites_71
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v7.1: $number_websites_71
  • EOF fi if [[ $number_websites_72 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v7.2: $number_websites_72
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v7.2: $number_websites_72
  • EOF fi if [[ $number_websites_73 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v7.3: $number_websites_73
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v7.3: $number_websites_73
  • EOF fi if [[ $number_websites_74 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v7.4: $number_websites_74
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v7.4: $number_websites_74
  • EOF fi if [[ $number_websites_80 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v8.0: $number_websites_80
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v8.0: $number_websites_80
  • EOF fi if [[ $number_websites_81 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v8.1: $number_websites_81
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v8.1: $number_websites_81
  • EOF fi if [[ $number_websites_82 -gt 0 ]]; then - cat <> ${DST_PATH_PHP}/index.php -
  • websites PHP v8.2: $number_websites_82
  • + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v8.2: $number_websites_82
  • EOF fi -cat <> ${DST_PATH_PHP}/index.php +if [[ $number_websites_83 -gt 0 ]]; then + cat <> ${DST_PATH_STATS}/index.html +
  • websites PHP v8.3: $number_websites_83
  • +EOF +fi +cat <> ${DST_PATH_STATS}/index.html