51 lines
1.3 KiB
Bash
Executable file
51 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: evobackup
|
|
# Required-Start: $syslog
|
|
# Required-Stop: $syslog
|
|
# Default-Start: 2
|
|
# Default-Stop: 1
|
|
# Short-Description: Backup manager using rsync and OpenSSH chroot.
|
|
### END INIT INFO
|
|
|
|
set -e
|
|
BACKUP_PATH=/backup
|
|
|
|
case "$1" in
|
|
start)
|
|
for jail in ${BACKUP_PATH}/jails/*; do
|
|
mount -t proc proc-chroot ${jail}/proc/
|
|
mount -t devtmpfs udev ${jail}/dev/
|
|
mount -t devpts devpts ${jail}/dev/pts
|
|
chroot ${jail} /usr/sbin/sshd > /dev/null
|
|
done
|
|
;;
|
|
|
|
stop)
|
|
for jail in ${BACKUP_PATH}/jails/*; do
|
|
kill $(chroot $jail cat /var/run/sshd.pid)
|
|
umount ${jail}/proc/
|
|
umount ${jail}/dev/pts/
|
|
# Need to wait a little time before unmounting /dev
|
|
sleep 0.2
|
|
umount ${jail}/dev
|
|
done
|
|
;;
|
|
|
|
reload|force-reload)
|
|
for jail in ${BACKUP_PATH}/jails/*; do
|
|
kill -HUP \
|
|
$(chroot $jail cat /var/run/sshd.pid)
|
|
done
|
|
;;
|
|
|
|
restart)
|
|
for jail in ${BACKUP_PATH}/jails/*; do
|
|
kill $(chroot $jail cat /var/run/sshd.pid)
|
|
chroot $jail /usr/sbin/sshd > /dev/null
|
|
done
|
|
;;
|
|
esac
|
|
|
|
exit 0 |