forked from k-mktr/fedora-things-to-do
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.sh
104 lines (89 loc) · 5.17 KB
/
template.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# "Things To Do!" script for a fresh Fedora Workstation installation
# Check if the script is run with sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run this script with sudo"
exit 1
fi
# Set variables
ACTUAL_USER=$SUDO_USER
ACTUAL_HOME=$(eval echo ~$SUDO_USER)
LOG_FILE="/var/log/fedora_things_to_do.log"
# Function to generate timestamps
get_timestamp() {
date +"%Y-%m-%d %H:%M:%S"
}
# Function to log messages
log_message() {
local message="$1"
echo "$(get_timestamp) - $message" | tee -a "$LOG_FILE"
}
# Function to handle errors
handle_error() {
local exit_code=$?
local message="$1"
if [ $exit_code -ne 0 ]; then
log_message "ERROR: $message"
exit $exit_code
fi
}
# Function to prompt for reboot
prompt_reboot() {
sudo -u $ACTUAL_USER bash -c 'read -p "It is time to reboot the machine. Would you like to do it now? (y/n): " choice; [[ $choice == [yY] ]]'
if [ $? -eq 0 ]; then
log_message "Rebooting..."
reboot
else
log_message "Reboot canceled."
fi
}
# Function to backup configuration files
backup_file() {
local file="$1"
if [ -f "$file" ]; then
cp "$file" "$file.bak"
handle_error "Failed to backup $file"
log_message "Backed up $file"
fi
}
echo "";
echo "╔═════════════════════════════════════════════════════════════════════════════╗";
echo "║ ║";
echo "║ ░█▀▀░█▀▀░█▀▄░█▀█░█▀▄░█▀█░░░█░█░█▀█░█▀▄░█░█░█▀▀░▀█▀░█▀█░▀█▀░▀█▀░█▀█░█▀█░ ║";
echo "║ ░█▀▀░█▀▀░█░█░█░█░█▀▄░█▀█░░░█▄█░█░█░█▀▄░█▀▄░▀▀█░░█░░█▀█░░█░░░█░░█░█░█░█░ ║";
echo "║ ░▀░░░▀▀▀░▀▀░░▀▀▀░▀░▀░▀░▀░░░▀░▀░▀▀▀░▀░▀░▀░▀░▀▀▀░░▀░░▀░▀░░▀░░▀▀▀░▀▀▀░▀░▀░ ║";
echo "║ ░░░░░░░░░░░░▀█▀░█░█░▀█▀░█▀█░█▀▀░█▀▀░░░▀█▀░█▀█░░░█▀▄░█▀█░█░░░░░░░░░░░░░░ ║";
echo "║ ░░░░░░░░░░░░░█░░█▀█░░█░░█░█░█░█░▀▀█░░░░█░░█░█░░░█░█░█░█░▀░░░░░░░░░░░░░░ ║";
echo "║ ░░░░░░░░░░░░░▀░░▀░▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░░░░▀░░▀▀▀░░░▀▀░░▀▀▀░▀░░░░░░░░░░░░░░ ║";
echo "║ ║";
echo "╚═════════════════════════════════════════════════════════════════════════════╝";
echo "";
echo "This script automates \"Things To Do!\" steps after a fresh Fedora Workstation installation"
echo "ver. 24.09"
echo ""
echo "Don't run this script if you didn't build it yourself or don't know what it does."
echo ""
read -p "Press Enter to continue or CTRL+C to cancel..."
# System Upgrade
{{system_upgrade}}
# System Configuration
{{system_config}}
# App Installation
{{app_install}}
# Customization
{{customization}}
# Custom user-defined commands
{{custom_script}}
# Finish
echo "";
echo "╔═════════════════════════════════════════════════════════════════════════╗";
echo "║ ║";
echo "║ ░█░█░█▀▀░█░░░█▀▀░█▀█░█▄█░█▀▀░░░▀█▀░█▀█░░░█▀▀░█▀▀░█▀▄░█▀█░█▀▄░█▀█░█░ ║";
echo "║ ░█▄█░█▀▀░█░░░█░░░█░█░█░█░█▀▀░░░░█░░█░█░░░█▀▀░█▀▀░█░█░█░█░█▀▄░█▀█░▀░ ║";
echo "║ ░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░░░░▀░░▀▀▀░░░▀░░░▀▀▀░▀▀░░▀▀▀░▀░▀░▀░▀░▀░ ║";
echo "║ ║";
echo "╚═════════════════════════════════════════════════════════════════════════╝";
echo "";
log_message "All steps completed. Enjoy!"
# Prompt for reboot
prompt_reboot