#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/nginx-module-check Check nginx module dependencies # # Creation: 2016-03-03 ap # Last Update: $Id$ # # Copyright (c) 2016-2022 Ansgar Puester, ansgar.puester(at)freenet(dot)de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # nginx tool to check module dependencies # # Arguments: # None # # Returns: # None # #---------------------------------------------------------------------------- #include eislib . /var/install/include/eislib ASK=/var/install/bin/ask CAT=/bin/cat RM=/bin/rm MKTEMP=/bin/mktemp module_path=/var/lib/nginx/modules # --------------------------------------------------------------------------- # check module # --------------------------------------------------------------------------- check_module() { act_module=$1 echo echo mecho --info "Analysis for modul $act_module" check_module_short "${act_module}" RC=$? if [ "${RC}" = 0 ]; then echo echo "Missing libraries:" ldd ${module_path}/${act_module} | grep -e '=>[[:space:]]not found' | cut -f2 | sed -E 's/[[:space:]].*//' echo echo "Install the required libraries and try again" else echo "No additional libraries required" fi echo } # --------------------------------------------------------------------------- # check module short # return # 1 no missing libs # 0 missing libs # --------------------------------------------------------------------------- check_module_short() { # readelf requires binutils # objdump requires binutils #readelf -d ${module_path}/${act_module} | awk '/NEEDED/ { print $5 } ' #objdump -p ${module_path}/${act_module} | grep NEEDED act_module=$1 ldd ${module_path}/${act_module} | grep -e '=>[[:space:]]not found' >/dev/null 2>&1 return $? } # --------------------------------------------------------------------------- # print modules # --------------------------------------------------------------------------- print_modules() { declare -A module_tab clrhome mecho --info 'Available nginx modules' echo techo --begin '3 4r 1 50 1 13' techo --row '' No '' module '' 'missing libs' idx=0 modules=$(find ${module_path} -name '*.so' -printf '%f\n' | sort) for module in ${modules} do #echo ${module} idx=$(/usr/bin/expr ${idx} + 1) check_module_short ${module} rc=$? [ "${rc}" = 1 ] && miss='No' || miss='yes' techo --row '' "${idx}" '' "${module}" '' "${miss}" eval module_tab[$idx]=${module} done techo --end echo _ask_file=$(${MKTEMP} -t .XXXXXXXXXXXXX) ${ASK} 'Select for detailed check' '' "1-${idx}" '^$=Return' '0=Exit' >${_ask_file} rc=${?} read _module_to_check < ${_ask_file} ${RM} -f ${_ask_file} if [ ${rc} = 255 ] then _module_to_check=0 fi case ${_module_to_check} in '') exit 0 ;; 0) exit 127 ;; *) eval selected_module=${module_tab[${_module_to_check}]} #echo "selected_module=${selected_module}" check_module ${selected_module} anykey ;; esac } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { while true do print_modules done } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------