?
Current Path : /usr/share/lve/modlscapi/utils/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : //usr/share/lve/modlscapi/utils/cpanel-hooks-lve |
#!/bin/bash # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################### # Utils for hooks installation or removing # ################################################### . /usr/share/lve/modlscapi/include/cpanel-common-lve function createHookHeader(){ #1 - hook name if [ ! -e "$common_path_of_cpanel/tmp" ]; then mkdir -p "$common_path_of_cpanel/tmp" fi if [ ! -e "$1" ];then touch "$1" fi if [ -e "$1" ];then chmod 755 "$1" tmp=$(cat "$1" | grep "#!/bin/bash") if [ -z "$tmp" ];then echo "#!/bin/bash" > "$common_path_of_cpanel/tmp/future_hook.tmp.$$" cat "$1" >> "$common_path_of_cpanel/tmp/future_hook.tmp.$$" cat "$common_path_of_cpanel/tmp/future_hook.tmp.$$" > "$1" rm -f "$common_path_of_cpanel/tmp/future_hook.tmp.$$" fi fi } function checkHookString(){ #1 - hook name #2 - pattern string #3 - comment srting if [ -e "$1" ];then tmp=$(cat "$1" | grep "$2") if [ -z "$tmp" ];then echo "$2 #$3" >> "$1" fi fi } function addHookStringFirst(){ #1 - hook name #2 - pattern string #3 - comment srting #4 - short hook name if [ -e "$1" ];then cat "$1" | sed /$4/d | sed 1a"$2 #$3" > "$common_path_of_cpanel/tmp/future_hook.tmp.$$" cat "$common_path_of_cpanel/tmp/future_hook.tmp.$$" > "$1" rm -f "$common_path_of_cpanel/tmp/future_hook.tmp.$$" fi } #################################################### # EasyApache hooks # #################################################### before_apache_make="/scripts/before_apache_make" before_httpd_restart_tests="/scripts/before_httpd_restart_tests" postupcp="/scripts/postupcp" after_apache_make_install="/scripts/after_apache_make_install" posteasyapache="/scripts/posteasyapache" #################################################### # Hooks list # #################################################### lsapi_HOOK="$common_path_of_cpanel/hooks/lsapi.hook" cpanelpostupcp_HOOK="$common_path_of_cpanel/hooks/cpanelpostupcp.hook" clearconf_HOOK="$common_path_of_cpanel/hooks/clearconf.hook" posteasyapache_HOOK="$common_path_of_cpanel/hooks/buildlsphp.hook" writeToLog "Install cPanel hooks" showBar 1 #Install new hooks createHookHeader "$before_apache_make" createHookHeader "$before_httpd_restart_tests" createHookHeader "$postupcp" createHookHeader "$after_apache_make_install" createHookHeader "$posteasyapache" showBar 2 writeToLog "Headers checked" addHookStringFirst "$before_apache_make" "$clearconf_HOOK" "mod_lsapi Version $VERSION. Required for LVE module recompilation" "clearconf.hook" removeEmptyStringsFromFile "$before_apache_make" showBar 3 writeToLog "before_apache_make checked" checkHookString "$before_httpd_restart_tests" "$lsapi_HOOK" "mod_lsapi Version $VERSION mod_lsapi module installation" checkHookString "$before_httpd_restart_tests" "$cpanelpostupcp_HOOK" "mod_lsapi Version $VERSION Rebuild Apache config hook" removeEmptyStringsFromFile "$before_httpd_restart_tests" showBar 4 writeToLog "before_httpd_restart_tests checked" checkHookString "$postupcp" "$cpanelpostupcp_HOOK" "mod_lsapi Version $VERSION Rebuild Apache config hook" removeEmptyStringsFromFile "$postupcp" showBar 5 writeToLog "postupcp checked" showBar 6 writeToLog "after_apache_make_install checked" checkHookString "$after_apache_make_install" "$lsapi_HOOK" "mod_lsapi Version $VERSION mod_lsapi module installation" removeEmptyStringsFromFile "$after_apache_make_install" showBar 7 writeToLog "after_apache_make_install checked" showBar 8 checkHookString "$posteasyapache" "$posteasyapache_HOOK" "mod_lsapi Version $VERSION mod_lsapi module installation" checkHookString "$posteasyapache" "$cpanelpostupcp_HOOK" "mod_lsapi Version $VERSION Rebuild Apache config hook" removeEmptyStringsFromFile "$posteasyapache" writeToLog "posteasyapache checked" showBar 9 writeToLog "Done installing hooks" echo