Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkeen committed Jun 17, 2020
1 parent b2316ed commit 8827b81
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/_lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ lib::import() {
local MODULE="$1"

if ! declare -F "$MODULE::__imported__" &>/dev/null ; then
if declare -F "$MODULE::__module__" ; then
if declare -F "$MODULE::__module__" &>/dev/null; then
"$MODULE::__module__"
else
if [ -z "${MAGEOPS_BASH_LIB_DIR:-}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lib/mageops/bootstrap.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mageops::bootstrap::__module__()
mageops::bootstrap::__module__() {
lib::import ui
lib::import mageops::core
lib::import mageops::ansible
Expand Down
43 changes: 43 additions & 0 deletions lib/mageops/guest.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
mageops::guest::__module__() {
lib::import ui
lib::import mageops::core
lib::import mageops::ansible
lib::import mageops::bootstrap

mageops::guest::trim() {
ui::info "Initial root filesystem size: $(ui::em $(du -sh / 2>/dev/null | cut -d"$(printf '\t')" -f1))"

ui::step "Clean YUM cache" \
yum -y clean all '||' true

ui::step "Clean DNF cache" \
dnf -y clean all '||' true

ui::step "Stop services" \
'&&' systemctl stop php-fpm \
'&&' systemctl stop varnish \
'&&' systemctl stop elasticsearch \
'&&' systemctl stop nginx \
'&&' systemctl stop mysql \
'&&' systemctl stop redis \
'&&' systemctl stop redis-sessions \
'&&' systemctl stop elasticsearch

ui::step "Remove unneeded cache and service data files" \
rm -rvf \
/{root,home/magento}/{.cache/*,.opcache/*,.*history,.composer,.yarn/*,.npm/*} \
/var/lib/mysql/ib_logfile* \
/var/lib/mysql/ib_tmp* \
/var/lib/varnish/* \
/var/lib/redis/* \
/var/lib/redis-sessions/*

ui::step "Trim system logs" \
echo '|' find /var/log -type f -exec tee {} \;

ui::step "Trim Magento logs" \
echo '|' find /var/www/magento/ -mindepth 3 -type f -path '*/var/log/*' -exec tee {} \;

ui::info "Trimmed root filesystem size: $(ui::em $(du -sh / 2>/dev/null | cut -d"$(printf '\t')" -f1))"
}
}
25 changes: 0 additions & 25 deletions lib/mageops/mageops-trim
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,3 @@
set -e



yum -y clean all || true
dnf -y clean all || true

systemctl stop php-fpm
systemctl stop varnish
systemctl stop elasticsearch
systemctl stop nginx
systemctl stop mysql
systemctl stop redis
systemctl stop redis-sessions
systemctl stop elasticsearch

rm -rvf \
/{root,home/magento}/{.cache/*,.opcache/*,.*history,.composer,.yarn/*,.npm/*} \
/var/lib/mysql/ib_logfile* \
/var/lib/mysql/ib_tmp* \
/var/lib/varnish/* \
/var/lib/redis/* \
/var/lib/redis-sessions/*

echo '' | find /var/log -type f -exec tee {} \;
echo '' | find /var/www/magento/ -mindepth 3 -type f -path '*/var/log/*' -exec tee {} \;


0 comments on commit 8827b81

Please # to comment.