-
Notifications
You must be signed in to change notification settings - Fork 3
/
tuned
executable file
·178 lines (163 loc) · 5.62 KB
/
tuned
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env bash
# Define some color variables
BABY_PINK='\033[1m\033[38;2;255;182;193m'
PEACH='\e[1;38;2;255;204;153m'
GREEN='\033[1m\033[38;2;0;255;0m'
RED='\033[1m\033[38;5;196m'
AQUA='\e[1;38;2;0;255;255m'
NC='\033[0m' # No Color
# Function to display a menu with options
display_menu() {
clear
echo ""
COLUMNS=$(tput cols)
t1="============================="
t2="Tuned Power Profile Manager"
printf "${BABY_PINK}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
printf "${BABY_PINK}%*s\n${NC}" $(((${#t2} + $COLUMNS) / 2)) "$t2"
printf "${BABY_PINK}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
echo ""
echo -e "${PEACH}Select Your Choice:${NC}"
echo " 1. Install Tuned"
echo " 2. Uninstall Tuned"
echo " 3. List Available Profiles"
echo " 4. Show Active Profile"
echo " 5. Set Active Profile"
echo " 6. Enable Tuned Service"
echo " 7. Disable Tuned Service"
echo " 8. Check Tuned Service Status"
echo " 9. Go Back To Main Menu"
echo ""
echo -n "Enter your choice: "
}
# Function to install Tuned and Tuned PPD
install_tuned() {
echo ""
echo -e "${GREEN}Installing Tuned and Tuned PPD...${NC}"
sleep 1
# Check for package manager and install Tuned and Tuned PPD accordingly
if command -v apt >/dev/null; then
sudo apt update && sudo apt install tuned -y
sudo systemctl enable tuned
sudo systemctl start tuned
elif command -v dnf >/dev/null; then
sudo dnf install tuned tuned-ppd -y
sudo systemctl enable tuned
sudo systemctl start tuned
elif command -v yum >/dev/null; then
sudo yum install tuned tuned-ppd -y
sudo systemctl enable tuned
sudo systemctl start tuned
elif command -v zypper >/dev/null; then
sudo zypper install tuned tuned-ppd -y
sudo systemctl enable tuned
sudo systemctl start tuned
elif command -v pacman >/dev/null; then
sudo pacman -S tuned tuned-ppd --noconfirm
sudo systemctl enable tuned
sudo systemctl start tuned
else
echo -e "${AQUA}Sorry, I don't know how to install Tuned on your system.${NC}"
fi
sleep 1
read -rp "Press Enter to continue..."
}
# Function to uninstall Tuned
uninstall_tuned() {
echo ""
echo -e "${RED}Uninstalling Tuned...${NC}"
sleep 1
if command -v apt >/dev/null; then
sudo apt remove --purge tuned -y
elif command -v dnf >/dev/null; then
sudo dnf remove tuned -y
elif command -v yum >/dev/null; then
sudo yum remove tuned -y
elif command -v zypper >/dev/null; then
sudo zypper remove tuned
elif command -v pacman >/dev/null; then
sudo pacman -R tuned
else
echo -e "${AQUA}Sorry, I don't know how to uninstall Tuned on your system.${NC}"
fi
sleep 1
read -rp "Press Enter to continue..."
}
# Function to list available profiles
list_profiles() {
echo ""
echo -e "${GREEN}Checking Profiles...${NC}"
sleep 1
tuned-adm list
sleep 1
read -rp "Press Enter to continue..."
}
# Function to show active profile
show_active_profile() {
echo ""
echo -e "${GREEN}Checking Profiles...${NC}"
sleep 1
tuned-adm active
sleep 1
read -rp "Press Enter to continue..."
}
# Function to set active profile
set_active_profile() {
echo ""
read -rp "Enter the name of the profile to activate: " profile_name
echo -e "${GREEN}Setting active profile to $profile_name...${NC}"
sleep 1
tuned-adm profile "$profile_name"
sleep 1
read -rp "Press Enter to continue..."
}
# Function to enable tuned service
enable_tuned() {
echo ""
echo -e "${GREEN}Enabling Tuned Service...${NC}"
sudo systemctl enable tuned
sudo systemctl start tuned
echo -e "${GREEN}Tuned Service has been enabled and started.${NC}"
sleep 1
read -rp "Press Enter to continue..."
}
# Function to disable tuned service
disable_tuned() {
echo ""
echo -e "${RED}Disabling Tuned Service...${NC}"
sudo systemctl stop tuned
sudo systemctl disable tuned
echo -e "${RED}Tuned Service has been disabled.${NC}"
sleep 1
read -rp "Press Enter to continue..."
}
# Function to check status of tuned service
check_status() {
echo ""
echo -e "${GREEN}Checking Tuned Service Status...${NC}"
systemctl status tuned --no-pager
sleep 1
read -rp "Press Enter to continue..."
}
# Go back to main menu
main_menu() {
chmod +x manager
./manager
}
# Main loop
while true; do
display_menu # Display the menu
read -r choice
case $choice in
1) install_tuned ;; # Install Tuned
2) uninstall_tuned ;; # Uninstall Tuned
3) list_profiles ;; # List available profiles
4) show_active_profile ;; # Show current active profile
5) set_active_profile ;; # Set active profile
6) enable_tuned ;; # Enable Tuned service
7) disable_tuned ;; # Disable Tuned service
8) check_status ;; # Check Tuned service status
9) main_menu ;; # Go back to main menu
*) echo "" && echo -e "${RED}Invalid choice. Please try again.${NC}" && sleep 3 ;; # Invalid choice
esac
done