Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # PL:Skrypt kontrolujacy stan tmpfs
- # EN:Script for control tmpfs status
- # http://filipczyk.net/optymalizacja-prestashop-16-cache-przyspieszenie/
- # 2014 - Filipczyk.net
- # Configration:
- source_to_prestashop="/home/www/public_html"#Zmien ścieżkę do presty
- security_procentage=90
- check_cachefs="yes"
- check_smarty_compile="yes"
- check_smarty_cache="yes"
- check_pagespeed="yes"
- # Functions:
- # check
- function check {
- check_source $source_to_prestashop
- check_procentage $security_procentage
- check_check $check_cachefs
- check_check $check_smarty_compile
- check_check $check_smarty_cache
- check_check $check_pagespeed
- }
- function check_source {
- if [ ! -d "$1" ]; then
- echo "Error: $1 - Doesn't exists"
- exit
- fi
- }
- function check_procentage {
- check_max=100
- check_min=0
- if (("$1" > "$check_max")); then
- echo "Error: $1 - is wrong"
- exit
- fi
- if (("$1" < "$check_min")); then
- echo "Error: $1 - is wrong"
- exit
- fi
- }
- function check_check {
- if [[ "$1" != "yes" && "$1" != "no" ]]; then
- echo "Error: $1 - is wrong. Use yes or no"
- exit
- fi
- }
- # Controller
- function event_do {
- state="good"
- event="nothing to do"
- if (("$1" >= "$security_procentage")); then
- state="bad"
- event="CLEARED!"
- source_to_remove="$source_to_prestashop$2/*"
- rm -rf $source_to_remove
- fi
- echo "#$2 -> $1%/100% = $state, $event"
- }
- function controller {
- echo "tmpfs - Controler - $(date)"
- check
- if [ "$check_cachefs" = "yes" ]; then
- status=`df -h $source_to_prestashop/cache/cachefs/ | awk '{print $5}' | tail -1 | sed 's/[^0-9]*//g'`
- name="/cache/cachefs"
- event_do $status $name
- fi
- if [ "$check_smarty_compile" = "yes" ]; then
- status=`df -h $source_to_prestashop/cache/smarty/compile/ | awk '{print $5}' | tail -1 | sed 's/[^0-9]*//g'`
- name="/cache/smarty/compile"
- event_do $status $name
- fi
- if [ "$check_smarty_cache" = "yes" ]; then
- status=`df -h $source_to_prestashop/cache/smarty/cache/ | awk '{print $5}' | tail -1 | sed 's/[^0-9]*//g'`
- name="/cache/smarty/cache"
- event_do $status $name
- fi
- if [ "$check_pagespeed" = "yes" ]; then
- status=`df -h $source_to_prestashop/cache/pagespeed/ | awk '{print $5}' | tail -1 | sed 's/[^0-9]*//g'`
- name="/cache/pagespeed"
- event_do $status $name
- fi
- }
- # Execution code:
- controller
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement