This repository was archived by the owner on Jul 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·78 lines (66 loc) · 1.91 KB
/
setup.sh
File metadata and controls
executable file
·78 lines (66 loc) · 1.91 KB
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
75
76
77
78
#!/bin/bash
# Host Optimization Setup Script
# This script prepares the host for manual Ansible playbook execution
set -e
# Configuration variables - modify these for your environment
PROJECT_NAME="${PROJECT_NAME:-Debian_KVM_Optimization}"
LOG_FILE="${LOG_FILE:-/var/log/${PROJECT_NAME}-setup.log}"
echo "=== ${PROJECT_NAME} Setup ===" | tee -a $LOG_FILE
echo "Started at: $(date)" | tee -a $LOG_FILE
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" | tee -a $LOG_FILE
exit 1
fi
# Update system
echo "Updating system packages..." | tee -a $LOG_FILE
apt-get update && apt-get upgrade -y >> $LOG_FILE 2>&1
# Install required packages
echo "Installing required packages..." | tee -a $LOG_FILE
apt-get install -y \
ansible \
git \
python3-pip \
python3-venv \
curl \
wget \
gnupg \
software-properties-common >> $LOG_FILE 2>&1
# Run optimization (manual execution only)
echo "Running KVM host optimization..." | tee -a $LOG_FILE
ansible-playbook -c local -i inventory/hosts.yml site.yml >> $LOG_FILE 2>&1
# Create log rotation for our logs
cat > /etc/logrotate.d/${PROJECT_NAME} << EOF
${LOG_FILE} {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 0644 root root
}
/var/log/${PROJECT_NAME}.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 0644 root root
}
EOF
# Display completion status
echo "=== Setup Complete ===" | tee -a $LOG_FILE
echo "Setup completed at: $(date)" | tee -a $LOG_FILE
echo ""
echo "=== Manual Execution Instructions ==="
echo ""
echo "To run optimization manually:"
echo " ansible-playbook -c local -i inventory/hosts.yml site.yml"
echo ""
echo "To check logs:"
echo " tail -f $LOG_FILE"
echo ""
echo "Note: This playbook should only be run manually to avoid system instability."
echo "Automatic execution via systemd/cron is not recommended."