Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
460 changes: 230 additions & 230 deletions README.md

Large diffs are not rendered by default.

Binary file added backups/backup_scripts_2026-05-06_09-49-12.tar.gz
Binary file not shown.
Binary file added backups/backup_scripts_2026-05-06_09-59-44.tar.gz
Binary file not shown.
Binary file added backups/backup_scripts_2026-05-06_10-03-22.tar.gz
Binary file not shown.
23 changes: 23 additions & 0 deletions logs/app.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
2026-05-06 09:59:15 - Running ALL scripts
2026-05-06 09:59:15 - START: User Info
2026-05-06 09:59:43 - SUCCESS: User Info
2026-05-06 09:59:43 - START: System Check
2026-05-06 09:59:44 - SUCCESS: System Check
2026-05-06 09:59:44 - START: Backup
2026-05-06 09:59:44 - SUCCESS: Backup
2026-05-06 09:59:44 - START: Process Monitor
2026-05-06 09:59:45 - SUCCESS: Process Monitor
2026-05-06 09:59:45 - START: File Manager (list)
2026-05-06 09:59:46 - SUCCESS: File Manager (list)
2026-05-06 10:00:55 - Running ALL scripts
2026-05-06 10:00:55 - START: User Info
2026-05-06 10:03:21 - SUCCESS: User Info
2026-05-06 10:03:21 - START: System Check
2026-05-06 10:03:21 - SUCCESS: System Check
2026-05-06 10:03:21 - START: Backup
2026-05-06 10:03:22 - SUCCESS: Backup
2026-05-06 10:03:22 - START: Process Monitor
2026-05-06 10:03:23 - SUCCESS: Process Monitor
2026-05-06 10:03:23 - START: File Manager (list)
2026-05-06 10:03:23 - SUCCESS: File Manager (list)
2026-05-06 10:03:29 - Exiting application
12 changes: 12 additions & 0 deletions logs/backup.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
===== BACKUP STARTED =====
Backup created: backups/backup_scripts_2026-05-06_09-49-12.tar.gz
Cleaning old backups (keeping last 5)...
===== BACKUP COMPLETED =====
===== BACKUP STARTED =====
Backup created: backups/backup_scripts_2026-05-06_09-59-44.tar.gz
Cleaning old backups (keeping last 5)...
===== BACKUP COMPLETED =====
===== BACKUP STARTED =====
Backup created: backups/backup_scripts_2026-05-06_10-03-22.tar.gz
Cleaning old backups (keeping last 5)...
===== BACKUP COMPLETED =====
30 changes: 30 additions & 0 deletions logs/file_manager.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
===== FILE MANAGER ACTION: create =====
File 'file.txt' created.
===== FILE MANAGER ACTION: list =====
Listing files:
total 4.0K
-rwxrwxrwx 1 root root 3.9K May 6 04:59 README.md
-rwxrwxrwx 1 root root 0 May 6 09:44 file.txt
drwxrwxrwx 1 root root 4.0K May 6 09:44 logs
-rwxrwxrwx 1 root root 0 May 6 07:39 run_all.sh
drwxrwxrwx 1 root root 4.0K May 6 09:44 scripts
===== FILE MANAGER ACTION: rename =====
Renamed 'file.txt' to 'newfile.txt'.
===== FILE MANAGER ACTION: delete =====
File 'newfile.txt' deleted.
===== FILE MANAGER ACTION: list =====
Listing files:
total 8.0K
-rwxrwxrwx 1 root root 3.9K May 6 04:59 README.md
drwxrwxrwx 1 root root 4.0K May 6 09:59 backups
drwxrwxrwx 1 root root 4.0K May 6 09:59 logs
-rwxrwxrwx 1 root root 1.7K May 6 09:57 run_all.sh
drwxrwxrwx 1 root root 4.0K May 6 09:54 scripts
===== FILE MANAGER ACTION: list =====
Listing files:
total 8.0K
-rwxrwxrwx 1 root root 3.9K May 6 04:59 README.md
drwxrwxrwx 1 root root 4.0K May 6 10:03 backups
drwxrwxrwx 1 root root 4.0K May 6 10:03 logs
-rwxrwxrwx 1 root root 1.7K May 6 09:57 run_all.sh
drwxrwxrwx 1 root root 4.0K May 6 09:54 scripts
21 changes: 21 additions & 0 deletions logs/process_monitor.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
===== PROCESS MONITOR =====
Date: Wed May 6 09:55:13 WAT 2026

Status: Stopped
Attempting to restart nginx...
Status: Restarted
===== CHECK COMPLETED =====
===== PROCESS MONITOR =====
Date: Wed May 6 09:59:44 WAT 2026

Status: Stopped
Attempting to restart nginx...
Status: Restarted
===== CHECK COMPLETED =====
===== PROCESS MONITOR =====
Date: Wed May 6 10:03:22 WAT 2026

Status: Stopped
Attempting to restart nginx...
Status: Restarted
===== CHECK COMPLETED =====
34 changes: 34 additions & 0 deletions logs/system_report_2026-05-06_09-34-45.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
===== SYSTEM REPORT =====
Date: Wed May 6 09:34:45 WAT 2026

