-
Notifications
You must be signed in to change notification settings - Fork 3
/
dnf
executable file
·162 lines (147 loc) · 5.52 KB
/
dnf
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
#!/usr/bin/env bash
# Define some color variables
SKYBLUE='\e[1;38;2;135;206;235m'
PEACH='\e[1;38;2;255;204;153m'
GREEN='\033[1m\033[38;2;0;255;0m'
RED='\033[1m\033[38;5;196m'
NC='\033[0m' # No Color
# Function to display a menu with options
display_menu() {
# Show heading in middle
clear
echo ""
COLUMNS=$(tput cols)
t1="================="
t2="DNF App Manager"
printf "${SKYBLUE}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
printf "${SKYBLUE}%*s\n${NC}" $(((${#t2} + $COLUMNS) / 2)) "$t2"
printf "${SKYBLUE}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
echo ""
echo -e "${PEACH}Select Your Choice:${NC}"
echo " 1. List All Apps"
echo " 2. List User Installed Apps"
echo " 3. Update All Apps"
echo " 4. Search & Install App"
echo " 5. Uninstall App"
echo " 6. Delete DNF Cache & Unnecessary Data"
echo " 7. List All Groups"
echo " 8. List Installed Groups"
echo " 9. Go Back To Main Menu"
echo ""
echo -n "Enter your choice: "
}
# Function to list all installed dnf apps
list_all_apps() {
echo ""
echo -e "${GREEN}Listing All Apps:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dnf list --installed # Use dnf command to list all apps
sleep 1
read -rp "Press Enter to continue..."
}
# Function to list user installed dnf apps
list_user_apps() {
echo ""
echo -e "${GREEN}Listing User Installed Apps:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dnf repoquery --userinstalled # Use dnf command to list user apps
sleep 1
read -rp "Press Enter to continue..."
}
# Function to update all installed dnf apps
update_apps() {
echo ""
echo -e "${GREEN}Updating All Apps...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
sudo dnf upgrade --refresh # Use sudo and dnf command to upgrade all apps with refresh option
sleep 1
read -rp "Press Enter to continue..."
}
# Function to search & install a specific dnf app
install_app() {
echo ""
read -rp "Enter the app name to search: " app_name
echo -e "${GREEN}Searching for $app_name...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dnf search "$app_name" # Use dnf command to search for app name
sleep 1
echo -e "${GREEN}-----------------------${NC}"
read -rp "Enter the exact app name from above shown list to install: " app_install
sudo dnf install "$app_install" # Use sudo and dnf command to install app
sleep 1
read -rp "Press Enter to continue..."
}
# Function to uninstall a specific dnf app
uninstall_app() {
echo ""
read -rp "Enter the app name to uninstall: " app_name
sudo dnf remove "$app_name" # Use sudo and dnf command to uninstall app
sleep 1
read -rp "Press Enter to continue..."
}
# Function to delete DNF cache and unnecessary data
delete_unused() {
echo ""
echo -e "${GREEN}Deleting DNF Cache & Unnecessary Data...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
sudo dnf clean all # Use sudo and dnf command to clean up all cache data
sudo dnf autoremove # Use sudo and dnf command to remove unused packages
sleep 1
read -rp "Press Enter to continue..."
}
# Function to list all groups and optionally install a group
list_all_groups() {
echo ""
echo -e "${GREEN}Listing All Groups:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dnf group list --hidden # Show all groups
sleep 1
# Ask if user wants to install any group
echo ""
read -rp "Do you want to install any group from the list? (Y/n): " choice
if [[ $choice == "Y" || $choice == "y" ]]; then
read -rp "Enter the name of the group you want to install: " group_name
sudo dnf group install "$group_name" -y
echo -e "${GREEN}Operation completed successfully.${NC}"
fi
# Continue
read -rp "Press Enter to continue..."
}
# Function to list installed groups
list_installed_groups() {
echo ""
echo -e "${GREEN}Listing Installed Groups:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dnf group list --hidden --installed # Show installed groups
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 # Handle the choice
1) list_all_apps ;; # List all apps
2) list_user_apps ;; # List user apps
3) update_apps ;; # Update all apps
4) install_app ;; # Install app
5) uninstall_app ;; # Uninstall app
6) delete_unused ;; # Delete dnf cache and unnecessary data
7) list_all_groups ;; # List all DNF groups
8) list_installed_groups ;; # List installed DNF groups
9) main_menu ;; # Exit to main menu
*) echo "" && echo -e "${RED}Invalid choice. Please try again.${NC}" && sleep 3 ;; # Invalid choice
esac
done