This commit is contained in:
Lars Engels
2023-03-14 22:03:16 +01:00
parent 09a1d306dc
commit c94f653e0b
+18 -18
View File
@@ -57,32 +57,32 @@ TAGS="${2}"
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags" bastille_jail_tags="${bastille_jailsdir}/${_jail}/tags"
if [ "${ACTION}" = "list" ]; then case ${ACTION} in
[ -f "${bastille_jail_tags}" ] && cat "${bastille_jail_tags}" add)
continue for _tag in $(echo ${TAGS} | tr , ' '); do
fi
for _tag in $(echo ${TAGS} | tr , ' '); do
case ${ACTION} in
add)
echo ${_tag} >> "${bastille_jail_tags}" echo ${_tag} >> "${bastille_jail_tags}"
tmpfile="$(mktemp)" tmpfile="$(mktemp)"
sort "${bastille_jail_tags}" | uniq > "${tmpfile}" sort "${bastille_jail_tags}" | uniq > "${tmpfile}"
mv "${tmpfile}" "${bastille_jail_tags}" mv "${tmpfile}" "${bastille_jail_tags}"
;; done
del*) ;;
if [ ! -f "${bastille_jail_tags}" ]; then del*)
break for _tag in $(echo ${TAGS} | tr , ' '); do
fi [ ! -f "${bastille_jail_tags}" ] && break # skip if no tags file
tmpfile="$(mktemp)" tmpfile="$(mktemp)"
grep -Ev "^${_tag}\$" "${bastille_jail_tags}" > "${tmpfile}" grep -Ev "^${_tag}\$" "${bastille_jail_tags}" > "${tmpfile}"
mv "${tmpfile}" "${bastille_jail_tags}" mv "${tmpfile}" "${bastille_jail_tags}"
# delete tags file if empty # delete tags file if empty
[ ! -s "${bastille_jail_tags}" ] && rm "${bastille_jail_tags}" [ ! -s "${bastille_jail_tags}" ] && rm "${bastille_jail_tags}"
;; done
*) ;;
usage list)
;; [ -f "${bastille_jail_tags}" ] && cat "${bastille_jail_tags}"
esac continue
done ;;
*)
usage
;;
esac
done done