siteLabel="[Site]" siteWordpressLabel="[Wordpress]" # Creates a new site: validates domain/source/DB, creates OLS vhost, copies files, # sets up MariaDB/Redis/Postfix, rolls back via cmdSiteRemove on failure. # $1 (domain): site domain name. # $2 (sourceFiles): source directory or archive with site files. # [$3] (sourceDatabase): optional SQL dump or archive with SQL dump. function cmdSiteAdd() { local domain="$1" shift local sourceFiles="${1:-$appAssetsPath/vhost/default}" shift printRow local output error if ! run output error siteAdd "$domain" "$sourceFiles" "$@"; then printDanger "$error" printRow else printSuccess "$output" cmdOpenlitespeedRestart fi } # Removes a site and all associated MariaDB/Redis/Postfix/OLS/host resources. # $1 (domain): site domain name. function cmdSiteRemove() { local domain domain=$(domainPrepare "$1") if ! runError error domainCheck "$domain"; then printRow printDanger "$error" printRow return 1 fi shift local mode="$1" shift printRow if [[ ! "$mode" == "-f" && ! "$mode" == "--force" ]]; then read -r -p "${fontYellow}Warning!${fontReset} Are you sure you want to ${fontRed}DELETE$fontReset the site $fontBlue$domain$fontReset (y/n): " confirmation if [[ ! "$confirmation" =~ ^[Yy]$ ]]; then printRow return 0 fi fi printRow local output error if ! run output error siteRemove "$domain"; then printDanger "$error" else printSuccess "$output" fi cmdOpenlitespeedRestart } # Copies a site: exports source DB, creates target site, rebuilds WP config. # $1 (domain): source site domain name. # $2 (domainNew): target site domain name. function cmdSiteCopy() { local output error printRow if ! run output error siteCopy "$@"; then printDanger "$error" printRow return 1 fi printSuccess "$output" cmdOpenlitespeedRestart if ! runError error wordpressDomainUpdate "$2"; then printDanger "$error" printRow fi } # Renames a site by copying it to the new domain and removing the old one. # $1 (domain): current site domain name. # $2 (domainNew): new site domain name. function cmdSiteRename() { local output error printRow if ! run output error siteRename "$@" ; then printDanger "$error" printRow return 1 fi printSuccess "$output" cmdOpenlitespeedRestart if ! runError error wordpressDomainUpdate "$2"; then printDanger "$error" printRow fi } # Creates a WordPress site from the bundled template, then rebuilds WP config. # $1 (domain): site domain name. # [$2] (sourceFiles): optional source directory or archive. # [$@] (...): optional remaining arguments passed to cmdSiteAdd (e.g. database dump). function cmdSiteAddWordpress() { local domain="$1" shift local sourceFiles="${1:-$appAssetsPath/vhost/wordpress}" if [[ ! -e "$sourceFiles" ]]; then sourceFiles="$appAssetsPath/vhost/wordpress.tar.gz" fi shift printRow local output error if ! run output error siteAdd "$domain" "$sourceFiles" "$@"; then printDanger "$error" printRow return 1 fi printSuccess "$output" cmdOpenlitespeedRestart if ! run output error wordpressConfigRebuild "$domain"; then printDanger "$error" printRow fi } # Rebuilds OLS vhost/config, MariaDB, Redis, Postfix, and WordPress salt for a site. # $1 (domain): site domain name. function cmdSiteConfigRebuild() { local domain domain=$(domainPrepare "$1") domainCheck "$domain" || return 1 printRow if ! runError error openlitespeedVhostRebuild "$domain"; then printDot 60 "OLS vhost" "$labelFail" printDanger "$error" else printDot 60 "OLS vhost" "$labelDone" fi if ! runError error openlitespeedConfigRebuild "$domain"; then printDot 60 "OLS config" "$labelFail" printDanger "$error" else printDot 60 "OLS config" "$labelDone" fi if ! runError error mariadbConfigRebuild "$domain"; then printDot 60 "MariaDB" "$labelFail" printDanger "$error" else printDot 60 "MariaDB" "$labelDone" fi if ! runError error redisConfigRebuild "$domain"; then printDot 60 "Redis" "$labelFail" printDanger "$error" else printDot 60 "Redis" "$labelDone" fi if ! runError error postfixConfigRebuild "$domain"; then printDot 60 "Postfix" "$labelFail" printDanger "$error" else printDot 60 "Postfix" "$labelDone" fi if ! runError error wordpressExec "$domain" config shuffle-salts; then printDot 60 "Wordpress salt" "$labelFail" printDanger "$error" else printDot 60 "Wordpress salt" "$labelDone" fi printRow } # Rebuilds the WordPress wp-config.php for a site. # $1 (domain): site domain name. function cmdSiteWordpressRebuild() { local error printRow if ! runError error wordpressConfigRebuild "$@"; then printDot 60 "Wordpress config rebuild" "$labelFail" printDanger "$error" else printDot 60 "Wordpress config rebuild" "$labelDone" fi printRow } # Resets databasePass/redisPass/postfixPass and rebuilds configs for one site or all sites. # Skips sites without wp-config.php in "all" mode. # $1 (target): site domain name or "all". function cmdSitePasswordReset() { local error printRow if ! runError error sitePasswordReset "$@"; then printDot 60 "Password reset" "$labelFail" printDanger "$error" else printDot 60 "Password reset" "$labelDone" fi printRow } # Resets all service credentials (passwords + usernames) and rebuilds configs for one site or all sites. # Skips sites without wp-config.php in "all" mode. # $1 (target): site domain name or "all". function cmdSiteAuthReset() { local error printRow if ! runError error siteAuthReset "$@"; then printDot 60 "Password reset" "$labelFail" printDanger "$error" else printDot 60 "Password reset" "$labelDone" fi printRow } # Exports a site's database to a file. # $1 (domain): site domain name. # [$2] (file): target dump file (auto-generated if omitted). function cmdSiteDatabaseDump() { local domain error domain=$(domainPrepare "$1") if ! runError error domainCheck "$domain"; then printDanger "$siteLabel $error" return 1 fi local file="$2" if [[ -z "$file" ]]; then file="$appDataPath/mariadb/${appDate}_${appTime}_$domain.sql.tar.gz" fi local databaseName databaseUser databasePass databaseName=$(siteConfigGet "$domain" "databaseName") databaseUser=$(siteConfigGet "$domain" "databaseUser") databasePass=$(siteConfigGet "$domain" "databasePass") printRow printDot 60 "file" "$file" printDot 60 "base" "$databaseName" printDot 60 "user" "$databaseUser" if ! runError error mariadbMasterExport "$databaseUser" "$databasePass" "$databaseName" "$file"; then printDot 60 "status" "$labelFailed" printDanger "$error" else printDot 60 "status" "$labelDone" fi printRow } # Prints system, config, and OLS details for a site. # $1 (domain): site domain name. function cmdSiteInfo() { printRow local domain error domain=$(domainPrepare "$1") if ! runError error domainCheck "$domain"; then printDanger "$error" printRow return 1 fi printSection "System" local ug userId groupId ug=$(domainToUser "$domain") printDot 60 "user" "$ug" printDot 60 "group" "$ug" if ! run userId error id -u "$ug"; then printDot 60 "userID" "$labelUnknown" else printDot 60 "userID" "$fontGreen$userId$fontReset" fi if ! run groupId error id -g "$ug"; then printDot 60 "groupID" "$labelUnknown" else printDot 60 "groupID" "$fontGreen$groupId$fontReset" fi local ip ip=$(systemHostGet "$domain") if [[ -z "$ip" ]]; then printDot 60 "/etc/hosts" "${fontGray}null$fontReset" elif [[ "$ip" == '127.0.0.1' ]]; then printDot 60 "/etc/hosts" "$fontGreen$ip$fontReset" else printDot 60 "/etc/hosts" "$fontRed$ip$fontReset" fi local limits blockLimit inodeLimit if ! run limits error openlitespeedVhostQuota "$ug"; then printDot 60 "quota block limit" "$labelUnknown" printDot 60 "quota inode limit" "$labelUnknown" else read -r blockLimit inodeLimit <<< "$limits" blockLimit=$(numFormat "$blockLimit"000) inodeLimit=$(numFormat "$inodeLimit") printDot 60 "quota block limit" "$blockLimit" printDot 60 "quota inode limit" "$inodeLimit" fi if groups "$ug" | grep -qw "$sftpAccessGroup"; then printDot 60 "SFTP access" "$labelOn" else printDot 60 "SFTP access" "$labelOff" fi printSection "Config" # printDot 60 "file$fontReset" "$appDataPath/config/$domain.config" if [[ ! -f "$appDataPath/config/$domain.config" ]]; then printDot 60 "file" "$fontRed$appDataPath/config/$domain.config$fontReset" printDot 60 "file" "${fontRed}not found$fontReset" else printDot 60 "file" "$fontGreen$appDataPath/config/$domain.config$fontReset" local -a params local param value params=(alias databaseName databaseUser databasePass redisUser redisPass postfixUser postfixPass postfixForwardTo sftpPass quotaBlockLimit quotaInodeLimit) for param in "${params[@]}"; do value=$(siteConfigGet "$domain" "$param") printDot 60 "$param" "${value:-$labelNull}" done fi printSection "OpenLiteSpeed" if [[ ! -f "$openlitespeedVhostsPath/$domain.conf" ]]; then printDot 60 "file$fontReset" "$fontRed$openlitespeedVhostsPath/$domain.conf$fontReset" printDot 60 "file$fontReset" "${fontRed}not found$fontReset" else printDot 60 "file$fontReset" "$fontGreen$openlitespeedVhostsPath/$domain.conf$fontReset" fi if [[ ! -d "$vhostsPath/$domain" ]]; then printDot 60 "path$fontReset" "$fontRed$vhostsPath/$domain$fontReset" printDot 60 "path$fontReset" "${fontRed}not found$fontReset" else printDot 60 "path$fontReset" "$fontGreen$vhostsPath/$domain$fontReset" fi if [[ ! -d "$openlitespeedVhostDataPath/$domain" ]]; then printDot 60 "data$fontReset" "$fontRed$openlitespeedVhostDataPath/$domain$fontReset" printDot 60 "data$fontReset" "${fontRed}not found$fontReset" else printDot 60 "data$fontReset" "$fontGreen$openlitespeedVhostDataPath/$domain$fontReset" fi printRow } # Checks site resources (config, system, dirs, OLS, MariaDB, Redis, Postfix, HTTP). # $1 (domain): site domain name. # [$@] (opts): full|short (mode). function cmdSiteStatus() { local domain opt error section label note domain=$(domainPrepare "$1") if ! runError error domainCheck "$domain"; then printDanger "$siteLabel $error" return 1 fi mode="${2:-full}" printSection "Config" if [[ -f "$appDataPath/config/$domain.config" ]]; then printDot 60 "file" "$fontGreen$appDataPath/config/$domain.config$fontReset" local -a params local param value params=(databaseName databaseUser databasePass redisUser redisPass postfixUser postfixPass quotaBlockLimit quotaInodeLimit) for param in "${params[@]}"; do value=$(siteConfigGet "$domain" "$param") if [[ -n "$value" ]]; then printDot 60 "$param" "$labelPass" else printDot 60 "$param" "$labelFail" fi done else printDot 60 "file" "$fontRed$appDataPath/config/$domain.config$fontReset" fi printSection "System" local userId groupId ug ug=$(domainToUser "$domain") note="$fontGray$ug$fontReset" if ! run userId error id -u "$ug"; then printDot 60 "user" "$note $labelFail" else printDot 60 "user" "$note $labelPass" fi if ! run groupId error id -g "$ug"; then printDot 60 "group" "$note $labelFail" else printDot 60 "group" "$note $labelPass" fi local ip ip=$(systemHostGet "$domain") note="$fontGray$ip$fontReset" if [[ "$ip" != '127.0.0.1' ]]; then printDot 60 "/etc/hosts" "$note $labelFail" else printDot 60 "/etc/hosts" "$note $labelPass" fi local limits blockLimit inodeLimit if ! run limits error openlitespeedVhostQuota "$ug"; then printDot 60 "quota block limit" "$labelFail" printDot 60 "quota inode limit" "$labelFail" else read -r blockLimit inodeLimit <<< "$limits" blockLimit=$(numFormat "$blockLimit"000) inodeLimit=$(numFormat "$inodeLimit") printDot 60 "quota block limit" "$blockLimit $labelPass" printDot 60 "quota inode limit" "$inodeLimit $labelPass" fi local sftpConfig if ! sftpConfig=$(sshd -T -C user="$ug",host="$hostName",addr=127.0.0.1); then printDot 60 "SFTP config" "$labelFail" else label="$fontBlue SFTP ForceCommand$fontReset" if ! grep -Fxq "forcecommand internal-sftp -d /www -u 027" <<< "$sftpConfig"; then printDot 60 "SFTP ForceCommand" "$labelFail" else printDot 60 "SFTP ForceCommand" "$labelPass" fi if ! grep -Fxq "chrootdirectory %h" <<< "$sftpConfig"; then printDot 60 "SFTP ChrootDirectory" "$labelFail" else printDot 60 "SFTP ChrootDirectory" "$labelPass" fi fi printSection "Path | existence, owner, permissions, ACL:nobody" local path path="$vhostsPath/$domain" label="vhost $fontBlue/$fontReset" note="${fontGray}root:root 755$fontReset" if [[ ! -d "$path" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%U:%G' "$path") != "root:root" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%a' "$path") != "755" ]]; then printDot 60 "$label" "$note $labelFail" else printDot 60 "$label" "$note $labelPass" fi local -a dirs local dir dirs=(session tmp) for dir in "${dirs[@]}"; do path="$vhostsPath/$domain/$dir" label="vhost $fontBlue/$dir$fontReset" note="${fontGray}ug:ug 770 acl:rwx$fontReset" if [[ ! -d "$path" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%U:%G' "$path") != "$ug:$ug" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%a' "$path") != "770" ]]; then printDot 60 "$label" "$note $labelFail" elif ! getfacl -cp "$path" | grep -Eq '^user:nobody:rwx($|[[:space:]])'; then printDot 60 "$label" "$note $labelFail" else printDot 60 "$label" "$note $labelPass" fi done path="$vhostsPath/$domain/www" label="vhost $fontBlue/www$fontReset" note="${fontGray}ug:ug 2750 acl:r-x$fontReset" if [[ ! -d "$path" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%U:%G' "$path") != "$ug:$ug" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%a' "$path") != "2750" ]]; then printDot 60 "$label" "$note $labelFail" elif ! getfacl -cp "$path" | grep -Eq '^user:nobody:r-x($|[[:space:]])'; then printDot 60 "$label" "$note $labelFail" else printDot 60 "$label" "$note $labelPass" fi path="$openlitespeedVhostDataPath/$domain" label="vhost-data $fontBlue/$fontReset" note="${fontGray}ug:ug 750 acl:r-x$fontReset" if [[ ! -d "$path" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%U:%G' "$path") != "$ug:$ug" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%a' "$path") != "750" ]]; then printDot 60 "$label" "$note $labelFail" elif ! getfacl -cp "$path" | grep -Eq '^user:nobody:r-x($|[[:space:]])'; then printDot 60 "$label" "$note $labelFail" else printDot 60 "$label" "$note $labelPass" fi path="$openlitespeedVhostDataPath/$domain/bootstrap.php" label="vhost-data $fontBlue/bootstrap.php$fontReset" note="${fontGray}ug:ug 640 acl:r--$fontReset" if [[ ! -f "$path" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%U:%G' "$path") != "$ug:$ug" ]]; then printDot 60 "$label" "$note $labelFail" elif [[ $(stat -c '%a' "$path") != "640" ]]; then printDot 60 "$label" "$note $labelFail" elif ! getfacl -cp "$path" | grep -Eq '^user:nobody:r--($|[[:space:]])'; then printDot 60 "$label" "$note $labelFail" else printDot 60 "$label" "$note $labelPass" fi printSection "OpenLiteSpeed" if ! run vhostList error openlitespeedVhostList; then printDot 60 "get vhost list" "$labelFail" else note="$fontGray$domain$fontReset" if listContains "$domain" "$vhostList"; then printDot 60 "vhost" "$note $labelPass" else printDot 60 "vhost" "$note $labelFail" fi fi note="$fontGray$domain.conf$fontReset" if [[ ! -f "$openlitespeedVhostsPath/$domain.conf" ]]; then printDot 60 "config" "$note $labelFail" else printDot 60 "config" "$note $labelPass" fi printSection "MariaDB" local mariadbDatabaseList mariadbUserList if ! run mariadbDatabaseList error mariadbDatabaseListGet; then printDot 60 "get database list" "$labelFail" elif ! run mariadbUserList error mariadbUserListGet; then printDot 60 "get user list" "$labelFail" else mariadbDatabase=$(siteConfigGet "$domain" "databaseName") note="$fontGray$mariadbDatabase$fontReset" if ! listContains "$mariadbDatabase" "$mariadbDatabaseList"; then printDot 60 "base" "$note $labelFail" else printDot 60 "base" "$note $labelPass" fi mariadbUser=$(siteConfigGet "$domain" "databaseUser") note="$fontGray$mariadbUser$fontReset" if ! listContains "$mariadbUser" "$mariadbUserList"; then printDot 60 "user" "$note $labelFail" else printDot 60 "user" "$note $labelPass" fi if [[ "$mode" == "full" ]]; then mariadbPass=$(siteConfigGet "$domain" "databasePass") if ! run output error mariadbMasterExec mariadb -u"$mariadbUser" -p"$mariadbPass" -N -e "SELECT 1;"; then printDot 60 "access" "$labelFail" elif [[ "$output" != "1" ]]; then printDot 60 "access" "$labelFail" else printDot 60 "access" "$labelPass" fi fi fi printSection "Redis" local redisUserList if ! run redisUserList error redisUserListGet; then printDot 60 "$fontBlue get user list$fontReset" "$labelFail" else redisUser=$(siteConfigGet "$domain" "redisUser") note="$fontGray$redisUser$fontReset" if ! listContains "$redisUser" "$redisUserList"; then printDot 60 "user" "$note $labelFail" else printDot 60 "user" "$note $labelPass" fi if [[ "$mode" == "full" ]]; then redisPass=$(siteConfigGet "$domain" "redisPass") if ! run output error redisExec redis-cli --no-auth-warning --user "$redisUser" --pass "$redisPass" PING; then printDot 60 "access" "$labelFail" elif [[ "$output" != "PONG" ]]; then printDot 60 "access" "$labelFail" else printDot 60 "access" "$labelPass" fi fi fi printSection "Postfix" local postfixSaslUserList if ! run postfixSaslUserList error postfixSaslUserList; then printDot 60 "get SASL list" "$labelFail" else postfixUser=$(siteConfigGet "$domain" "postfixUser") note="$fontGray$postfixUser$fontReset" if ! listContains "$postfixUser@$postfixDefaultRealm" "$postfixSaslUserList"; then printDot 60 "SASL user" "$note $labelFail" else printDot 60 "SASL user" "$note $labelPass" fi postfixPass=$(siteConfigGet "$domain" "postfixPass") printDot 60 "SASL access" "${fontGray}in progress$fontReset" fi if [[ "$mode" == "full" ]]; then printSection "HTTP" local httpCode urlEffective if ! run httpCode error urlCode "http://$domain"; then printDot 60 "HTTP code" "${fontGray}unknown$fontReset" elif [[ "$httpCode" == 200 ]]; then printDot 60 "HTTP code" "$fontGreen$httpCode$fontReset" elif [[ "$httpCode" =~ ^[23][0-9]{2}$ ]]; then printDot 60 "HTTP code" "$fontYellow$httpCode$fontReset" else printDot 60 "HTTP code" "$fontRed$httpCode$fontReset" fi if ! run urlEffective error urlAccessible "$domain"; then printDot 60 "URL effective" "${fontGray}unknown$fontReset" else printDot 60 "URL effective" "$fontGreen$urlEffective$fontReset" fi fi printRow } function siteFilesCheck() { local domain error ug dots domain=$(domainPrepare "$1") if ! runError error domainCheck "$domain"; then printDanger "$error" return 1 fi ug=$(domainToUser "$domain") dots=30 # fileSignatureDiff "$vhostsPath/$domain" "755:root:root" if ! run output error fileSignatureDiff "$vhostsPath/$domain" "755:root:root"; then printDanger "$error" elif [[ -n "$output" ]]; then local prefix=":$vhostsPath/$domain" printDot "$dots" "${fontCyan}vhost d 755:root:root$fontReset" "" "${output/$prefix/ /}" fi # fileSignatureDiffList "$vhostsPath/$domain/www" "d" "2750|$ug:$ug" if ! run output error fileSignatureDiffList "$vhostsPath/$domain/www" "d" "2750|$ug:$ug"; then printDanger "$error" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}www d 2750:u:g$fontReset" local prefix=":$vhostsPath/$domain/www/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # 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" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}www f (600|640):u:g$fontReset" local prefix=":$vhostsPath/$domain/www/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # fileSignatureDiffList "$vhostsPath/$domain/tmp" "d" "770:$ug:$ug" if ! run output error fileSignatureDiffList "$vhostsPath/$domain/tmp" "d" "770:$ug:$ug"; then printDanger "$error" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}tmp d 770:u:g$fontReset" local prefix=":$vhostsPath/$domain/tmp/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # fileSignatureDiffList "$vhostsPath/$domain/tmp" "f" "660:$ug:$ug" if ! run output error fileSignatureDiffList "$vhostsPath/$domain/tmp" "f" "660:$ug:$ug"; then printDanger "$error" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}tmp f 660:u:g$fontReset" local prefix=":$vhostsPath/$domain/tmp/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # fileSignatureDiffList "$vhostsPath/$domain/session" "d" "770:$ug:$ug" if ! run output error fileSignatureDiffList "$vhostsPath/$domain/session" "d" "770:$ug:$ug"; then printDanger "$error" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}session d 770:u:g$fontReset" local prefix=":$vhostsPath/$domain/session/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # 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" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}session f (660|600):u:g$fontReset" local prefix=":$vhostsPath/$domain/session/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "d" "750:$ug:$ug" if ! run output error fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "d" "750:$ug:$ug"; then printDanger "$error" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}data d 750:u:g$fontReset" local prefix=":$openlitespeedVhostDataPath/$domain/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi # fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "f" "600:$ug:$ug" if ! run output error fileSignatureDiffList "$openlitespeedVhostDataPath/$domain" "f" "600:$ug:$ug"; then printDanger "$error" else lineCount=$(grep -c . <<< "$output" || true) if [[ "$lineCount" -gt 0 ]]; then local label="${fontCyan}data f 600:u:g$fontReset" local prefix=":$openlitespeedVhostDataPath/$domain/" while read -r line; do printDot "$dots" "$label" "" "${line/$prefix/ /}" done < <(awk 'NF' <<< "$output") fi fi } function siteAllFilesCheck() { local vhostList error domain if ! run vhostList error openlitespeedVhostList; then printDanger "Cannot get vhost list: $error" return 1 fi for domain in $vhostList; do mapfile -t diffArray < <(siteFilesCheck "$domain") if [[ ${#diffArray[@]} -gt 0 ]]; then printSection "$domain" local line for line in "${diffArray[@]}"; do printText "$line" done fi done } function siteAllVhostRebuild() { local vhostList error domain if ! run vhostList error openlitespeedVhostList; then printDanger "Cannot get vhost list: $error" return 1 fi for domain in $vhostList; do printText "$domain" openlitespeedVhostRebuild "$domain" done }