# bin/bash # 要更新的外掛清單 # WPPLUGINS=("worker") read -p "請輸入要更新的外掛名稱:" WPPLUGINS # 要跳過的帳號清單 continue_user=("students-media" "students-orgtw" "webai-tw" "runcloud") # 跳過指定帳號 # 列出所有 /home 下的目錄 (System USER),x=System USER for x in $(ls -l /home/ | awk '/^d/ {print $NF}') do # 跳過指定帳號 for i in ${continue_user[@]} do # echo ${i} if [ ${x} == ${i} ]; then continue 2 fi done # echo ${x} # 查看 USER # 列出 USER 所有網站,y=site for y in $(ls -l /home/${x}/webapps/ | awk '/^d/ {print $NF}') do # echo ${y} # 查看 APP ID cd /home/${x}/webapps/${y}/ sudo -u ${x} wp plugin update ${WPPLUGINS} # sleep 1 # 停用並刪除外掛 # wp plugin uninstall wp-cli-login-server --deactivate --allow-root # 查看被執行的帳號 # echo ${x} >> /root/user.txt done done