jina verze

This commit is contained in:
2026-08-12 10:53:04 +02:00
parent f186ec26a8
commit 93d4f24f07
43 changed files with 1686 additions and 1959 deletions
+5 -59
View File
@@ -10,7 +10,7 @@ function cmdBackupSitesArchive() {
local type="${2:-$backupType}"
local error vhostList total
run vhostList error openlitespeedConfigVhostList || { printDanger "Failed get list of vhosts: $error"; return 1; }
run vhostList error openlitespeedVhostList || { printDanger "Failed get list of virtual hosts: $error"; return 1; }
total=$(grep -c . <<< "$vhostList")
printSection "Config"
@@ -68,13 +68,13 @@ function cmdBackupSitesRsync() {
printDotText "Path" "$path"
local error vhostList
run vhostList error openlitespeedConfigVhostList || { printDanger "Failed get list of vhosts: $error"; return 1; }
run vhostList error openlitespeedVhostList || { printDanger "Failed get list of virtual hosts: $error"; return 1; }
printText "Files..."
if [[ "$path" == *"$backupFirstDir" ]]; then
runError error rsync -a --mkpath -- "$olsVhostsPath/" "$path" || printDanger "$error"
runError error rsync -a --mkpath -- "$vhostsPath/" "$path" || printDanger "$error"
else
runError error rsync -a --link-dest="$backupDailyPath/$backupFirstDir" -- "$olsVhostsPath/" "$path" || printDanger "$error"
runError error rsync -a --link-dest="$backupDailyPath/$backupFirstDir" -- "$vhostsPath/" "$path" || printDanger "$error"
fi
printText "Databases..."
@@ -84,7 +84,7 @@ function cmdBackupSitesRsync() {
printText "Configs..."
while read -r domain; do
runError error cp -p -- "$olsVhostsConfigPath/$domain.conf" "$path/$domain.conf" || printDanger "$error"
runError error cp -p -- "$openlitespeedVhostsPath/$domain.conf" "$path/$domain.conf" || printDanger "$error"
done < <(awk 'NF' <<< "$vhostList")
}
@@ -302,7 +302,6 @@ function cmdBackupDispatch() {
# [$3] (type): backup type.
function cmdBackupRun() {
local target="$1"
[[ -n "$target" ]] || { printRow; printDanger "Target not specified"; return 1; }
local path="$2"
path=$(backupPathGenerate "$path")
@@ -328,56 +327,3 @@ function cmdBackupRun() {
fi
fi
}
function cmdBackupList() {
printRow
local dirList archiveList dailyList backupList backupCount error
run dirList error fileList "$backupArchivePath" d || { printDanger "$error"; return 1; }
archiveList=$(printf '%s\n' "$dirList" | grep -E -- "$backupArchiveDirPattern" | sort || true)
run dirList error fileList "$backupDailyPath" d || { printDanger "$error"; return 1; }
dailyList=$(printf '%s\n' "$dirList" | grep -E -- "$backupDailyDirPattern" | sort || true)
backupList=$(printf '%s\n' "$archiveList" "$dailyList" | awk 'NF' | sort)
backupCount=$(grep -c . <<< "$backupList" || true)
local i=0 num dir label
while read -r dir; do
((++i))
num=$(printf "%0${#backupCount}d" "$i")
label="$num: $fontBlue$dir$fontReset"
if listContains "$dir" "$archiveList"; then
printDotText "$label" "${fontGreen}archive$fontReset"
elif listContains "$dir" "$dailyList"; then
printDotText "$label" "${fontGreen}daily$fontReset"
else
printDotText "$label" "$labelUnknown"
fi
done < <(awk 'NF' <<< "$backupList")
}
function cmdBackupSize() {
local dirList file size total=0 archiveList dailyList
printSection "Archive: $backupArchivePath"
run dirList error fileList "$backupArchivePath" d || { printDanger "$error"; return 1; }
archiveList=$(printf '%s\n' "$dirList" | grep -E -- "$backupArchiveDirPattern" | sort || true)
while IFS= read -r file; do
size=$(pathSize "$backupArchivePath/$file" "gb")
printDotText "$file" "$size Gb"
(( total += size ))
done <<< "$archiveList"
printSection "Daily: $backupDailyPath"
run dirList error fileList "$backupDailyPath" d || { printDanger "$error"; return 1; }
dailyList=$(printf '%s\n' "$dirList" | grep -E -- "$backupDailyDirPattern" | sort || true)
while IFS= read -r file; do
size=$(pathSize "$backupDailyPath/$file" "gb")
printDotText "$file" "$size Gb"
(( total += size ))
done <<< "$dailyList"
printRow
printDotText "total" "$total Gb"
}
+49 -52
View File
@@ -3,14 +3,14 @@ function cmdHelpPrint() {
}
function cmdHelpK3S() {
local title="-k|--k3s <action>"
local title="-k|--k3s <action> [option]"
local desc="
create - create all resources in k3s
remove - remove all resources in k3s
info - detail about a k3s
status - status about a k3s
top - top pod
res [<resource>] - get resource info (all|pod|event|pv|pvc|deploy|ds|rs|sts|svc|ing|ip|secret|cm|job|cj|ep|no|ns|cs|netpol)"
res [resource] - get resource info (all|pod|event|pv|pvc|deploy|ds|rs|sts|svc|ing|ip|secret|cm|job|cj|ep|no|ns|cs|netpol)"
cmdHelpPrint "$title" "$desc"
}
@@ -26,8 +26,8 @@ function cmdHelpMariaDB() {
replica - replica rebuild
database - database list
user - user list
dump [all|<database>] [<file>] - dump specified database or all databases from Master
dump_slave [<file>] - full dump from Slave"
dump [all|<database>] [file] - dump specified database or all databases from Master
dump_slave [file] - full dump from Slave"
cmdHelpPrint "$title" "$desc"
}
@@ -50,21 +50,22 @@ function cmdHelpRedis() {
function cmdHelpOpenLiteSpeed() {
local title="-o|--ols <action>"
local desc="
install - install OpenLiteSpeed in k3s
update - update OpenLiteSpeed in k3s
uninstall - uninstall OpenLiteSpeed from k3s
info - detail about a OpenLiteSpeed
list <option> - vhost list (all|up|down)
up - unpause vhost
down - pause vhost
alias - set aliases for domain
restart - restart OLS (graceful restart)
php_kill all|<domain> - kill lsphp for domain or all domains
white_list - WebAdmin white list update
allow_list - WebAdmin allow list update
install - install OpenLiteSpeed in k3s
update - update OpenLiteSpeed in k3s
uninstall - uninstall OpenLiteSpeed from k3s
info - detail about a OpenLiteSpeed
list <option> - vhost list (all|up|down)
up - unpause vhost
down - pause vhost
alias - set aliases for domain
restart - restart OLS (graceful restart)
restart_php - restart PHP
kill_php - kill PHP (hard restart)
white_list - WebAdmin white list update
allow_list - WebAdmin allow list update
alias_list all|<domain> - get aliases for domain or all domains
rebuild all|<domain> - rebuild owner and permission files
config - check config $olsConfigFile"
config - check config $openlitespeedConfigFile"
cmdHelpPrint "$title" "$desc"
}
@@ -72,13 +73,14 @@ function cmdHelpOpenLiteSpeed() {
function cmdHelpPostfix() {
local title="-p|--postfix <action>"
local desc="
install - install Postfix in k3s
update - update Postfix in k3s
uninstall - uninstall Postfix from k3s
info - detail about a Postfix
status - status about a Postfix
user - user list (SASL)
dkim [<domain>] - autocreate and display DKIM key for DNS record or all domains !!!"
install - install Postfix in k3s
update - update Postfix in k3s
uninstall - uninstall Postfix from k3s
info - detail about a Postfix
list <option> - list (domain|alias|senders|sasl) !!!!
domain <domain> - add domain
alias <domain> <email> - set alias for domain
dkim [domain] - autocreate and display DKIM key for DNS record or all domains !!!"
cmdHelpPrint "$title" "$desc"
}
@@ -89,10 +91,10 @@ function cmdHelpWorker() {
install - install Worker in k3s
update - update Worker in k3s
uninstall - uninstall Worker from k3s
task <file> [domain] - Execute task !!!!!
list - task list
down - stop receiving new tasks from the API (pause)
up - start receiving new tasks from the API (unpause)
task <file> [<domain>] - Execute task !!!!!"
up - start receiving new tasks from the API (unpause)"
cmdHelpPrint "$title" "$desc"
}
@@ -111,8 +113,8 @@ function cmdHelpMetric() {
function cmdHelpSite() {
local title="-s|--site <action>"
local desc="
add <domain> [<pathF>] [<pathD>] - add site (pathF: source files | pathD: source database)
add_wp|wp <domain> [<pathF>] [<pathD>] - add site on Wordpress
add <domain> [pathF] [pathD] - add site (pathF: source files | pathD: source database)
add_wp|wp <domain> [pathF] [pathD] - add site on Wordpress
remove <domain> [-f|--force] - site full remove (-f|--force - forced mode)
copy <domain> <domainNew> - create copy of site
rename <domain> <domainNew> - rename of site
@@ -122,7 +124,7 @@ function cmdHelpSite() {
rebuild_wp <domain> - rewrite config connection to internal services in bootstrap.php
reset_pass all|<domain> - reset ALL passwords for domain or all domains
reset_auth all|<domain> - reset ALL authentication settings for domain or all domains
dump <domain> [<file>] - dump database of site"
dump <domain> [file] - dump database of site"
cmdHelpPrint "$title" "$desc"
}
@@ -133,8 +135,7 @@ function cmdHelpWP() {
user <domain> - user list
pass <domain> <user> <pass> - user password set
salt all|<domain> - shuffle salts
check all|<domain> - check core and plugins
exec all|<domain> <command> - command exec"
exec <domain> <command> - command exec"
cmdHelpPrint "$title" "$desc"
}
@@ -162,27 +163,24 @@ function cmdHelpCron() {
}
function cmdHelpBackup() {
local title="--backup <action>"
local title="-b|--backup <target> [path] [type]"
local path=$(backupPathGenerate)
local desc="
run all|<domain> [<path>] [<type>] - backup
path: path to save backup, default: autogenerate
type: type backup (zip|tar|archive|rsync), default: $backupType
list - list backups on local
size - list of backup sizes"
target - all|<domain>
path - path to save backup, default value: $path (autogenerate)
type - type backup (zip|tar|archive|rsync), default value: $backupType"
cmdHelpPrint "$title" "$desc"
}
function cmdHelpRestore() {
local title="--restore <domain> $fontRed[NO TESTED!]$fornReset"
local title="--restore <domain> [option] [NO TESTED!]"
local desc="
run <domain> [<option>] - manual site restore
<empty> - manual site restore
list - display a list of available markers for restore
last - automatic site restore from the last backup
full - automatic site restore from the last FULL backup
auto - automatic site restore from the last FULL backup or the last backup
N - automatic site restore from the last backup #N (N: 1+)"
<domain> - manual site restore
<domain> list - display a list of available markers for restore
<domain> last - automatic site restore from the last backup
<domain> full - automatic site restore from the last FULL backup
<domain> auto - automatic site restore from the last FULL backup or the last backup
<domain> N - automatic site restore from the last backup #N (N: 1+)"
cmdHelpPrint "$title" "$desc"
}
@@ -192,7 +190,6 @@ function cmdHelpStorage() {
local desc="
list - list backups on external storage
compare - comparison table
size - list of backup sizes
sync <type> - synchronization with external storage (archive|daily)
remove - remove backups on external storage"
@@ -216,7 +213,7 @@ function cmdHelpScript() {
}
function cmdHelpTest() {
local title="--test <action> $fontRed[NO TESTED!]$fornReset"
local title="--test <action> [NO TESTED!]"
local desc="
mariadb - test MariaDB replica
redis - test Redis cluster
@@ -229,9 +226,9 @@ function cmdHelpTest() {
function cmdHelpMalware() {
local title="--malware <action>"
local desc="
plugin - check plugins (files) in all vhosts
user - check users Wordpress in all vhosts
file all|<domain> - check files"
muplugin - check MU plugins (files) in all vhosts
user - check users Wordpress in all vhosts
file all|<domain> - check files"
cmdHelpPrint "$title" "$desc"
}
@@ -301,7 +298,7 @@ function cmdHelp() {
printDotFix 20 "$fontBlue --log" "Log of pods"
printDotFix 20 "$fontBlue --describe" "Describe of pods"
printDotFix 20 "$fontBlue --delete" "Delete pods"
printDotFix 20 "$fontBlue --backup" "Create backup of sites"
printDotFix 20 "$fontBlue -b|--backup" "Create backup of sites"
printDotFix 20 "$fontBlue --restore" "Restore sites from backups"
printDotFix 20 "$fontBlue --storage" "Copy backups to storage"
printDotFix 20 "$fontBlue --script" "Execute scripts"
-9
View File
@@ -45,8 +45,6 @@ function cmdK3sPodSelect() {
# Interactively opens a shell or CLI inside a selected pod.
# [$1] (cli): pass "cli" to open the native CLI (mariadb/redis-cli) instead of a shell.
function cmdShell() {
printTitle " Shell $@"
local cli="$1"
local pod
cmdK3sPodSelect pod || return 1
@@ -99,8 +97,6 @@ function cmdShell() {
# Interactively selects a pod and streams its logs.
# [$@] (...): extra arguments passed to kubectl logs (e.g. -f, --tail=100).
function cmdLog() {
printTitle " Log $@"
local pod
cmdK3sPodSelect pod || return 1
@@ -119,8 +115,6 @@ function cmdDescribe() {
local target="${1:-pod}"
shift || true
printTitle " Describe $@"
case "$target" in
pod)
local pod
@@ -144,8 +138,6 @@ function cmdDescribe() {
# Interactively selects and deletes a pod.
function cmdDelete() {
printTitle " Delete $@ $fontRed[DANGER]$fontReset"
local pod
cmdK3sPodSelect pod || return 1
@@ -186,7 +178,6 @@ netpol|NetworkPolicies"
local i=0 line code info num
total=$(grep -c . <<< "$resList")
while IFS= read -r line; do
[[ -n "$line" ]] || continue
((i++))
num=$(printf "%${#total}d" "$i")
code="${line%%|*}"
+6 -37
View File
@@ -98,50 +98,19 @@ wgpwpp-cache.php
installatron_hide_status_test.php
"
run vhostsList error fileList "$olsVhostsPath" d || { printDanger "$error"; return 1; }
run vhostsList error fileList "$vhostsPath" d || { printDanger "$error"; return 1; }
while read -r dir; do
local found=0 pluginList
# unknown
run itemList error fileList "$olsVhostsPath/$dir/www/wp-content/mu-plugins/" f || continue
local found=0
run itemList error fileList "$vhostsPath/$dir/www/wp-content/mu-plugins/" f || continue
while read -r item; do
if grep -qF '($i){static $a=null' "$olsVhostsPath/$dir/www/wp-content/mu-plugins/$item"; then
if grep -qF '($i){static $a=null' "$vhostsPath/$dir/www/wp-content/mu-plugins/$item"; then
(( found++ )) || printSection "$dir"
printDotText "$item" "${fontRed}malware$fontReset"
elif ! listContains "$item" "$allowedFiles"; then
(( found++ )) || printSection "$dir"
printDotText "/wp-content/mu-plugins/$item" "$labelUnknown"
printDotText "$item" "${fontYellow}warning$fontReset"
fi
done < <(awk 'NF' <<< "$itemList")
# wp2shell
pluginList=$(find "$olsVhostsPath/$dir/www/wp-content/plugins" -maxdepth 1 -type d -name 'wp2shell*' 2>/dev/null)
if [ -n "$pluginList" ]; then
while IFS= read -r item; do
(( found++ )) || printSection "$dir"
printDotText "${item#"$olsVhostsPath/$dir/www"}" "${fontRed}malware$fontReset"
done <<< "$pluginList"
fi
# wp-static-cache
pluginList=$(find "$olsVhostsPath/$dir/www/wp-content/plugins" -maxdepth 1 -type d -name 'wp-static-cache*' 2>/dev/null)
if [ -n "$pluginList" ]; then
while IFS= read -r item; do
(( found++ )) || printSection "$dir"
printDotText "${item#"$olsVhostsPath/$dir/www"}" "${fontRed}malware$fontReset"
done <<< "$pluginList"
fi
# other
for subdir in wp-content/mu-plugins wp-content/plugins; do
pluginList=$(find "$olsVhostsPath/$dir/www/$subdir" -maxdepth 1 -regextype posix-extended -regex '^.*[^0-9a-f][0-9a-f]{6,8}(\.php)?$' 2>/dev/null)
if [ -n "$pluginList" ]; then
while IFS= read -r item; do
(( found++ )) || printSection "$dir"
printDotText "${item#"$olsVhostsPath/$dir/www"}" "${fontYellow}warning$fontReset"
done <<< "$pluginList"
fi
done
done < <(awk 'NF' <<< "$vhostsList")
}
@@ -153,7 +122,7 @@ function cmdMalwareFilesCheck() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
+187 -179
View File
@@ -2,7 +2,7 @@ openlitespeedLabel="[OpenLiteSpeed]"
# Renders the OpenLiteSpeed Kubernetes YAML manifest via Helm.
function cmdOpenlitespeedYamlRender() {
local templateFile="templates/$olsKube.yaml"
local templateFile="templates/$openlitespeedKube.yaml"
printSection "Render YAML file | Helm"
printDotText "Template" "$appAssetsPath/k3s/$templateFile"
@@ -26,13 +26,13 @@ function cmdOpenlitespeedYamlRender() {
}
local adminWhiteList=() adminWhiteStr
for i in "${!olsAdminWhiteList[@]}"; do
adminWhiteList[$i]="\"${olsAdminWhiteList[$i]}\""
for i in "${!openlitespeedAdminWhiteList[@]}"; do
adminWhiteList[$i]="\"${openlitespeedAdminWhiteList[$i]}\""
done
adminWhiteStr=$(IFS=','; printf '%s\n' "${adminWhiteList[*]}")
local varsFile
varsFile=$(mktemp "/tmp/$olsKube.vars.XXXXXX.yaml") || {
varsFile=$(mktemp "/tmp/$openlitespeedKube.vars.XXXXXX.yaml") || {
printDotText "render" "$labelFail"
printDanger "Create temp variables file"
return 1
@@ -42,24 +42,21 @@ function cmdOpenlitespeedYamlRender() {
cat > "$varsFile" <<EOF
openlitespeedHelm: true
namespace: $k3sNamespace
openlitespeed: $olsKube
olsPodVhostsPath: $olsPodVhostsPath
olsPodPrivatePath: $olsPodPrivatePath
olsPodPublicPath: $olsPodPublicPath
olsVhostsPath: $olsVhostsPath
olsPrivatePath: $olsPrivatePath
olsPublicPath: $olsPublicPath
olsConfigPath: $olsConfigPath
olsPhpIniPath: $olsPhpIniPath
olsLogsPath: $olsLogsPath
olsAdminPath: $olsAdminPath
olsAdminWhiteList: $adminWhiteStr
openlitespeed: $openlitespeedKube
openlitespeedConfigPath: $openlitespeedConfigPath
openlitespeedPhpIniPath: $openlitespeedPhpIniPath
openlitespeedLogsPath: $openlitespeedLogsPath
openlitespeedVhostDataPath: $openlitespeedVhostDataPath
openlitespeedVhostSharedPath: $openlitespeedVhostSharedPath
openlitespeedAdminPath: $openlitespeedAdminPath
openlitespeedAdminWhiteList: $adminWhiteStr
vhostsPath: $vhostsPath
EOF
printDotText "Result" "$olsYaml"
mkdir -p -- "$(dirname -- "$olsYaml")" || return 1
fileBackup "$olsYaml"
helm template stack "$appAssetsPath/k3s" -f "$varsFile" -f "$profileCpuFile" -f "$profileMemoryFile" --show-only "$templateFile" > "$olsYaml" || {
printDotText "Result" "$openlitespeedYaml"
mkdir -p -- "$(dirname -- "$openlitespeedYaml")" || return 1
fileBackup "$openlitespeedYaml"
helm template stack "$appAssetsPath/k3s" -f "$varsFile" -f "$profileCpuFile" -f "$profileMemoryFile" --show-only "$templateFile" > "$openlitespeedYaml" || {
printDotText "render" "$labelFail"
printDanger "Render failed"
return 1
@@ -70,35 +67,8 @@ EOF
# Initializes OpenLiteSpeed after Kubernetes deployment: patches Traefik, sets admin credentials, PHP config, rules, and restarts.
function cmdOpenlitespeedInit() {
printSection "Initialization..."
printInfo "$openlitespeedLabel Initialization..."
local ug
ug="$(stat -c "%u:%g" "$olsConfigFile")"
# Patch svc traefik
runSilent "$k3sCmd" kubectl -n kube-system patch svc traefik -p '{"spec": {"externalTrafficPolicy": "Local"}}' || {
printDotText "Patch svc traefik" "$labelFail"
return 1
}
printDotText "Patch svc traefik" "$labelDone"
cmdOpenlitespeedWaitReady || return 1
# Updating Administrator Password
runSilent cmdOpenlitespeedAdminPassUpdate "$olsAdminPass" || {
printDotText "Updating admin password" "$labelFail"
return 1
}
printDotText "Updating admin password" "$labelDone"
# Adding redirect rules
mkdir -p "$olsConfigPath/rules"
cp -n "$appAssetsPath"/openlitespeed/rules/* "$olsConfigPath/rules/"
chown -R "$ug" "$olsConfigPath/rules"
chmod 750 -R "$olsConfigPath/rules"
printDotText "Adding redirect rules" "$labelDone"
# Adding PHP configs
local profileFile="$appAssetsPath/openlitespeed/profiles/memory-$kubeMemoryProfile.config"
local children max_memory_limit memory_limit max_execution_time post_max_size upload_max_filesize
children=$(configGet "$profileFile" "children")
@@ -108,7 +78,15 @@ function cmdOpenlitespeedInit() {
post_max_size=$(configGet "$profileFile" "post_max_size")
upload_max_filesize=$(configGet "$profileFile" "upload_max_filesize")
local phpIniFile="$olsPhpIniPath/00-ols-master.ini"
"$k3sCmd" kubectl -n kube-system patch svc traefik -p '{"spec": {"externalTrafficPolicy": "Local"}}'
cmdOpenlitespeedWaitReady || return 1
cmdOpenlitespeedAdminPassUpdate "$openlitespeedAdminPass" || return 1
local ug output error
run ug error stat -c "%u:%g" "$openlitespeedConfigFile" || printDanger "$openlitespeedLabel Stat: $error"
printInfo "$openlitespeedLabel Adding PHP configs..."
local phpIniFile="$openlitespeedPhpIniPath/00-ols-master.ini"
fileBackup "$phpIniFile"
cp -f -- "$appAssetsPath/openlitespeed/php/00-ols-master.ini" "$phpIniFile"
sed -i \
@@ -119,43 +97,58 @@ function cmdOpenlitespeedInit() {
-e "s|{{post_max_size}}|$post_max_size|g" \
-e "s|{{upload_max_filesize}}|$upload_max_filesize|g" \
-- "$phpIniFile"
find "$olsPhpIniPath" -type f -exec chmod 644 {} +
printDotText "Adding PHP configs" "$labelDone"
find "$openlitespeedPhpIniPath" -type f -exec chmod 644 {} +
# Path OLS Admin config
runSilent openlitespeedAdminAllowList || {
printDotText "Path OLS Admin config" "$labelFail"
return 1
}
printDotText "Path OLS Admin config" "$labelDone"
printInfo "$openlitespeedLabel Adding redirect rules..."
mkdir -p "$openlitespeedConfigPath/rules"
cp -n "$appAssetsPath"/openlitespeed/rules/* "$openlitespeedConfigPath/rules/"
chown -R "$ug" "$openlitespeedConfigPath/rules"
chmod 750 -R "$openlitespeedConfigPath/rules"
# Path OLS config
openlitespeedConfigRebuild || {
printDotText "Path OLS config" "$labelFail"
return 1
}
printDotText "Path OLS config" "$labelDone"
printInfo "$openlitespeedLabel Path OLS config..."
fileBackup "$openlitespeedConfigFile"
openlitespeedConfigEditSet '' useIpInProxyHeader 2 || return 1
openlitespeedConfigEditSet 'fileAccessControl' checkSymbolLink 1 || return 1
openlitespeedConfigEditSet 'accessControl' allow '10.42.0.0/16T, 10.43.0.0/16T' || return 1
openlitespeedConfigEditDel 'ext[Pp]rocessor\h+lsphp' env 'PHPRC=*' || return 1
openlitespeedConfigEditSet 'ext[Pp]rocessor\h+lsphp' backlog 100 || return 1
openlitespeedConfigEditSet 'ext[Pp]rocessor\h+lsphp' procSoftLimit 700 || return 1
openlitespeedConfigEditSet 'ext[Pp]rocessor\h+lsphp' procHardLimit 800 || return 1
openlitespeedConfigEditSet 'ext[Pp]rocessor\h+lsphp' maxConns "$children" || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'PHP_INI_SCAN_DIR=*' 'PHP_INI_SCAN_DIR=:/etc/ols-php-ini' || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'PHP_LSAPI_CHILDREN=*' "PHP_LSAPI_CHILDREN=$children" || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'LSAPI_AVOID_FORK=*' 'LSAPI_AVOID_FORK=0' || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'LSAPI_MAX_IDLE=*' 'LSAPI_MAX_IDLE=120' || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'LSAPI_MAX_IDLE_CHILDREN=*' 'LSAPI_MAX_IDLE_CHILDREN=1' || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'LSAPI_PGRP_MAX_IDLE=*' 'LSAPI_PGRP_MAX_IDLE=300' || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'LSAPI_MAX_PROCESS_TIME=*' 'LSAPI_MAX_PROCESS_TIME=300' || return 1
openlitespeedConfigEditSetMasked 'ext[Pp]rocessor\h+lsphp' env 'LSAPI_SLOW_REQ_MSECS=*' 'LSAPI_SLOW_REQ_MSECS=5000' || return 1
printInfo "$openlitespeedLabel Path OLS Admin config..."
openlitespeedAdminAllowList || return 1
cmdOpenlitespeedRestart
cmdOpenlitespeedPhpKill all
cmdOpenlitespeedPhpRestart
printSuccess "$openlitespeedLabel Initialization completed"
}
# Updates OpenLiteSpeed Kubernetes resources (limits, replicas, etc.) without re-initialization.
function cmdOpenlitespeedUpdate() {
cmdOpenlitespeedYamlRender || return 1
cmdK3sYamlApplyEx "$olsYaml" || return 1
cmdK3sYamlApplyEx "$openlitespeedYaml" || return 1
}
# Installs OpenLiteSpeed into Kubernetes and runs initialization.
function cmdOpenlitespeedInstall() {
cmdOpenlitespeedYamlRender || return 1
cmdK3sYamlApplyEx "$olsYaml" || return 1
cmdK3sYamlApplyEx "$openlitespeedYaml" || return 1
cmdOpenlitespeedInit
}
# Uninstalls OpenLiteSpeed Kubernetes resources.
function cmdOpenlitespeedUninstall() {
"$k3sCmd" kubectl delete -f "$olsYaml"
"$k3sCmd" kubectl delete -f "$openlitespeedYaml"
}
# Waits until OpenLiteSpeed WebAdmin PHP is ready.
@@ -184,91 +177,101 @@ function cmdOpenlitespeedAdminPassUpdate() {
local encrypt output error
run encrypt error openlitespeedExec /usr/local/lsws/admin/fcgi-bin/admin_php -q /usr/local/lsws/admin/misc/htpasswd.php "$password" || {
printDotText "Get encrypt" "$labelFail"
printDanger "$error"
printDanger "$openlitespeedLabel Create pass | $error"
return 1
}
printDotText "Get encrypt" "$labelDone"
run output error openlitespeedExec bash -c "echo '$user:$encrypt' > /usr/local/lsws/admin/conf/htpasswd" || {
printDotText "Save data" "$labelFail"
printDanger "$error"
printDanger "$openlitespeedLabel Encrypt pass | $error"
return 1
}
printDotText "Save data" "$labelDone"
# if admin... save to <hostname>.openlitespeed
printSuccess "$openlitespeedLabel Authorization parameters updated"
}
# Restarts OpenLiteSpeed on all OLS pods.
function cmdOpenlitespeedRestart() {
local podList error
run podList error k3sPodListStatus "$olsKube" || { printDanger "Get pods: $error"; return 1; }
[[ -n "$podList" ]] || { printDanger "Pods not found"; return 1; }
local output error podList
local pod phase output
while IFS='|' read -r pod phase; do
printSection "$pod"
if ! run podList error k3sPodListStatus "$openlitespeedKube"; then
printDanger "Get pods: $error"
elif [[ -z "$podList" ]]; then
printDanger "Pods not found"
else
while IFS='|' read -r pod phase; do
printSection "$pod"
if [[ "$phase" != "Running" ]]; then
printDotText "Phase" "$fontRed$phase$fontReset"
else
printDotText "Phase" "$fontGreen$phase$fontReset"
if ! run output error openlitespeedPodExec "$pod" /usr/local/lsws/bin/lswsctrl restart; then
printDotText "Restart" "$labelUnknown"
printDanger "$error"
elif [[ "$output" =~ "[OK]" ]]; then
printDotText "Restart" "$fontGreen$output$fontReset"
if [[ "$phase" != "Running" ]]; then
printDotText "Phase" "$fontRed$phase$fontReset"
else
printDotText "Restart" "$fontRed$output$fontReset"
printDotText "Phase" "$fontGreen$phase$fontReset"
if ! run output error openlitespeedPodExec "$pod" /usr/local/lsws/bin/lswsctrl restart; then
printDotText "Restart" "$labelUnknown"
printDanger "$error"
elif [[ "$output" =~ "[OK]" ]]; then
printDotText "Restart" "$fontGreen$output$fontReset"
else
printDotText "Restart" "$fontRed$output$fontReset"
fi
# k3sRun wait --for=condition=Ready "pod/$pod" --timeout=10s >/dev/null 2>&1 || true
fi
fi
done < <(awk 'NF' <<< "$podList")
done < <(awk 'NF' <<< "$podList")
fi
}
# Restarts PHP workers on all OLS pods.
function cmdOpenlitespeedPhpKill() {
local target="$1"
[[ -n "$target" ]] || { printRow; printDanger "Target not specified"; return 1; }
function cmdOpenlitespeedPhpRestart() {
local output error podList
local podList error
run podList error k3sPodListStatus "$olsKube" || { printRow; printDanger "Get pods: $error"; return 1; }
[[ -n "$podList" ]] || { printRow; printDanger "Pods not found"; return 1; }
if ! run podList error k3sPodListStatus "$openlitespeedKube"; then
printDanger "Get pods: $error"
elif [[ -z "$podList" ]]; then
printDanger "Pods not found"
else
while IFS='|' read -r pod phase; do
printSection "$pod"
local uid=""
if [[ "$target" != "all" ]]; then
local vhostList
run vhostList error openlitespeedConfigVhostList || { printRow; printDanger "Cannot get vhost list: $error"; return 1; }
listContains "$target" "$vhostList" || { printRow; printDanger "Unknown domain: $target"; return 1; }
uid=$(domainToUid "$target")
[[ -n "$uid" ]] || { printDanger "Cannot resolve UID for: $target"; return 1; }
fi
local pod phase
while IFS='|' read -r pod phase; do
printSection "$pod"
if [[ "$phase" != "Running" ]]; then
printDotText "Phase" "$fontRed$phase$fontReset"
else
printDotText "Phase" "$fontGreen$phase$fontReset"
if [[ -n "$uid" ]]; then
runSilent openlitespeedPodExec "$pod" pkill -u "$uid" -x lsphp
if [[ "$phase" != "Running" ]]; then
printDotText "Phase" "$fontRed$phase$fontReset"
else
runSilent openlitespeedPodExec "$pod" pkill -x lsphp
printDotText "Phase" "$fontGreen$phase$fontReset"
run output error openlitespeedPodExec "$pod" killall -USR1 lsphp || true
printDotText "PHP" "process restart"
fi
printDotText "kill$fontBlue lsphp$fontReset processes for $target" "$labelDone"
fi
done < <(awk 'NF' <<< "$podList")
done < <(awk 'NF' <<< "$podList")
fi
}
# Restarts PHP (kill) workers on all OLS pods.
function cmdOpenlitespeedPhpKill() {
local output error podList
if ! run podList error k3sPodListStatus "$openlitespeedKube"; then
printDanger "Get pods: $error"
elif [[ -z "$podList" ]]; then
printDanger "Pods not found"
else
while IFS='|' read -r pod phase; do
printSection "$pod"
if [[ "$phase" != "Running" ]]; then
printDotText "Phase" "$fontRed$phase$fontReset"
else
printDotText "Phase" "$fontGreen$phase$fontReset"
run output error openlitespeedPodExec "$pod" pkill -9 -f lsphp || true
printDotText "PHP" "process kill"
fi
done < <(awk 'NF' <<< "$podList")
fi
}
# Prints OpenLiteSpeed and PHP versions for each OLS pod.
function cmdOpenlitespeedInfo() {
local output error podList ver pid
if ! run podList error k3sPodListStatus "$olsKube"; then
if ! run podList error k3sPodListStatus "$openlitespeedKube"; then
printDanger "Get pods: $error"
elif [[ -z "$podList" ]]; then
printDanger "Pods not found"
@@ -310,7 +313,7 @@ function cmdOpenlitespeedInfo() {
printSection "Hosts"
local vhostList vhostDown
if run output error openlitespeedConfigVhostList; then
if run output error openlitespeedVhostList; then
mapfile -t vhostList < <(awk 'NF' <<< "$output")
printDotText "all" "${#vhostList[@]}"
else
@@ -318,7 +321,7 @@ function cmdOpenlitespeedInfo() {
printDanger "$error"
fi
if run output error openlitespeedConfigVhostList "down"; then
if run output error openlitespeedVhostList "down"; then
mapfile -t vhostDownList < <(awk 'NF' <<< "$output")
printDotText "down" "${#vhostDownList[@]}"
else
@@ -326,17 +329,18 @@ function cmdOpenlitespeedInfo() {
printDanger "$error"
fi
local count="$(find "$olsVhostsPath" -mindepth 1 -maxdepth 1 -type d | wc -l)"
printDotText "directories" "$fontGray$olsVhostsPath$fontReset $count"
local count="$(find "$vhostsPath" -mindepth 1 -maxdepth 1 -type d | wc -l)"
printDotText "directories" "$fontGray$vhostsPath$fontReset $count"
}
# Marks a virtual host as suspended.
# $1 (domain): site domain name.
function cmdOpenlitespeedVhostDown() {
function cmdOpenlitespeedVHostDown() {
local error
printRow
local error
if ! runError error openlitespeedVhostConfigDown "$@"; then
if ! runError error openlitespeedVHostDown "$@"; then
printDotText "VHost down" "$labelFail"
printDanger "$error"
else
@@ -347,11 +351,12 @@ function cmdOpenlitespeedVhostDown() {
# Marks a virtual host as active.
# $1 (domain): site domain name.
function cmdOpenlitespeedVhostUp() {
function cmdOpenlitespeedVHostUp() {
local error
printRow
local error
if ! runError error openlitespeedVhostConfigUp "$@"; then
if ! runError error openlitespeedVHostUp "$@"; then
printDotText "VHost up" "$labelFail"
printDanger "$error"
else
@@ -363,10 +368,11 @@ function cmdOpenlitespeedVhostUp() {
# Lists virtual hosts with optional status filtering.
# [$1] (type): all (default) | up | down.
function cmdOpenlitespeedSiteList() {
local output error type="${1:-all}"
printRow
local output error type="${1:-all}"
if ! run output error openlitespeedConfigVhostList "$type"; then
if ! run output error openlitespeedVhostList "$type"; then
printDanger "$error"
else
printText "$output"
@@ -375,66 +381,67 @@ function cmdOpenlitespeedSiteList() {
# Updates the Traefik middleware allowlist for OpenLiteSpeed WebAdmin.
function cmdOpenlitespeedAdminWhiteList() {
local output error
printRow
local output error
run output error openlitespeedAdminWhiteList || { printDotText "Update" "$labelFail"; printDanger "$error"; return 1; }
printDotText "White list" "$output"
printDotText "Update" "$labelDone"
}
# Updates OpenLiteSpeed WebAdmin access control from current Traefik pod IPs.
function cmdOpenlitespeedAdminAllowList() {
printRow
local output error
run output error openlitespeedAdminAllowList || { printDotText "Update" "$labelFail"; printDanger "$error"; return 1; }
printDotText "Allow list: ${output:-$labelNull}"
printDotText "Update" "$labelDone"
cmdOpenlitespeedRestart
if ! run output error openlitespeedAdminWhiteList; then
printDotText "Update" "$labelFail"
printDanger "$error"
else
printDotText "White list" "$output"
printDotText "Update" "$labelDone"
fi
}
# Sets aliases for an OpenLiteSpeed virtual host.
# $1 (domain): primary site domain name.
# $@ (...): alias domain names.
function cmdOpenlitespeedVhostAliasSet() {
local domain
domain=$(domainPrepare "$1")
function cmdOpenlitespeedAliasSet() {
local output error
printRow
domainCheck "$domain" || return 1
local vhostList aliasList output error
if ! run vhostList error openlitespeedConfigVhostList; then
appError "Error retrieving vhost list: $error"
return 1
elif ! listContains "$domain" "$vhostList"; then
appError "Domain not exists in OpenLiteSpeed config: $domain"
return 1
fi
run output error openlitespeedVhostSet "$@" || {
printDotText "Set" "$labelFail"
if ! run output error openlitespeedAliasSet "$@"; then
printDanger "$error"
return 1
}
elif [[ -z "$output" ]]; then
printText "$labelNull"
cmdOpenlitespeedRestart
else
printText "$output"
cmdOpenlitespeedRestart
fi
}
printDotText "Alias" "${output:-$labelNull}"
printDotText "Set" "$labelDone"
cmdOpenlitespeedRestart
# Updates OpenLiteSpeed WebAdmin access control from current Traefik pod IPs.
function cmdOpenlitespeedAdminAllowList() {
local output error
printRow
if ! run output error openlitespeedAdminAllowList; then
printDotText "Update" "$labelFail"
printDanger "$error"
elif [[ -z "$output" ]]; then
printDotText "Allow list" "$labelNull"
printDotText "Update" "$labelDone"
cmdOpenlitespeedRestart
else
printDotText "Allow list" "$output"
printDotText "Update" "$labelDone"
cmdOpenlitespeedRestart
fi
}
# Lists aliases for a domain or all domains.
# [$1] (target): domain name, or "all" to list all.
function cmdOpenlitespeedAliasList() {
local output error domain target="$1"
printRow
local output error domain target="$1"
if [[ "$target" == all ]]; then
if ! run output error openlitespeedConfigAliasList; then
if ! run output error openlitespeedAliasList; then
printDanger "$error"
elif [[ -z "$output" ]]; then
printText "$labelNull"
@@ -443,7 +450,7 @@ function cmdOpenlitespeedAliasList() {
fi
else
domain=$(domainPrepare "$target")
if ! run output error openlitespeedConfigVhostAliasList "$domain"; then
if ! run output error openlitespeedVhostAlias "$domain"; then
printDanger "$error"
elif [[ -z "$output" ]]; then
printText "$labelNull"
@@ -455,9 +462,10 @@ function cmdOpenlitespeedAliasList() {
# Tests the OpenLiteSpeed configuration inside the container.
function cmdOpenlitespeedConfigCheck() {
local output error
printRow
local output error
run output error openlitespeedExec sh -lc "/usr/local/lsws/bin/openlitespeed -t 2>/dev/null || true"
if grep -qi 'configuration failed!' <<< "$output"; then
printDotText "Check config" "$labelFail"
@@ -475,7 +483,7 @@ function cmdOpenlitespeedVhostRebuild() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
+84 -48
View File
@@ -113,10 +113,6 @@ EOF
function cmdPostfixInit() {
printSection "Initialization..."
touch "$postfixConfigPath/$postfixDomainsFile" || return 1
touch "$postfixConfigPath/$postfixAliasesFile" || return 1
touch "$postfixConfigPath/$postfixSendersFile" || return 1
postfixDkimAdd "$postfixHost" || {
printDotText "Add DKIM for host" "$labelFail"
return 1
@@ -150,20 +146,6 @@ function cmdPostfixUninstall() {
"$k3sCmd" kubectl delete -f "$postfixYaml"
}
function cmdPostfixUser() {
local output error
printRow
if ! run output error postfixUserList; then
printDanger "$error"
elif [[ -z "$output" ]]; then
printText "$labelNull"
else
printText "$output"
fi
}
# Prints the Postfix mail version.
function cmdPostfixInfo() {
local output error podList ver pid
@@ -208,69 +190,123 @@ function cmdPostfixInfo() {
fi
}
# Sets a virtual alias forward-to address for a domain and saves it to site config.
# $1 (domain): site domain name.
# $2 (mail): forward-to email address.
function cmdPostfixVirtualAliasSetEx() {
local domain="$1"
[[ -n "$domain" ]] || { printDanger "$postfixLabel Domain not specified"; return 1; }
local mail="$2"
[[ -n "$mail" ]] || { printDanger "$postfixLabel Mail not specified"; return 1; }
local domainList output error
if ! run domainList error postfixDomainList; then
printDanger "$postfixLabel postfixDomainList: $error"
return 1
elif ! listContains "$domain" "$domainList"; then
printDanger "$postfixLabel Domain not found in postfixDomainList"
return 1
elif ! run output error siteConfigSet "$domain" "postfixForwardTo" "$mail"; then
printDanger "$postfixLabel siteConfigSet: $error"
elif ! run output error postfixVirtualAliasSet "@$domain" "$mail"; then
printDanger "$postfixLabel postfixVirtualAliasSet: $error"
fi
}
# Checks MTA host DNS records (A, SPF, PTR, DKIM) against configured values.
function cmdPostfixMtaDnsCheck() {
local label output error text
printSection "MTA DNS: $postfixHost"
# A record
if ! run output error dig +short A "$postfixHost" "$dnsResolver"; then
printDotText "A record" "$fontRed${output:-$error}$fontReset"
label="$postfixLabel A record: $postfixHost"
if ! run output error dig +short A "$postfixHost" "$postfixResolver"; then
printDanger "$label"
else
text=$(printf '%s' "$output" | paste -sd, - | sed 's/,/ \/ /g')
if grep -Fxq -- "$postfixIp" <<<"$output"; then
printDotText "A record" "$fontGreen$text$fontReset"
printSuccess "$label | $text"
else
printDotText "A record" "$fontYellow$text$fontReset"
printWarning "$label | $text"
fi
fi
# SPF record
if ! run output error dig +short TXT "$postfixHost" "$dnsResolver"; then
printDotText "SPF record" "$fontRed${output:-$error}$fontReset"
label="$postfixLabel SPF record: $postfixHost"
if ! run output error dig +short TXT "$postfixHost" "$postfixResolver"; then
printDanger "$label"
elif grep -Eq '^"?v=spf1([[:space:]]|")' <<<"$output"; then
printDotText "SPF record" "$fontGreen$output$fontReset"
printSuccess "$label | $output"
else
printDotText "SPF record" "$fontRed$output$fontReset"
printWarning "$label | $output"
fi
# PTR record
if ! run output error dig -x "$postfixIp" +short "$dnsResolver"; then
printDotText "PTR record" "$fontRed${output:-$error}$fontReset"
label="$postfixLabel PTR record: $postfixHost"
if ! run output error dig -x "$postfixIp" +short "$postfixResolver"; then
printDanger "$label"
else
text=$(printf '%s' "$output" | paste -sd, - | sed 's/,/ \/ /g')
if grep -Fxq -- "$postfixHost." <<<"$output"; then
printDotText "PTR record" "$fontGreen$text$fontReset"
printSuccess "$label | $text"
else
printDotText "PTR record" "$fontYellow$text$fontReset"
printWarning "$label | $text"
fi
fi
# DKIM record
label="$postfixLabel DKIM record: $postfixHost"
if ! run output error dig +short TXT "$postfixDkimSelector._domainkey.$postfixHost"; then
printDotText "DKIM record" "$fontRed${output:-$error}$fontReset"
printDanger "$label | $error"
else
local dkimDnsNorm dkimFileRaw dkimFileNorm
dkimDnsNorm=$(
printf '%s\n' "$output" |
tr -d '\n' |
sed -e 's/"//g' -e 's/[[:space:]]//g' |
sed -n 's/.*p=\([^;]*\).*/\1/p'
printf '%s\n' "$output" |
tr -d '\n' |
sed -e 's/"//g' -e 's/[[:space:]]//g' |
sed -n 's/.*p=\([^;]*\).*/\1/p'
)
dkimFileRaw=$(postfixDkimGet "$postfixHost")
dkimFileNorm=$(
printf '%s\n' "$dkimFileRaw" |
tr -d '\n' |
sed -e 's/[()"]//g' -e 's/[[:space:]]//g' |
sed -n 's/.*p=\([^;]*\).*/\1/p'
printf '%s\n' "$dkimFileRaw" |
tr -d '\n' |
sed -e 's/[()"]//g' -e 's/[[:space:]]//g' |
sed -n 's/.*p=\([^;]*\).*/\1/p'
)
if [[ "$dkimDnsNorm" == "$dkimFileNorm" ]]; then
printText "$fontGreen$dkimDnsNorm$fontReset"
printSuccess "$label | OK"
else
printText "DNS : $fontYellow$dkimDnsNorm$fontReset"
printText "File: $fontYellow$dkimFileNorm$fontReset"
printWarning "$label | DNS : $dkimDnsNorm"
printWarning "$label | FILE: $dkimFileNorm"
fi
fi
}
# Prints domain/alias/sender/SASL lists; accepts domain/alias/senders/sasl as filter.
# [$1] (filter): domain|alias|senders|sasl; omit to print all.
function cmdPostfixList() {
case "$1" in
'domain')
postfixDomainList
;;
'alias')
postfixAliasList
;;
'senders')
postfixSendersList
;;
'sasl')
postfixSaslUserList
;;
*)
printInfo "$postfixLabel Domains"
postfixDomainList
printInfo "$postfixLabel Aliases"
postfixAliasList
printInfo "$postfixLabel Senders"
postfixSendersList
printInfo "$postfixLabel SASL users"
postfixSaslUserList
;;
esac
}
+1 -1
View File
@@ -101,7 +101,7 @@ function cmdRedisUninstall() {
# local output error podList ver pid
# if ! run podList error k3sPodListStatus "$olsKube"; then
# if ! run podList error k3sPodListStatus "$openlitespeedKube"; then
# printDanger "Get pods: $error"
# elif [[ -z "$podList" ]]; then
# printDanger "Pods not found"
+2 -2
View File
@@ -17,7 +17,7 @@ function restoreSiteFiles() {
domain=$(domainPrepare "$1")
domainCheck "$domain" || return 1
local target="$olsVhostsPath/$domain"
local target="$vhostsPath/$domain"
local source="$2"
if [[ -z "$source" ]]; then
@@ -257,7 +257,7 @@ function restoreSite() {
# Config
printInfo "$restoreLabel $domain | Config: $sourceConf"
if [[ -n "$sourceConf" ]]; then
if ! runError error cp -f -- "$sourceConf" "$olsVhostsConfigPath/$domain.conf"; then
if ! runError error cp -f -- "$sourceConf" "$openlitespeedVhostsPath/$domain.conf"; then
printDanger "$restoreLabel $domain | Config: $error"
return 1
fi
+75 -90
View File
@@ -202,23 +202,27 @@ function cmdOpenlitespeed() {
;;
up)
printTitle " $openlitespeedLabel Up $@"
cmdOpenlitespeedVhostUp "$@"
cmdOpenlitespeedVHostUp "$@"
;;
down)
printTitle " $openlitespeedLabel Down $@"
cmdOpenlitespeedVhostDown "$@"
cmdOpenlitespeedVHostDown "$@"
;;
alias)
printTitle " $openlitespeedLabel Alias $1"
cmdOpenlitespeedVhostAliasSet "$@"
cmdOpenlitespeedAliasSet "$@"
;;
restart)
printTitle " $openlitespeedLabel Restart"
cmdOpenlitespeedRestart
;;
php_kill)
printTitle " $openlitespeedLabel Kill PHP $@"
cmdOpenlitespeedPhpKill "$@"
restart_php)
printTitle " $openlitespeedLabel Restart PHP"
cmdOpenlitespeedPhpRestart
;;
kill_php)
printTitle " $openlitespeedLabel Kill PHP"
cmdOpenlitespeedPhpKill
;;
white_list)
printTitle " $openlitespeedLabel White list update"
@@ -276,13 +280,22 @@ function cmdPostfix() {
printTitle " $postfixLabel Info"
cmdPostfixInfo
;;
status)
printTitle " $postfixLabel Status"
cmdPostfixMtaDnsCheck
list)
if [[ -z "$1" ]]; then
printInfo " $postfixLabel List all"
else
printInfo " $postfixLabel List $action"
fi
cmdPostfixList "$@"
;;
user)
printTitle " $postfixLabel User list"
cmdPostfixUser
domain)
printInfo " $postfixLabel Domain add"
postfixDomainAdd "$@"
postfixPostmapRebuild
;;
alias)
printInfo " $postfixLabel Set alias for domain"
cmdPostfixVirtualAliasSetEx "$@"
;;
dkim)
printInfo " $postfixLabel DKIM record for DNS (autocreate)"
@@ -544,51 +557,21 @@ function cmdCron() {
}
function cmdBackup() {
local action="${1:-}"
shift || true
case "$action" in
run)
printTitle " $systemLabel Backup of target"
cmdBackupRun "$@"
;;
list)
printTitle " $systemLabel List of backups on local storage"
cmdBackupList
;;
size)
printTitle " $systemLabel List of Backup Sizes"
cmdBackupSize
;;
# remove)
# printTitle " $backupLabel Remove of backups on local storage"
# cmdStorageBackupRemove
# ;;
*)
printTitle " $systemLabel Backup"
printRow
printWarning "Unsupported or empty command: $action"
cmdHelpBackup
;;
esac
if [[ -n "$1" ]]; then
cmdBackupRun "$@"
else
printDanger "$backupLabel Empty command"
cmdHelpBackup
fi
}
function cmdRestore() {
local action="${1:-}"
shift || true
case "$action" in
run)
printTitle " $restoreLabel Backup of target"
restoreRun "$@"
;;
*)
printTitle " $restoreLabel"
printRow
printWarning "Unsupported or empty command: $action"
cmdHelpRestore
;;
esac
if [[ -n "$1" ]]; then
restoreRun "$@"
else
printDanger "$restoreLabel Empty command"
cmdHelpRestore
fi
}
function cmdStorage() {
@@ -604,10 +587,6 @@ function cmdStorage() {
printTitle " $systemLabel Comparison table"
cmdStorageBackupCompare
;;
size)
printTitle " $systemLabel List of Backup Sizes on external storage"
cmdStorageBackupSize
;;
sync)
printTitle " $systemLabel Synchronization with external storage"
cmdStorageBackupSync "$@"
@@ -625,12 +604,6 @@ function cmdStorage() {
esac
}
# Dispatches a named script sub-command and redirects output to a timestamped log file.
# $1 (option): script name (backup, mariadb-dump, worker-observer, metric-kube, metric-sites, diag-report-ai-short, diag-report-ai-full).
function cmdScript() {
cmdScriptRun "$@"
}
function cmdInstall() {
printTitle " $ks3Label Full install"
if cmdRouterConfirm "Are you sure you want to$fontRed INSTALL$fontReset $fontBlue FULL infrastrutute$fontReset?"; then
@@ -677,8 +650,8 @@ function cmdMalware() {
printTitle " Malware user list"
cmdMalwareUserList
;;
plugin)
printTitle " Malware plugin list"
muplugin)
printTitle " Malware MU plugin list"
cmdMalwareMuPluginList
;;
file)
@@ -701,30 +674,42 @@ function cmdRouter() {
printHeader
case "$action" in
-k|--k3s) cmdK3s "$@" ;;
-m|--mariadb) cmdMariadb "$@" ;;
-r|--redis) cmdRedis "$@" ;;
-o|--ols) cmdOpenlitespeed "$@" ;;
-p|--postfix) cmdPostfix "$@" ;;
-w|--worker) cmdWorker "$@" ;;
-s|--site) cmdSite "$@" ;;
--metric) cmdMetric "$@" ;;
--wp) cmdWordpress "$@" ;;
--sftp) cmdSftp "$@" ;;
--cron) cmdCron "$@" ;;
--shell) cmdShell "$@" ;;
--log) cmdLog "$@" ;;
--describe) cmdDescribe "$@" ;;
--delete) cmdDelete "$@" ;;
--backup) cmdBackup "$@" ;;
--restore) cmdRestore "$@" ;;
--storage) cmdStorage "$@" ;;
--script) cmdScript "$@" ;;
--install) cmdInstall "$@" ;;
--test) cmdTest "$@" ;;
--malware) cmdMalware "$@" ;;
--help) cmdHelp "$@" ;;
dev) appDev "$@" ;;
-k|--k3s) cmdK3s "$@" ;;
-m|--mariadb) cmdMariadb "$@" ;;
-r|--redis) cmdRedis "$@" ;;
-o|--ols) cmdOpenlitespeed "$@" ;;
-p|--postfix) cmdPostfix "$@" ;;
-w|--worker) cmdWorker "$@" ;;
-s|--site) cmdSite "$@" ;;
--metric) cmdMetric "$@" ;;
--wp) cmdWordpress "$@" ;;
--sftp) cmdSftp "$@" ;;
--cron) cmdCron "$@" ;;
--shell)
printTitle " Shell $@"
cmdShell "$@"
;;
--log)
printTitle " Log $@"
cmdLog "$@"
;;
--describe)
printTitle " Describe $@"
cmdDescribe "$@"
;;
--delete)
printTitle " Delete $@ $fontRed[DANGER]$fontReset"
cmdDelete "$@"
;;
-b|--backup) cmdBackup "$@" ;;
--restore) cmdRestore "$@" ;;
--storage) cmdStorage "$@" ;;
--script) cmdScript "$@" ;;
--install) cmdInstall "$@" ;;
--test) cmdTest "$@" ;;
--malware) cmdMalware "$@" ;;
--help) cmdHelp "$@" ;;
dev) appDev "$@" ;;
esac
local status=$?
+7 -6
View File
@@ -53,14 +53,18 @@ function cmdScriptDiagReportAi() {
printFinish
}
function cmdScriptRun() {
# Dispatches a named script sub-command and redirects output to a timestamped log file.
# $1 (option): script name (backup, mariadb-dump, worker-observer, metric-kube, metric-sites, diag-report-ai-short, diag-report-ai-full).
function cmdScript() {
local option="$1"
printText "Output: $logPath/$option/${appDate}_$appTime.log"
printText "$logPath/$option/${appDate}_$appTime.log"
printRow
printFile="$logPath/$option/${appDate}_$appTime.log"
local logFileOld="$logFile"
local logFileOld
logFileOld="$logFile"
logFile=""
case "$option" in
@@ -85,9 +89,6 @@ function cmdScriptRun() {
diag-report-ai-full)
cmdScriptDiagReportAi "full"
;;
unigma)
cmdUnigma
;;
*)
printFile=""
logFile="$logFileOld"
+54 -54
View File
@@ -9,10 +9,10 @@ siteWordpressLabel="[Wordpress]"
function cmdSiteAdd() {
local domain sourceFiles
domain=$(domainPrepare "$1")
shift || true
shift
sourceFiles="${1:-$appAssetsPath/vhost/default}"
shift || true
shift
printSection "Add site"
printDotText "domain" "$domain"
@@ -36,10 +36,10 @@ function cmdSiteAdd() {
function cmdSiteRemove() {
local domain mode
domain=$(domainPrepare "$1")
shift || true
shift
mode="$1"
shift || true
shift
if [[ ! "$mode" == "-f" && ! "$mode" == "--force" ]]; then
if ! cmdRouterConfirm "Are you sure you want to$fontRed DELETE$fontReset the site $fontBlue$domain$fontReset?"; then
@@ -141,13 +141,13 @@ function cmdSiteRename() {
function cmdSiteAddWordpress() {
local domain sourceFiles
domain=$(domainPrepare "$1")
shift || true
shift
sourceFiles="${1:-$appAssetsPath/vhost/wordpress}"
if [[ ! -e "$sourceFiles" ]]; then
sourceFiles="$appAssetsPath/vhost/wordpress.tar.gz"
fi
shift || true
shift
printSection "Add site (Wordpress)"
printDotText "domain" "$domain"
@@ -185,7 +185,7 @@ function cmdSiteConfigRebuild() {
printDotText "OLS vhost" "$labelDone"
fi
if ! runError error openlitespeedConfigVhostSet "$domain"; then
if ! runError error openlitespeedConfigRebuild "$domain"; then
printDotText "OLS config" "$labelFail"
printDanger "$error"
else
@@ -247,7 +247,7 @@ function cmdSitePasswordReset() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
@@ -280,7 +280,7 @@ function cmdSiteAuthReset() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
@@ -375,7 +375,7 @@ function cmdSiteInfo() {
fi
local limits blockLimit inodeLimit
if ! run limits error openlitespeedVhostQuotaGet "$ug"; then
if ! run limits error openlitespeedVhostQuota "$ug"; then
printDotText "quota block limit" "$labelUnknown"
printDotText "quota inode limit" "$labelUnknown"
else
@@ -410,25 +410,25 @@ function cmdSiteInfo() {
fi
printSection "OpenLiteSpeed"
if [[ ! -f "$olsVhostsConfigPath/$domain.conf" ]]; then
printDotText "file$fontReset" "$fontRed$olsVhostsConfigPath/$domain.conf$fontReset"
if [[ ! -f "$openlitespeedVhostsPath/$domain.conf" ]]; then
printDotText "file$fontReset" "$fontRed$openlitespeedVhostsPath/$domain.conf$fontReset"
printDotText "file$fontReset" "${fontRed}not found$fontReset"
else
printDotText "file$fontReset" "$fontGreen$olsVhostsConfigPath/$domain.conf$fontReset"
printDotText "file$fontReset" "$fontGreen$openlitespeedVhostsPath/$domain.conf$fontReset"
fi
if [[ ! -d "$olsVhostsPath/$domain" ]]; then
printDotText "path$fontReset" "$fontRed$olsVhostsPath/$domain$fontReset"
if [[ ! -d "$vhostsPath/$domain" ]]; then
printDotText "path$fontReset" "$fontRed$vhostsPath/$domain$fontReset"
printDotText "path$fontReset" "${fontRed}not found$fontReset"
else
printDotText "path$fontReset" "$fontGreen$olsVhostsPath/$domain$fontReset"
printDotText "path$fontReset" "$fontGreen$vhostsPath/$domain$fontReset"
fi
if [[ ! -d "$olsPrivatePath/$domain" ]]; then
printDotText "data$fontReset" "$fontRed$olsPrivatePath/$domain$fontReset"
if [[ ! -d "$openlitespeedVhostDataPath/$domain" ]]; then
printDotText "data$fontReset" "$fontRed$openlitespeedVhostDataPath/$domain$fontReset"
printDotText "data$fontReset" "${fontRed}not found$fontReset"
else
printDotText "data$fontReset" "$fontGreen$olsPrivatePath/$domain$fontReset"
printDotText "data$fontReset" "$fontGreen$openlitespeedVhostDataPath/$domain$fontReset"
fi
}
@@ -489,7 +489,7 @@ function cmdSiteStatus() {
fi
local limits blockLimit inodeLimit
if ! run limits error openlitespeedVhostQuotaGet "$ug"; then
if ! run limits error openlitespeedVhostQuota "$ug"; then
printDotText "quota block limit" "$labelFail"
printDotText "quota inode limit" "$labelFail"
else
@@ -519,7 +519,7 @@ function cmdSiteStatus() {
printSection "Path | existence, owner, permissions, ACL:nobody"
local path
path="$olsVhostsPath/$domain"
path="$vhostsPath/$domain"
label="vhost $fontBlue/$fontReset"
note="${fontGray}755:root:root$fontReset"
if [[ ! -d "$path" ]]; then
@@ -530,7 +530,7 @@ function cmdSiteStatus() {
printDotText "$label" "$note $labelPass"
fi
path="$olsVhostsPath/$domain/www"
path="$vhostsPath/$domain/www"
label="vhost $fontBlue/www$fontReset"
note="${fontGray}2750:u:g acl:r-x$fontReset"
if [[ ! -d "$path" ]]; then
@@ -547,7 +547,7 @@ function cmdSiteStatus() {
local dir
dirs=(session tmp)
for dir in "${dirs[@]}"; do
path="$olsVhostsPath/$domain/$dir"
path="$vhostsPath/$domain/$dir"
label="vhost $fontBlue/$dir$fontReset"
note="${fontGray}770:u:g acl:rwx$fontReset"
if [[ ! -d "$path" ]]; then
@@ -561,7 +561,7 @@ function cmdSiteStatus() {
fi
done
path="$olsPrivatePath/$domain"
path="$openlitespeedVhostDataPath/$domain"
label="vhost-data $fontBlue/$fontReset"
note="${fontGray}750:u:g acl:r-x$fontReset"
if [[ ! -d "$path" ]]; then
@@ -574,7 +574,7 @@ function cmdSiteStatus() {
printDotText "$label" "$note $labelPass"
fi
path="$olsPrivatePath/$domain/bootstrap.php"
path="$openlitespeedVhostDataPath/$domain/bootstrap.php"
label="vhost-data $fontBlue/bootstrap.php$fontReset"
note="${fontGray}600:u:g acl:r--$fontReset"
if [[ ! -f "$path" ]]; then
@@ -589,7 +589,7 @@ function cmdSiteStatus() {
# fileSignatureAclDiff "$path" "user:nobody:r--"
printSection "OpenLiteSpeed"
if ! run vhostList error openlitespeedConfigVhostList; then
if ! run vhostList error openlitespeedVhostList; then
printDotText "get vhost list" "$labelFail"
else
note="$fontGray$domain$fontReset"
@@ -600,7 +600,7 @@ function cmdSiteStatus() {
fi
fi
note="$fontGray$domain.conf$fontReset"
if [[ ! -f "$olsVhostsConfigPath/$domain.conf" ]]; then
if [[ ! -f "$openlitespeedVhostsPath/$domain.conf" ]]; then
printDotText "config" "$note $labelFail"
else
printDotText "config" "$note $labelPass"
@@ -715,120 +715,120 @@ function siteFilesCheck() {
ug=$(domainToUser "$domain")
dots=30
# fileSignatureDiff "$olsVhostsPath/$domain" "755:root:root"
if ! run output error fileSignatureDiff "$olsVhostsPath/$domain" "755:root:root"; then
# fileSignatureDiff "$vhostsPath/$domain" "755:root:root"
if ! run output error fileSignatureDiff "$vhostsPath/$domain" "755:root:root"; then
printDanger "${error:-$output}"
elif [[ -n "$output" ]]; then
local prefix=":$olsVhostsPath/$domain"
local prefix=":$vhostsPath/$domain"
printDot "$dots" "${fontCyan}vhost d 755:root:root$fontReset" "" "${output/$prefix/ /}"
fi
# fileSignatureDiffList "$olsVhostsPath/$domain/www" "d" "2750|$ug:$ug"
if ! run output error fileSignatureDiffList "$olsVhostsPath/$domain/www" "d" "2750|$ug:$ug"; then
# fileSignatureDiffList "$vhostsPath/$domain/www" "d" "2750|$ug:$ug"
if ! run output error fileSignatureDiffList "$vhostsPath/$domain/www" "d" "2750|$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}www d 2750:u:g$fontReset"
local prefix=":$olsVhostsPath/$domain/www/"
local prefix=":$vhostsPath/$domain/www/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsVhostsPath/$domain/www" "f" "(600|640):$ug:$ug"
if ! run output error fileSignatureDiffList "$olsVhostsPath/$domain/www" "f" "(600|640):$ug:$ug"; then
# fileSignatureDiffList "$vhostsPath/$domain/www" "f" "(600|640):$ug:$ug"
if ! run output error fileSignatureDiffList "$vhostsPath/$domain/www" "f" "(600|640):$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}www f (600|640):u:g$fontReset"
local prefix=":$olsVhostsPath/$domain/www/"
local prefix=":$vhostsPath/$domain/www/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsVhostsPath/$domain/tmp" "d" "770:$ug:$ug"
if ! run output error fileSignatureDiffList "$olsVhostsPath/$domain/tmp" "d" "770:$ug:$ug"; then
# fileSignatureDiffList "$vhostsPath/$domain/tmp" "d" "770:$ug:$ug"
if ! run output error fileSignatureDiffList "$vhostsPath/$domain/tmp" "d" "770:$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}tmp d 770:u:g$fontReset"
local prefix=":$olsVhostsPath/$domain/tmp/"
local prefix=":$vhostsPath/$domain/tmp/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsVhostsPath/$domain/tmp" "f" "660:$ug:$ug"
if ! run output error fileSignatureDiffList "$olsVhostsPath/$domain/tmp" "f" "660:$ug:$ug"; then
# fileSignatureDiffList "$vhostsPath/$domain/tmp" "f" "660:$ug:$ug"
if ! run output error fileSignatureDiffList "$vhostsPath/$domain/tmp" "f" "660:$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}tmp f 660:u:g$fontReset"
local prefix=":$olsVhostsPath/$domain/tmp/"
local prefix=":$vhostsPath/$domain/tmp/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsVhostsPath/$domain/session" "d" "770:$ug:$ug"
if ! run output error fileSignatureDiffList "$olsVhostsPath/$domain/session" "d" "770:$ug:$ug"; then
# fileSignatureDiffList "$vhostsPath/$domain/session" "d" "770:$ug:$ug"
if ! run output error fileSignatureDiffList "$vhostsPath/$domain/session" "d" "770:$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}session d 770:u:g$fontReset"
local prefix=":$olsVhostsPath/$domain/session/"
local prefix=":$vhostsPath/$domain/session/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsVhostsPath/$domain/session" "f" "(660|600):$ug:$ug"
if ! run output error fileSignatureDiffList "$olsVhostsPath/$domain/session" "f" "(660|600):$ug:$ug"; then
# fileSignatureDiffList "$vhostsPath/$domain/session" "f" "(660|600):$ug:$ug"
if ! run output error fileSignatureDiffList "$vhostsPath/$domain/session" "f" "(660|600):$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}session f (660|600):u:g$fontReset"
local prefix=":$olsVhostsPath/$domain/session/"
local prefix=":$vhostsPath/$domain/session/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsPrivatePath/$domain" "d" "750:$ug:$ug"
if ! run output error fileSignatureDiffList "$olsPrivatePath/$domain" "d" "750:$ug:$ug"; then
# fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "d" "750:$ug:$ug"
if ! run output error fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "d" "750:$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}data d 750:u:g$fontReset"
local prefix=":$olsPrivatePath/$domain/"
local prefix=":$openlitespeedVhostDataPath/$domain/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
fi
fi
# fileSignatureDiffList "$olsPrivatePath/$domain" "f" "600:$ug:$ug"
if ! run output error fileSignatureDiffList "$olsPrivatePath/$domain" "f" "600:$ug:$ug"; then
# fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "f" "600:$ug:$ug"
if ! run output error fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "f" "600:$ug:$ug"; then
printDanger "${error:-$output}"
else
lineCount=$(grep -c . <<< "$output" || true)
if [[ "$lineCount" -gt 0 ]]; then
local label="${fontCyan}data f 600:u:g$fontReset"
local prefix=":$olsPrivatePath/$domain/"
local prefix=":$openlitespeedVhostDataPath/$domain/"
while read -r line; do
printDot "$dots" "$label" "" "${line/$prefix/ /}"
done < <(awk 'NF' <<< "$output")
-17
View File
@@ -355,20 +355,3 @@ function cmdStorageBackupCompare() {
printDotText "$fontBlue$dir$fontReset" "[ $localStatus : $remoteStatus ]"
done < <(awk 'NF' <<< "$allDirs")
}
function cmdStorageBackupSize() {
local fileList file size total
printSection "FTP: $ftpPath"
total=0
fileList=$(ftpFileList | sort -n)
while IFS= read -r file; do
size=$(ftpPathSize "/$file" "gb")
printDotText "$file" "$size Gb"
(( total += size ))
done <<< "$fileList"
printRow
printDotText "total" "$total Gb"
}
+1 -2
View File
@@ -136,9 +136,8 @@ function cmdCronList() {
local i=0 line total
total=$(grep -c . <<< "$list")
while IFS= read -r line; do
[[ -n "$line" ]] || continue
((i++))
num=$(printf "%${#total}d" "$i")
num=$(printf "%0${#total}d" "$i")
printDotFix 20 "$num: $line"
done <<< "$list"
}
-59
View File
@@ -1,59 +0,0 @@
UNIGMA_PHP=""
UNIGMA_MEM=""
UNIGMA_EXEC=""
function cmdUnigma() {
local podList vhostsList error raw pod phase
printSection "Unigma"
run podList error k3sPodListStatus "$olsKube" || { printDanger "Get pods: $error"; return 1; }
[[ -n "$podList" ]] || { printDanger "Pods not found"; return 1; }
# run vhostList error fileList "$olsVhostsPath" d || { printDanger "$error"; return 1; }
run vhostList error openlitespeedConfigVhostList || { printDanger "Failed get list of vhosts: $error"; return 1; }
while read -r vhost; do
run raw error unigmaGetTxt "$vhost" || {
printDotText "$vhost" "${fontGray}failed get Unigma data$fontReset";
continue
}
# raw='php=8.1;mem=112M;exec=60'
unigmaParse "$raw" || {
printDotText "$vhost" "$labelFail";
printDanger "$error"
continue
}
unigmaIniSet "$vhost" "$UNIGMA_MEM" "$UNIGMA_EXEC"
case $? in
1) printDotText "$vhost" "$labelFail"; printDanger "$error"; continue ;;
2)
uid=$(domainToUid "$vhost")
[[ -n "$uid" ]] || {
printDotText "$vhost" "$labelFail";
printDanger "Cannot resolve UID for: $vhost";
continue;
}
local pod phase
while IFS='|' read -r pod phase; do
if [[ "$phase" != "Running" ]]; then
printDotText " $pod" "$fontRed$phase$fontReset"
else
runSilent openlitespeedPodExec "$pod" pkill -u "$uid" -x lsphp
printDotText " kill$fontBlue lsphp$fontReset processes for $vhost"
fi
done < <(awk 'NF' <<< "$podList")
;;
esac
unigmaPhpSet "$vhost" "$UNIGMA_PHP" || {
printDotText "$vhost" "$labelFail";
printDanger "$error"
continue
}
printDotText "$vhost" "$labelDone";
done < <(awk 'NF' <<< "$vhostList")
}
+6 -6
View File
@@ -35,7 +35,7 @@ function cmdWordpressPasswordSet() {
# $@ (...): WP-CLI sub-command and arguments.
function cmdWordpressExec() {
local target="$1"
shift || true
shift
local vhostList error
@@ -43,7 +43,7 @@ function cmdWordpressExec() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
@@ -72,7 +72,7 @@ function cmdWordpressSalt() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
@@ -102,7 +102,7 @@ function cmdWordpressCheck() {
if [[ -z "$target" ]]; then
printDanger "Target not specified";
elif ! run vhostList error openlitespeedConfigVhostList; then
elif ! run vhostList error openlitespeedVhostList; then
printDanger "Cannot get vhost list: $error";
elif [[ "$target" == "all" ]]; then
local domain
@@ -219,8 +219,8 @@ function cmdWordpressDomainUpdate() {
wordpressSearchReplace "$domain" "$rootOld" "$siteNew"
fi
if [[ -n "$abspathOld" ]]; then
printInfo "$wordpressLabel Replace in DB (6): $abspathOld --> $olsPodVhostsPath/$domain/www"
wordpressSearchReplace "$domain" "$abspathOld" "$olsPodVhostsPath/$domain/www"
printInfo "$wordpressLabel Replace in DB (6): $abspathOld --> /var/www/vhosts/$domain/www"
wordpressSearchReplace "$domain" "$abspathOld" "/var/www/vhosts/$domain/www"
fi
printInfo "$wordpressLabel Replace in DB (7): $hostOld --> $domain"
+3 -3
View File
@@ -180,7 +180,7 @@ function cmdWorkerTaskHandle() {
local output error
local uuid="worker_$(uuidgen)"
if ! run vhostList error openlitespeedConfigVhostList; then
if ! run vhostList error openlitespeedVhostList; then
printDanger "Vhost list: $error"
configSet "$taskFile" "status" "$taskStatusFailed"
configSet "$taskFile" "message" "Error getting list of virtual hosts"
@@ -192,13 +192,13 @@ function cmdWorkerTaskHandle() {
return 1
fi
if ! run output error backupSiteFiles "$domain" "$olsVhostsPath/$domain/www/$uuid"; then
if ! run output error backupSiteFiles "$domain" "$vhostsPath/$domain/www/$uuid"; then
printDanger "$error"
configSet "$taskFile" "status" "$taskStatusFailed"
configSet "$taskFile" "message" "Error create files archive: $error"
return 1
fi
if ! run output error backupSiteDatabase "$domain" "$olsVhostsPath/$domain/www/$uuid.sql"; then
if ! run output error backupSiteDatabase "$domain" "$vhostsPath/$domain/www/$uuid.sql"; then
printDanger "$error"
configSet "$taskFile" "status" "$taskStatusFailed"
configSet "$taskFile" "message" "Error create database archive: $error"