mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-03 19:23:42 +01:00
cp: update to use new functions in common.sh
This commit is contained in:
@@ -34,49 +34,63 @@
|
||||
. /usr/local/etc/bastille/bastille.conf
|
||||
|
||||
usage() {
|
||||
error_exit "Usage: bastille cp [OPTION] TARGET HOST_PATH CONTAINER_PATH"
|
||||
error_notify "Usage: bastille cp [option(s)] TARGET HOST_PATH JAIL_PATH"
|
||||
cat << EOF
|
||||
Options:
|
||||
|
||||
-q | --quiet Suppress output.
|
||||
-x | --debug Enable debug mode.
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
CPSOURCE="${1}"
|
||||
CPDEST="${2}"
|
||||
# Handle options.
|
||||
OPTION="-av"
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-h|--help|help)
|
||||
usage
|
||||
;;
|
||||
-q|--quiet)
|
||||
OPTION="-a"
|
||||
shift
|
||||
;;
|
||||
-x|--debug)
|
||||
enable_debug
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do
|
||||
case ${_opt} in
|
||||
q) OPTION="-a" ;;
|
||||
x) enable_debug ;;
|
||||
*) error_exit "Unknown Option: \"${1}\"" ;;
|
||||
esac
|
||||
done
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Handle special-case commands first.
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
-q|--quiet)
|
||||
OPTION="${1}"
|
||||
CPSOURCE="${2}"
|
||||
CPDEST="${3}"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
if [ "$#" -ne 3 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
bastille_root_check
|
||||
TARGET="${1}"
|
||||
CPSOURCE="${2}"
|
||||
CPDEST="${3}"
|
||||
|
||||
case "${OPTION}" in
|
||||
-q|--quiet)
|
||||
OPTION="-a"
|
||||
;;
|
||||
*)
|
||||
OPTION="-av"
|
||||
;;
|
||||
esac
|
||||
bastille_root_check
|
||||
set_target "${TARGET}"
|
||||
|
||||
for _jail in ${JAILS}; do
|
||||
info "[${_jail}]:"
|
||||
bastille_jail_path="${bastille_jailsdir}/${_jail}/root"
|
||||
cp "${OPTION}" "${CPSOURCE}" "${bastille_jail_path}/${CPDEST}"
|
||||
RETURN="$?"
|
||||
if [ "${TARGET}" = "ALL" ]; then
|
||||
# Display the return status for reference
|
||||
echo -e "Returned: ${RETURN}\n"
|
||||
else
|
||||
echo
|
||||
return "${RETURN}"
|
||||
if ! cp "${OPTION}" "${CPSOURCE}" "${bastille_jail_path}${CPDEST}"; then
|
||||
error_continue "CP failed: ${CPSOURCE} -> ${bastille_jail_path}${CPDEST}"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user