mirror of
https://github.com/BastilleBSD/bastille.git
synced 2025-12-11 01:19:52 +01:00
Re-work "list" command / output and add "search" command.
This commit is contained in:
@@ -35,9 +35,11 @@
|
||||
usage() {
|
||||
error_notify "Usage: bastille tags TARGET add tag1,tag2,..."
|
||||
error_notify " bastille tags TARGET delete tag1,tag2,..."
|
||||
error_notify " bastille tags TARGET search tag"
|
||||
error_notify " bastille tags TARGET list"
|
||||
echo -e "Example: bastille tags JAILNAME add database,mysql"
|
||||
echo -e " bastille tags JAILNAME delete mysql"
|
||||
echo -e " bastille tags ALL search mysql"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -76,9 +78,20 @@ for _jail in ${JAILS}; do
|
||||
[ ! -s "${bastille_jail_tags}" ] && rm "${bastille_jail_tags}"
|
||||
done
|
||||
;;
|
||||
search)
|
||||
[ -n "$(echo ${TAGS} | grep ,)" ] && usage # Only one tag per query
|
||||
[ ! -f "${bastille_jail_tags}" ] && continue # skip if there is no tags file
|
||||
grep -qE "^${TAGS}\$" "${bastille_jail_tags}"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "${_jail}"
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
list)
|
||||
[ -f "${bastille_jail_tags}" ] && cat "${bastille_jail_tags}"
|
||||
continue
|
||||
if [ -f "${bastille_jail_tags}" ]; then
|
||||
echo -n "${_jail}: "
|
||||
xargs < "${bastille_jail_tags}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
|
||||
Reference in New Issue
Block a user