2017-07-19 11:36:20 +02:00
|
|
|
#!/bin/sh
|
2016-12-20 11:04:24 +01:00
|
|
|
#
|
2017-01-17 16:50:39 +01:00
|
|
|
# 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
|
|
|
|
#
|
2016-12-18 15:45:15 +01:00
|
|
|
|
2018-03-27 17:11:25 +02:00
|
|
|
set -u
|
|
|
|
|
2019-01-04 13:51:05 +01:00
|
|
|
[ "$(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'
|
2020-04-01 07:24:33 +02:00
|
|
|
# shellcheck source=lib/config
|
2020-04-02 00:31:57 +02:00
|
|
|
. "${LIBDIR}/includes"
|
2019-01-04 13:51:05 +01:00
|
|
|
|
|
|
|
subcommand="${1:-}"
|
|
|
|
jail="${2:-}"
|
|
|
|
option="${3:-}"
|
|
|
|
|
2019-01-07 14:47:05 +01:00
|
|
|
if [ ! -x "${LIBDIR}/bkctld-${subcommand}" ]; then
|
|
|
|
"${LIBDIR}/bkctld-help" && exit 1
|
|
|
|
fi
|
2019-01-04 13:51:05 +01:00
|
|
|
|
|
|
|
case "${subcommand}" in
|
2019-01-08 16:23:46 +01:00
|
|
|
"inc" | "rm" | "check" | "stats" | "help" | "list")
|
2019-01-04 13:51:05 +01:00
|
|
|
"${LIBDIR}/bkctld-${subcommand}"
|
|
|
|
;;
|
2019-01-07 16:34:14 +01:00
|
|
|
"init" | "is-on")
|
2019-01-04 13:51:05 +01:00
|
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}"
|
|
|
|
;;
|
|
|
|
"key" | "port" | "ip")
|
2019-01-04 16:38:20 +01:00
|
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}" "${option}"
|
2019-01-04 13:51:05 +01:00
|
|
|
;;
|
2019-01-04 16:55:56 +01:00
|
|
|
"start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove" | "firewall")
|
2020-04-02 13:40:48 +02:00
|
|
|
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
|
2019-01-04 13:51:05 +01:00
|
|
|
;;
|
|
|
|
"status")
|
2020-04-02 13:40:48 +02:00
|
|
|
if [ -z "${jail}" ]; then
|
|
|
|
"${LIBDIR}/bkctld-list"|xargs --no-run-if-empty --max-args=1 "${LIBDIR}/bkctld-${subcommand}"
|
|
|
|
else
|
|
|
|
"${LIBDIR}/bkctld-${subcommand}" "${jail}"
|
|
|
|
fi
|
2019-01-04 13:51:05 +01:00
|
|
|
;;
|
|
|
|
esac
|