-
Notifications
You must be signed in to change notification settings - Fork 3
/
deb
executable file
·103 lines (94 loc) · 3.49 KB
/
deb
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
#!/usr/bin/env bash
# Define some color variables
LIME='\e[1;38;2;50;205;50m'
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() {
# Show heading in middle
clear
echo ""
COLUMNS=$(tput cols)
t1="================="
t2="DEB App Manager"
printf "${LIME}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
printf "${LIME}%*s\n${NC}" $(((${#t2} + $COLUMNS) / 2)) "$t2"
printf "${LIME}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
echo ""
echo -e "${PEACH}Select Your Choice:${NC}"
echo " 1. List All Apps"
echo " 2. Search Installed App"
echo " 3. Install DEB Package"
echo " 4. Uninstall App"
echo " 5. Go Back To Main Menu"
echo ""
echo -n "Enter your choice: "
}
# Function to list all installed deb apps
list_all_apps() {
echo ""
echo -e "${AQUA}NOTE: Press Q key anytime, to go back to the menu.${NC}"
echo ""
sleep 3
echo -e "${GREEN}Listing All Installed DEB Packages:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dpkg -l # List all packages using dpkg
sleep 1
read -rp "Press Enter to continue..."
}
# Function to search a specific installed deb app
search_app() {
echo ""
read -rp "Enter the name or keyword of the DEB package to search: " keyword
echo -e "${GREEN}Searching for $keyword...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
dpkg -l | grep "$keyword" # Search for packages using dpkg and grep
sleep 1
read -rp "Press Enter to continue..."
}
# Function to install a deb file from local path or URL
install_app() {
echo ""
read -rp "Enter the local path or URL of the DEB file: " file_path
if [[ $file_path == http* ]]; then # If file path is a URL
wget "$file_path" # Download the file using wget
file_name=${file_path##*/} # Extract the file name from the URL
sudo dpkg -i "$file_name" # Install the file using dpkg
rm "$file_name" # Remove the downloaded file
else # If file path is a local path
sudo dpkg -i "$file_path" # Install the file using dpkg
fi
sleep 1
read -rp "Press Enter to continue..."
}
# Function to uninstall a specific deb app
uninstall_app() {
echo ""
read -rp "Enter the name of the DEB package to remove: " package_name
sudo dpkg -r "$package_name" # Remove the package using dpkg
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) search_app ;; # Search for specific installed app
3) install_app ;; # Install app
4) uninstall_app ;; # Uninstall app
5) main_menu ;; # Exit to main menu
*) echo "" && echo -e "${RED}Invalid choice. Please try again.${NC}" && sleep 3 ;; # Invalid choice
esac
done