mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-23 18:50:46 +01:00
Remove sort option to fix recent conflicts
Remove the sort option to fix the recent conflicts.
This commit is contained in:
10
usr/local/bin/bastille
Normal file → Executable file
10
usr/local/bin/bastille
Normal file → Executable file
@@ -203,9 +203,11 @@ case "${CMD}" in
|
|||||||
# Commands that don't allow parallel mode
|
# Commands that don't allow parallel mode
|
||||||
bootstrap| \
|
bootstrap| \
|
||||||
clone| \
|
clone| \
|
||||||
|
cmd| \
|
||||||
console| \
|
console| \
|
||||||
convert| \
|
convert| \
|
||||||
create| \
|
create| \
|
||||||
|
destroy| \
|
||||||
edit| \
|
edit| \
|
||||||
etcupdate| \
|
etcupdate| \
|
||||||
export| \
|
export| \
|
||||||
@@ -213,10 +215,13 @@ case "${CMD}" in
|
|||||||
import| \
|
import| \
|
||||||
limits| \
|
limits| \
|
||||||
list| \
|
list| \
|
||||||
|
migrate| \
|
||||||
network| \
|
network| \
|
||||||
|
pkg| \
|
||||||
rcp| \
|
rcp| \
|
||||||
rdr| \
|
rdr| \
|
||||||
rename| \
|
rename| \
|
||||||
|
service| \
|
||||||
setup| \
|
setup| \
|
||||||
top| \
|
top| \
|
||||||
update| \
|
update| \
|
||||||
@@ -227,17 +232,12 @@ case "${CMD}" in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
# Commands that allow parallel mode
|
# Commands that allow parallel mode
|
||||||
cmd| \
|
|
||||||
config| \
|
config| \
|
||||||
cp| \
|
cp| \
|
||||||
destroy| \
|
|
||||||
jcp| \
|
jcp| \
|
||||||
limits| \
|
limits| \
|
||||||
migrate| \
|
|
||||||
mount| \
|
mount| \
|
||||||
pkg| \
|
|
||||||
restart| \
|
restart| \
|
||||||
service| \
|
|
||||||
start| \
|
start| \
|
||||||
stop| \
|
stop| \
|
||||||
sysrc| \
|
sysrc| \
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ usage() {
|
|||||||
-d | --down List stopped jails only.
|
-d | --down List stopped jails only.
|
||||||
-j | --json List jails or sub-arg(s) in json format.
|
-j | --json List jails or sub-arg(s) in json format.
|
||||||
-p | --pretty Print JSON in columns.
|
-p | --pretty Print JSON in columns.
|
||||||
-s | --sort VALUE Print info in VALUE order.
|
|
||||||
-u | --up List running jails only.
|
-u | --up List running jails only.
|
||||||
-x | --debug Enable debug mode.
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
@@ -52,10 +51,10 @@ EOF
|
|||||||
print_info() {
|
print_info() {
|
||||||
|
|
||||||
# Print jails in given order
|
# Print jails in given order
|
||||||
for _file in $(echo ${_tmp_list}); do
|
for _file in $(echo ${_tmp_list} | sort); do
|
||||||
cat ${_file}
|
cat ${_file}
|
||||||
rm -f ${_file}
|
rm -f ${_file}
|
||||||
done | sort ${OPT_SORT}
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
pretty_json() {
|
pretty_json() {
|
||||||
@@ -194,8 +193,8 @@ get_jail_info() {
|
|||||||
# Get info if jail is UP
|
# Get info if jail is UP
|
||||||
if [ "$(awk '$1 == "vnet;" { print $1 }' "${bastille_jailsdir}/${JAIL_NAME}/jail.conf" 2> /dev/null)" ]; then
|
if [ "$(awk '$1 == "vnet;" { print $1 }' "${bastille_jailsdir}/${JAIL_NAME}/jail.conf" 2> /dev/null)" ]; then
|
||||||
# Get IP for VNET jails
|
# Get IP for VNET jails
|
||||||
JAIL_IP4="$(jexec -l ${JAIL_NAME} ifconfig -an | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}')"
|
JAIL_IP4="$(jexec -l ${JAIL_NAME} ifconfig -an | grep "^[[:space:]]*inet " | grep -v "127.0.0.1" | awk '{print $2}')"
|
||||||
JAIL_IP6="$(jexec -l ${JAIL_NAME} ifconfig -an | grep "inet6" | grep -Ev 'lo[0-9]+| ::1 | fe80::' | awk '{print $2}' | sed 's/%.*//g')"
|
JAIL_IP6="$(jexec -l ${JAIL_NAME} ifconfig -an | grep "^[[:space:]]*inet6" | grep -Ev 'lo[0-9]+| ::1 | fe80::' | awk '{print $2}' | sed 's/%.*//g')"
|
||||||
else
|
else
|
||||||
# Get IP for standard jails
|
# Get IP for standard jails
|
||||||
JAIL_IP4=$(jls -j ${JAIL_NAME} ip4.addr | sed 's/,/\n/g')
|
JAIL_IP4=$(jls -j ${JAIL_NAME} ip4.addr | sed 's/,/\n/g')
|
||||||
@@ -646,7 +645,6 @@ TARGET=""
|
|||||||
OPT_JSON=0
|
OPT_JSON=0
|
||||||
OPT_PRETTY=0
|
OPT_PRETTY=0
|
||||||
OPT_STATE="all"
|
OPT_STATE="all"
|
||||||
OPT_SORT="-k2"
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-h|--help|help)
|
-h|--help|help)
|
||||||
@@ -664,25 +662,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
OPT_PRETTY=1
|
OPT_PRETTY=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-s|--sort)
|
|
||||||
if [ -n "${3}" ]; then
|
|
||||||
error_exit "[ERROR]: [-s|--sort] can only be used with 'bastille list'."
|
|
||||||
fi
|
|
||||||
case "${2}" in
|
|
||||||
jid) OPT_SORT="-k1 -n" ;;
|
|
||||||
name) OPT_SORT="-k2" ;;
|
|
||||||
boot) OPT_SORT="-k3" ;;
|
|
||||||
prio|priority) OPT_SORT="-k4 -n" ;;
|
|
||||||
state) OPT_SORT="-k5" ;;
|
|
||||||
type|jailtype) OPT_SORT="-k6" ;;
|
|
||||||
ip) OPT_SORT="-k7 -n" ;;
|
|
||||||
ports) OPT_SORT="-k8 -n" ;;
|
|
||||||
release) OPT_SORT="-k9" ;;
|
|
||||||
tags) OPT_SORT="-k10" ;;
|
|
||||||
*) error_exit "Invalid sort option: \"${2}\"" ;;
|
|
||||||
esac
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
-u|--up)
|
-u|--up)
|
||||||
OPT_STATE="Up"
|
OPT_STATE="Up"
|
||||||
shift
|
shift
|
||||||
@@ -734,7 +713,6 @@ fi
|
|||||||
if [ "$#" -eq 1 ]; then
|
if [ "$#" -eq 1 ]; then
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-a|--all|all)
|
-a|--all|all)
|
||||||
OPT_SORT="-k2"
|
|
||||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||||
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
||||||
list_all | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Boot\":\"%s\",\"Prio\":\"%s\",\"State\":\"%s\",\"IP Address\":\"%s\",\"Published Ports\":\"%s\",\"Hostname\":\"%s\",\"Release\":\"%s\",\"Path\":\"%s\"}",$1,$2,$3,$4,$5,$6,$7,$8,$9} END{print "\n]"}' | pretty_json
|
list_all | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Boot\":\"%s\",\"Prio\":\"%s\",\"State\":\"%s\",\"IP Address\":\"%s\",\"Published Ports\":\"%s\",\"Hostname\":\"%s\",\"Release\":\"%s\",\"Path\":\"%s\"}",$1,$2,$3,$4,$5,$6,$7,$8,$9} END{print "\n]"}' | pretty_json
|
||||||
@@ -746,7 +724,6 @@ if [ "$#" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ip|ips)
|
ip|ips)
|
||||||
OPT_SORT="-k3 -n"
|
|
||||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||||
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
||||||
list_ips | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"IP Address\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
list_ips | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"IP Address\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
||||||
@@ -758,7 +735,6 @@ if [ "$#" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
path|paths)
|
path|paths)
|
||||||
OPT_SORT="-k3"
|
|
||||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||||
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
if [ "${OPT_PRETTY}" -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]"}' | pretty_json
|
list_paths | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Path\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
||||||
@@ -770,7 +746,6 @@ if [ "$#" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
rdr|port|ports)
|
rdr|port|ports)
|
||||||
OPT_SORT="-k3 -n"
|
|
||||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||||
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
if [ "${OPT_PRETTY}" -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]"}' | pretty_json
|
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]"}' | pretty_json
|
||||||
@@ -782,7 +757,6 @@ if [ "$#" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
state|status)
|
state|status)
|
||||||
OPT_SORT="-k3"
|
|
||||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||||
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
||||||
list_state | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"State\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
list_state | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"State\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
||||||
@@ -794,7 +768,6 @@ if [ "$#" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
type|jailtype)
|
type|jailtype)
|
||||||
OPT_SORT="-k3"
|
|
||||||
if [ "${OPT_JSON}" -eq 1 ]; then
|
if [ "${OPT_JSON}" -eq 1 ]; then
|
||||||
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
if [ "${OPT_PRETTY}" -eq 1 ]; then
|
||||||
list_type | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Type\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
list_type | awk 'BEGIN{print "["} NR>1{if(NR>2)print ","; printf " {\"JID\":\"%s\",\"Name\":\"%s\",\"Type\":\"%s\"}",$1,$2,$3} END{print "\n]"}' | pretty_json
|
||||||
|
|||||||
Reference in New Issue
Block a user