Fix #1533 : revert chroot-dir -> chroot-name change

I want chroot-ssh.sh stay evo-independant, then we can't "detect" chroot dir.
This commit is contained in:
Gregory Colpart 2015-08-14 18:26:45 +02:00
parent 1b02ba0a70
commit ecd3190fdd

View file

@ -17,12 +17,14 @@
# kill -9 $(chroot /backup/jails/myserver cat /var/run/sshd.pid) # kill -9 $(chroot /backup/jails/myserver cat /var/run/sshd.pid)
# chroot /backup/jails/myserver /usr/sbin/sshd > /dev/null # chroot /backup/jails/myserver /usr/sbin/sshd > /dev/null
# After *each* ssh upgrade or libs upgrade: # *Warning* : this setting is specific EvoBackup but used *only*
# for guessing SSH port and updating all the chroot
BACKUP_PATH='/backup/jails'
# With all your jails in $BACKUP_PATH, after *each* ssh upgrade
# or libs upgrade, you can upgrade all your chroots with:
# sh chroot-ssh.sh updateall # sh chroot-ssh.sh updateall
# And restart all sshd daemons # And restart all sshd daemons
# We suppose jails are all in /backup/jails...
BACKUP_PATH='/backup/jails'
# Are we root? # Are we root?
id=$(id -u) id=$(id -u)
@ -36,16 +38,18 @@ usage() {
cat <<EOT cat <<EOT
Add an OpenSSH chroot. Add an OpenSSH chroot.
Usage: $0 -n chroot-name -i ip -p port -k pub-key-path Usage: $0 -n chroot-dir -i ip -p port -k pub-key-path
Mandatory parameters: Mandatory parameters:
-n: name of chroot -n: directory of chroot
Optional parameters: Optional parameters:
-i: IP address of the client machine. -i: IP address of the client machine.
-k: Path to the SSH public key of the client machine. -k: Path to the SSH public key of the client machine.
-p: SSH port which chroot/jail will listen on. -p: SSH port which chroot/jail will listen on.
If you set "guess", port will be guessed if there is already one chroot. If you set "guess", port will be guessed if there is already one chroot
and all your chroots are in $BACKUP_PATH
EOT EOT
@ -87,7 +91,7 @@ done
while getopts ':n:i:p:k:' opt; do while getopts ':n:i:p:k:' opt; do
case $opt in case $opt in
n) n)
jail=$OPTARG chrootdir=$OPTARG
;; ;;
i) i)
ip=$OPTARG ip=$OPTARG
@ -105,11 +109,8 @@ while getopts ':n:i:p:k:' opt; do
esac esac
done done
# Complete path to chroot dir.
chrootdir=${BACKUP_PATH}/${jail}
# Verify parameters. # Verify parameters.
if [ -z $jail ]; if [ -z $chrootdir ];
then then
usage usage
exit 1 exit 1
@ -135,8 +136,8 @@ if [ "$port" = "guess" ]; then
fi fi
fi fi
# Used for updating jails. # specific EvoBackup (use ${BACKUP_PATH}) : updating jails in /backup/jails
if [ "$jail" = "updateall" ]; then if [ "$chrootdir" = "updateall" ]; then
for i in $(ls -1 ${BACKUP_PATH}/*/lib/x86_64-linux-gnu/libnss_compat.so.2); do for i in $(ls -1 ${BACKUP_PATH}/*/lib/x86_64-linux-gnu/libnss_compat.so.2); do
chrootdir=$(echo $i | cut -d"/" -f1,2,3,4) chrootdir=$(echo $i | cut -d"/" -f1,2,3,4)