===== DISK USAGE =====
Filesystem Size Used Avail Use% Mounted on
rootfs 931G 76G 856G 9% /
none 931G 76G 856G 9% /dev
none 931G 76G 856G 9% /run
none 931G 76G 856G 9% /run/lock
none 931G 76G 856G 9% /run/shm
none 931G 76G 856G 9% /run/user
tmpfs 931G 76G 856G 9% /sys/fs/cgroup
C:\ 931G 76G 856G 9% /mnt/c


===== MEMORY USAGE =====
total used free shared buff/cache available
Mem: 16303 5387 10692 17 223 10785
Swap: 49152 0 49152

===== CPU LOAD =====
09:34:45 up 1:22, 0 users, load average: 0.52, 0.58, 0.59

===== TOTAL RUNNING PROCESSES =====
8

===== TOP 5 MEMORY-CONSUMING PROCESSES =====
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 7 0.0 0.0 18084 3608 tty1 S 08:12 0:00 -bash
root 136 4.0 0.0 16796 1968 tty1 S 09:34 0:00 bash scripts/system_check.sh
root 179 0.0 0.0 18660 1876 tty1 R 09:34 0:00 ps aux --sort=-%mem
root 180 0.0 0.0 15288 840 tty1 S 09:34 0:00 head -6
root 181 0.0 0.0 15284 840 tty1 S 09:34 0:00 tee -a logs/system_report_2026-05-06_09-34-45.log

34 changes: 34 additions & 0 deletions logs/system_report_2026-05-06_09-42-10.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
===== SYSTEM REPORT =====
Date: Wed May 6 09:42:10 WAT 2026

===== DISK USAGE =====
Filesystem Size Used Avail Use% Mounted on
rootfs 931G 76G 856G 9% /
none 931G 76G 856G 9% /dev
none 931G 76G 856G 9% /run
none 931G 76G 856G 9% /run/lock
none 931G 76G 856G 9% /run/shm
none 931G 76G 856G 9% /run/user
tmpfs 931G 76G 856G 9% /sys/fs/cgroup
C:\ 931G 76G 856G 9% /mnt/c


===== MEMORY USAGE =====
total used free shared buff/cache available
Mem: 16303 5375 10704 17 223 10797
Swap: 49152 0 49152

===== CPU LOAD =====
09:42:10 up 1:30, 0 users, load average: 0.52, 0.58, 0.59

===== TOTAL RUNNING PROCESSES =====
8

===== TOP 5 MEMORY-CONSUMING PROCESSES =====
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 7 0.0 0.0 18084 3612 tty1 S 08:12 0:00 -bash
root 187 8.0 0.0 16796 1968 tty1 S 09:42 0:00 bash scripts/system_check.sh
root 230 0.0 0.0 18660 1876 tty1 R 09:42 0:00 ps aux --sort=-%mem
root 231 0.0 0.0 15288 844 tty1 S 09:42 0:00 head -6
root 232 0.0 0.0 15284 836 tty1 S 09:42 0:00 tee -a logs/system_report_2026-05-06_09-42-10.log

34 changes: 34 additions & 0 deletions logs/system_report_2026-05-06_09-59-43.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
===== SYSTEM REPORT =====
Date: Wed May 6 09:59:43 WAT 2026

===== DISK USAGE =====
Filesystem Size Used Avail Use% Mounted on
rootfs 931G 76G 856G 9% /
none 931G 76G 856G 9% /dev
none 931G 76G 856G 9% /run
none 931G 76G 856G 9% /run/lock
none 931G 76G 856G 9% /run/shm
none 931G 76G 856G 9% /run/user
tmpfs 931G 76G 856G 9% /sys/fs/cgroup
C:\ 931G 76G 856G 9% /mnt/c


===== MEMORY USAGE =====
total used free shared buff/cache available
Mem: 16303 5489 10589 17 223 10682
Swap: 49152 0 49152

===== CPU LOAD =====
09:59:43 up 1:47, 0 users, load average: 0.52, 0.58, 0.59

===== TOTAL RUNNING PROCESSES =====
9

===== TOP 5 MEMORY-CONSUMING PROCESSES =====
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 7 0.0 0.0 18084 3612 tty1 S 08:12 0:00 -bash
root 315 0.0 0.0 16796 2056 tty1 S 09:58 0:00 bash run_all.sh
root 338 0.0 0.0 16796 1968 tty1 S 09:59 0:00 bash scripts/system_check.sh
root 381 0.0 0.0 18660 1876 tty1 R 09:59 0:00 ps aux --sort=-%mem
root 382 0.0 0.0 15288 844 tty1 S 09:59 0:00 head -6

34 changes: 34 additions & 0 deletions logs/system_report_2026-05-06_10-03-21.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
===== SYSTEM REPORT =====
Date: Wed May 6 10:03:21 WAT 2026

