-
Notifications
You must be signed in to change notification settings - Fork 0
/
after_pull-dev.sh
executable file
·74 lines (53 loc) · 1.89 KB
/
after_pull-dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Run on the server after pulling to clear Laravel cache.
# Give it executable permission with chmod +x and run with sudo ./after_pull.sh
# ANSI escape codes for text colors
YELLOW='\033[1;33m' # Yellow
RESET='\033[0m' # Reset to default
GREEN='\033[0;32m' # Green
RED='\033[0;31m' # Red
BLUE='\033[0;34m' # Blue
# Function to print messages with color
print_message() {
local color=$1
local message=$2
echo -e "${color}${message}${RESET}"
}
# Function to list files
list_files() {
find "$1" -type f
}
# Log start time
print_message "$GREEN" "Starting cache clearing process at $(date)"
# Log the status of each command and file operations
print_message "$YELLOW" "Running composer dump-autoload"
composer dump-autoload
print_message "$YELLOW" "Running php artisan clear-compiled..."
php artisan clear-compiled
print_message "$YELLOW" "Running php artisan config:cache..."
php artisan config:cache
print_message "$YELLOW" "Running php artisan route:cache..."
php artisan route:cache
print_message "$YELLOW" "Running php artisan cache:clear..."
php artisan cache:clear
print_message "$YELLOW" "Running php artisan view:clear..."
php artisan view:clear
print_message "$YELLOW" "Running php artisan config:clear..."
php artisan config:clear
php artisan optimize:clear
print_message "$YELLOW" "Listing files in bootstrap/cache before deletion..."
# List files before deletion
before_files=$(list_files bootstrap/cache)
echo "$before_files"
# Remove files
rm -f bootstrap/cache/*.php
# List files after deletion
after_files=$(list_files bootstrap/cache)
print_message "$YELLOW" "Files after deletion:"
echo "$after_files"
# Determine deleted files
deleted_files=$(comm -23 <(echo "$before_files" | sort) <(echo "$after_files" | sort))
print_message "$BLUE" "Deleted files:"
echo "$deleted_files"
# Log end time
print_message "$GREEN" "Cache clearing process completed at $(date)"