mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-01 10:20:55 +01:00
list: Add path list also
This commit is contained in:
@@ -327,6 +327,32 @@ list_all(){
|
||||
done
|
||||
}
|
||||
|
||||
list_paths() {
|
||||
|
||||
get_max_lengths
|
||||
|
||||
# Check if we want only a single jail, or all jails
|
||||
if [ -n "${TARGET}" ]; then
|
||||
JAIL_LIST="${TARGET}"
|
||||
else
|
||||
JAIL_LIST=$(ls --color=never "${bastille_jailsdir}" | sed "s/\n//g")
|
||||
fi
|
||||
|
||||
# Print header
|
||||
printf " JID%*sName%*sPath\n" "$((${MAX_LENGTH_JID} + ${SPACER} - 3))" "" "$((${MAX_LENGTH_JAIL_NAME} + ${SPACER} - 4))" ""
|
||||
|
||||
for _jail in ${JAIL_LIST}; do
|
||||
|
||||
if [ -f "${bastille_jailsdir}/${_jail}/jail.conf" ]; then
|
||||
|
||||
get_jail_info "${_jail}"
|
||||
|
||||
printf " ${JID}%*s${JAIL_NAME}%*s${JAIL_PATH}\n" "$((${MAX_LENGTH_JID} - ${#JID} + ${SPACER}))" "" "$((${MAX_LENGTH_JAIL_NAME} - ${#JAIL_NAME} + ${SPACER}))" ""
|
||||
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
list_ports() {
|
||||
|
||||
get_max_lengths
|
||||
@@ -446,9 +472,12 @@ if [ "$#" -eq 0 ]; then
|
||||
else
|
||||
list_bastille
|
||||
fi
|
||||
elif [ "$#" -eq 2 ]; then
|
||||
set_target "${1}" || exit 1
|
||||
shift 1
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
if [ "$#" -eq 1 ]; then
|
||||
case "${1}" in
|
||||
-a|--all|all)
|
||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||
@@ -457,6 +486,13 @@ if [ "$#" -gt 0 ]; then
|
||||
list_all
|
||||
fi
|
||||
;;
|
||||
path|paths)
|
||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||
list_paths | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Path\":\"%s\"}",$1,$2,$3} END{print "\n]"}'
|
||||
else
|
||||
list_paths
|
||||
fi
|
||||
;;
|
||||
rdr|port|ports)
|
||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||
list_ports | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Published_Ports\":\"%s\"}",$1,$2,$3} END{print "\n]"}'
|
||||
@@ -488,10 +524,12 @@ if [ "$#" -gt 0 ]; then
|
||||
TARGET="${1}"
|
||||
set_target "${TARGET}"
|
||||
if [ -f "${bastille_jailsdir}/${TARGET}/jail.conf" ]; then
|
||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||
list_bastille | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Boot\":\"%s\",\"Prio\":\"%s\",\"State\":\"%s\",\"Type\":\"%s\",\"IP_Address\":\"%s\",\"Published_Ports\":\"%s\",\"Release\":\"%s\",\"Tags\":\"%s\"}",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10} END{print "\n]"}'
|
||||
else
|
||||
list_bastille
|
||||
if [ "$#" -eq 0 ]; then
|
||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||
list_bastille | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Boot\":\"%s\",\"Prio\":\"%s\",\"State\":\"%s\",\"Type\":\"%s\",\"IP_Address\":\"%s\",\"Published_Ports\":\"%s\",\"Release\":\"%s\",\"Tags\":\"%s\"}",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10} END{print "\n]"}'
|
||||
else
|
||||
list_bastille
|
||||
fi
|
||||
fi
|
||||
else
|
||||
usage
|
||||
|
||||
Reference in New Issue
Block a user