52 lines
1.5 KiB
Bash
Executable file
52 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# bkctld is a shell script to create and manage a backup server which will
|
|
# handle the backup of many servers (clients).
|
|
#
|
|
# Author: Victor Laborie <vlaborie@evolix.fr>
|
|
# Contributor: Benoît Série <bserie@evolix.fr>, Gregory Colpart <reg@evolix.fr>, Romain Dessort <rdessort@evolix.fr>, Tristan Pilat <tpilat@evolix.fr>
|
|
# Licence: AGPLv3
|
|
#
|
|
|
|
set -u
|
|
|
|
[ "$(id -u)" -ne 0 ] && error "You need to be root to run ${0} !"
|
|
|
|
[ -d './lib' ] && LIBDIR='lib'
|
|
[ -d '/usr/lib/bkctld' ] && LIBDIR='/usr/lib/bkctld'
|
|
. "${LIBDIR}/config"
|
|
|
|
subcommand="${1:-}"
|
|
jail="${2:-}"
|
|
option="${3:-}"
|
|
|
|
if [ ! -x "${LIBDIR}/bkctld-${subcommand}" ]; then
|
|
"${LIBDIR}/bkctld-help" && exit 1
|
|
fi
|
|
|
|
case "${subcommand}" in
|
|
"inc" | "rm" | "check" | "stats" | "help" | "list")
|
|
"${LIBDIR}/bkctld-${subcommand}"
|
|
;;
|
|
"init" | "is-on")
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}"
|
|
;;
|
|
"key" | "port" | "ip")
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}" "${option}"
|
|
;;
|
|
"start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove" | "firewall")
|
|
if [ "${jail}" = "all" ]; then
|
|
"${LIBDIR}/bkctld-list"|xargs --no-run-if-empty --max-args=1 --max-procs=0 "${LIBDIR}/bkctld-${subcommand}"
|
|
else
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}"
|
|
fi
|
|
;;
|
|
"status")
|
|
if [ -z "${jail}" ]; then
|
|
"${LIBDIR}/bkctld-list"|xargs --no-run-if-empty --max-args=1 "${LIBDIR}/bkctld-${subcommand}"
|
|
else
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}"
|
|
fi
|
|
;;
|
|
esac
|