Skip to content

Commit 4fe99d1

Browse files
author
Kristan Kenney
committed
Implement v-search-command
Enables the server administrator to search through all available HestiaCP-specific commands. Thanks @fedekrum!
1 parent 49deb93 commit 4fe99d1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

bin/v-search-command

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# info: search for available commands
4+
#
5+
# This function searches for available Hestia Control Panel commands
6+
# and returns results based on the specified criteria.
7+
#
8+
# Originally developed for VestaCP by Federico Krum
9+
# https://github.com/FastDigitalOceanDroplets/VestaCP/blob/master/files/v-search-command
10+
11+
#----------------------------------------------------------#
12+
# Variable&Function #
13+
#----------------------------------------------------------#
14+
source $HESTIA/func/main.sh
15+
16+
#----------------------------------------------------------#
17+
# Verifications #
18+
#----------------------------------------------------------#
19+
if [ $# -eq 0 ]; then
20+
echo "ERROR: No search arguments specified."
21+
echo "Usage: v-search-command ARG1 [ARG2] [ARG...]"
22+
exit 1
23+
fi
24+
25+
#----------------------------------------------------------#
26+
# Action #
27+
#----------------------------------------------------------#
28+
29+
SearchPath=`ls -a $HESTIA/bin/ | sort`
30+
TotalItems=`ls -a $HESTIA/bin/ | sort | wc -l`
31+
32+
for i; do
33+
SearchResults=`echo $SearchPath | tr " " "\n" | grep $i`
34+
FoundItems=`echo $SearchResults | tr " " "\n" | grep $i | wc -l`
35+
done
36+
37+
if [ -z "$SearchResults" ]; then
38+
echo "No available commands were found matching the specified critera."
39+
echo "There are a total of $TotalItems commands available."
40+
else
41+
echo "Command Search Results"
42+
echo "================================="
43+
echo $SearchResults | tr " " "\n"
44+
echo "================================="
45+
echo "Found $FoundItems matching items in $TotalItems commands."
46+
fi
47+
exit

0 commit comments

Comments
 (0)