===== DISK USAGE =====
Filesystem Size Used Avail Use% Mounted on
rootfs 931G 76G 856G 9% /
none 931G 76G 856G 9% /dev
none 931G 76G 856G 9% /run
none 931G 76G 856G 9% /run/lock
none 931G 76G 856G 9% /run/shm
none 931G 76G 856G 9% /run/user
tmpfs 931G 76G 856G 9% /sys/fs/cgroup
C:\ 931G 76G 856G 9% /mnt/c


===== MEMORY USAGE =====
total used free shared buff/cache available
Mem: 16303 5495 10583 17 223 10676
Swap: 49152 0 49152

===== CPU LOAD =====
10:03:21 up 1:51, 0 users, load average: 0.52, 0.58, 0.59

===== TOTAL RUNNING PROCESSES =====
9

===== TOP 5 MEMORY-CONSUMING PROCESSES =====
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 7 0.0 0.0 18084 3612 tty1 S 08:12 0:00 -bash
root 315 0.0 0.0 16796 2060 tty1 S 09:58 0:00 bash run_all.sh
root 474 10.0 0.0 16796 1972 tty1 S 10:03 0:00 bash scripts/system_check.sh
root 517 0.0 0.0 18660 1876 tty1 R 10:03 0:00 ps aux --sort=-%mem
root 518 0.0 0.0 15288 844 tty1 S 10:03 0:00 head -6

12 changes: 12 additions & 0 deletions logs/user_info.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--------------------------------
Hello Tariq Olugbode from NIGERIA!
You are classified as: Adult
--------------------------------
--------------------------------
Hello Tariq Olugbode from NIGERIA!
You are classified as: Adult
--------------------------------
--------------------------------
Hello Tariq Olugbode from NIGERIA!
You are classified as: Adult
--------------------------------
85 changes: 85 additions & 0 deletions run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

set -euo pipefail

mkdir -p logs
LOG_FILE="logs/app.log"

log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
}

# -------------------------
# FUNCTIONS
# -------------------------

run_all() {
log "Running ALL scripts"

run_script "User Info" "bash scripts/user_info.sh"
run_script "System Check" "bash scripts/system_check.sh"
run_script "Backup" "bash scripts/backup.sh scripts"
run_script "Process Monitor" "bash scripts/process_monitor.sh nginx"
run_script "File Manager (list)" "bash scripts/file_manager.sh list"
}

run_system_check() {
log "Running System Check"
run_script "System Check" "bash scripts/system_check.sh"
}

run_backup() {
read -p "Enter directory to back up: " DIR
log "Running Backup on $DIR"
run_script "Backup" "bash scripts/backup.sh $DIR"
}

# -------------------------
# SAFE EXECUTION HANDLER
# -------------------------
run_script() {
NAME=$1
CMD=$2

echo ""
echo ">>> $NAME"
log "START: $NAME"

if eval "$CMD"; then
log "SUCCESS: $NAME"
else
log "FAILED: $NAME"
echo "Error occurred in $NAME (continuing...)"
fi
}

# -------------------------
# MENU
# -------------------------
while true; do
echo ""
echo "=============================="
echo " DEVOPS TOOLKIT MENU"
echo "=============================="
echo "1. Run All"
echo "2. System Check"
echo "3. Backup"
echo "4. Exit"
echo "=============================="

read -p "Choose an option: " CHOICE

case $CHOICE in
1) run_all ;;
2) run_system_check ;;
3) run_backup ;;
4)
log "Exiting application"
echo "Goodbye!"
exit 0
;;
*)
echo "Invalid option. Try again."
;;
esac
done
49 changes: 49 additions & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

mkdir -p backups
mkdir -p logs

LOG_FILE="logs/backup.log"

SOURCE=$1
DATE=$(date +"%Y-%m-%d_%H-%M-%S")

echo "===== BACKUP STARTED =====" | tee -a "$LOG_FILE"

# -------------------------
# Validate input
# -------------------------
if [ -z "$SOURCE" ]; then
echo "Error: No directory provided." | tee -a "$LOG_FILE"
echo "Usage: $0 <directory>" | tee -a "$LOG_FILE"
exit 1
fi

# -------------------------
# Check directory exists
# -------------------------
if [ ! -d "$SOURCE" ]; then
echo "Error: Directory '$SOURCE' does not exist." | tee -a "$LOG_FILE"
exit 1
fi

# -------------------------
# Create backup
# -------------------------
BACKUP_NAME="backups/backup_$(basename "$SOURCE")_$DATE.tar.gz"

tar -czf "$BACKUP_NAME" "$SOURCE"

echo "Backup created: $BACKUP_NAME" | tee -a "$LOG_FILE"

# -------------------------
# Keep only last 5 backups
# -------------------------
echo "Cleaning old backups (keeping last 5)..." | tee -a "$LOG_FILE"

ls -t backups/*.tar.gz 2>/dev/null | tail -n +6 | while read OLD; do
rm -f "$OLD"
echo "Deleted old backup: $OLD" | tee -a "$LOG_FILE"
done

echo "===== BACKUP COMPLETED =====" | tee -a "$LOG_FILE"
Loading