Added logging to the scripts
This commit is contained in:
@@ -29,7 +29,8 @@ make DESTDIR=$RPM_BUILD_ROOT install
|
||||
touch "$RPM_BUILD_ROOT"%{_sysconfdir}/hestia_php_selector/system/lock
|
||||
%{__mkdir} -p "$RPM_BUILD_ROOT"/usr/local/hestia_php_selector/
|
||||
%{__install} -D -m 755 installer.sh "$RPM_BUILD_ROOT"/usr/local/hestia_php_selector/hestiacp_php_selector_installer
|
||||
echo "/usr/bin/php%s" > "$RPM_BUILD_ROOT"%{_sysconfdir}/hestia_php_selector/php_sel_path.conf
|
||||
echo "/usr/bin/php%s" > "$RPM_BUILD_ROOT"%{_sysconfdir}/hestia_php_selector/php_sel_path_remi.conf
|
||||
echo "/opt/brepo/php%s/bin/php" > "$RPM_BUILD_ROOT"%{_sysconfdir}/hestia_php_selector/php_sel_path_brepo.conf
|
||||
|
||||
%check
|
||||
make check
|
||||
@@ -51,8 +52,10 @@ fi
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc LICENSE
|
||||
%config(noreplace) %{_sysconfdir}/hestia_php_selector/php_sel_path.conf
|
||||
%attr(0644, root, root) %{_sysconfdir}/hestia_php_selector/php_sel_path.conf
|
||||
%config(noreplace) %{_sysconfdir}/hestia_php_selector/php_sel_path_remi.conf
|
||||
%config(noreplace) %{_sysconfdir}/hestia_php_selector/php_sel_path_brepo.conf
|
||||
%attr(0644, root, root) %{_sysconfdir}/hestia_php_selector/php_sel_path_remi.conf
|
||||
%attr(0644, root, root) %{_sysconfdir}/hestia_php_selector/php_sel_path_brepo.conf
|
||||
%attr(0755, root, root) %{_bindir}/hestiacp-php-selector
|
||||
%attr(0755, root, root) %{_bindir}/hestiacp-php-admin
|
||||
%{_sysconfdir}/hestia_php_selector/*
|
||||
|
||||
13
installer.sh
13
installer.sh
@@ -1,5 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DEBUG_LOG_FILE="/var/log/hestia_php_selector.log"
|
||||
debug_out_function(){
|
||||
pattern=">>$DEBUG_LOG_FILE DEBUG"
|
||||
res="$@"
|
||||
dt="[$(date -Is)]"
|
||||
res1=${res#*debug_out_function}
|
||||
result="${res1%%$pattern*}"
|
||||
echo "$dt ${result# }"
|
||||
}
|
||||
exec 3>&1 1> >(tee -a "$DEBUG_LOG_FILE") 2>&1
|
||||
trap "debug_out_function $BASH_COMMAND>>$DEBUG_LOG_FILE" DEBUG
|
||||
|
||||
|
||||
function restore_system() {
|
||||
current_php=$(readlink -f /usr/bin/php)
|
||||
if [ "$current_php" == "/usr/bin/hestiacp-php-selector" ]; then
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
PATH_TO_LOCAL_PHP_ROOT = "php_sel"
|
||||
PATH_TO_LOCAL_PHP = PATH_TO_LOCAL_PHP_ROOT + PATH_TO_CONFIG_NAME
|
||||
LOCK_PATH = "lock"
|
||||
PHP_SEL_CONF = "/etc/hestia_php_selector/php_sel_path.conf"
|
||||
PHP_SEL_CONF = "/etc/hestia_php_selector/php_sel_path_%s.conf"
|
||||
PHP_TEMPLATE_REMI = "/usr/bin/php%s"
|
||||
PHP_TEMPLATE_BREPO = "/opt/brepo/php%s/bin/php"
|
||||
HESTIA_CONF = "/usr/local/hestia/conf/hestia.conf"
|
||||
@@ -89,7 +89,9 @@ func isExecOther(mode os.FileMode) bool {
|
||||
}
|
||||
|
||||
func getPathtpPHP(phpVer string) string {
|
||||
cont, err := os.ReadFile(PHP_SEL_CONF)
|
||||
php_tp := get_php_type()
|
||||
options := fmt.Sprintf(PHP_SEL_CONF, php_tp)
|
||||
cont, err := os.ReadFile(options)
|
||||
if err == nil {
|
||||
result := strings.Split(strings.TrimSpace(string(cont)), "\n")
|
||||
if len(result) > 0 {
|
||||
@@ -99,7 +101,7 @@ func getPathtpPHP(phpVer string) string {
|
||||
}
|
||||
}
|
||||
}
|
||||
if get_php_type() == "remi" {
|
||||
if php_tp == "remi" {
|
||||
return fmt.Sprintf(PHP_TEMPLATE_REMI, phpVer)
|
||||
} else {
|
||||
return fmt.Sprintf(PHP_TEMPLATE_BREPO, phpVer)
|
||||
|
||||
Reference in New Issue
Block a user