60 lines
2.1 KiB
Bash
60 lines
2.1 KiB
Bash
UNIGMA_PHP=""
|
|
UNIGMA_MEM=""
|
|
UNIGMA_EXEC=""
|
|
|
|
function cmdUnigma() {
|
|
local podList vhostsList error raw pod ready phase reason
|
|
|
|
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 ready phase reason
|
|
while IFS='|' read -r pod ready phase reason; do
|
|
if [[ "$ready" != "1" ]]; then
|
|
printDotText " $pod" "$fontGray$reason $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")
|
|
}
|