cae32 (cae32) wrote,
cae32
cae32

Напейсал рестартилку для jail:


#!/bin/sh
#
#    Copyright (C) 2009 Sergey A.Eremenko (eremenko.s@gmail.com)
#
#    Written for Eugene Gladchenko's eazy and improving FreeBSD jail hosting
#       Please contact thru hosting@gladchenko.ru
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id: v1.2 $

# SYNOPSIS
# $ sudo crontab -u root -e
# add line
# */5 * * * * /usr/local/bin/ezjail_check_reboot
#
# DESCRIPTION
# Check for .need_ezjail_restart magic file in root directory of jail and
# restart this machine, remove magic file after restart (no check result)

if [ `id -u` != 0 ] ; then
        echo "You must be a root!"
        exit 2
fi

ezjail_prefix=/usr/local
ezjail_config_dir="${ezjail_prefix}/etc/ezjail/"
ezjail_restart_script=/usr/local/etc/rc.d/ezjail.sh
ezjail_magic_flag_for_restart=.need_ezjail_restart
ezjail_framework_log="/var/log/ezjail_framework.log"

. /etc/rc.subr

name=ezjail_check_reboot
rcvar=`set_rcvar`
load_rc_config ${name}

ezjail_enable=${ezjail_enable:-"NO"}

if ! checkyesno ezjail_enable; then
        return 0
fi

unset ezjail_list ezjail_pass ezjail_restart_files_for_rm

[ -d "${ezjail_config_dir}" ] && cd "${ezjail_config_dir}" && ezjail_list=`ls | xargs rcorder`

for ezjail in ${ezjail_list} ; do
        [ -f "${ezjail_config_dir}${ezjail}.norun" -o "${ezjail%.*}" != "${ezjail}" ] && continue

        [ ! -r "${ezjail_config_dir}${ezjail}" ] && continue

        . "${ezjail_config_dir}${ezjail}"

        eval ezjail_rootdir=\"\$jail_${ezjail}_rootdir\"

        [ ! -d "${ezjail_rootdir}" ] && continue

        [ ! -f "${ezjail_rootdir}/${ezjail_magic_flag_for_restart}" ] && continue

        ezjail_pass="${ezjail_pass:} ${ezjail}"
        ezjail_restart_files_for_rm="${ezjail_restart_files_for_rm} ${ezjail_rootdir}/${ezjail_magic_flag_for_restart}"
done

[ "${ezjail_pass}" ] && "${ezjail_restart_script}" restart ${ezjail_pass} | while read s ; do
        echo "`date +"%b %e %H:%M:%S %Z"` `hostname -s` `basename $0`[$$]" $s >> "${ezjail_framework_log}"
done

[ "${ezjail_restart_files_for_rm}" ] && rm -f ${ezjail_restart_files_for_rm}



Как-то так...
Subscribe

  • Лицемерненько

    Зачёл историю про выселение народа из общаг на Зорге. Подрочности в блокноте, хочется, загляните. История супер! 1. Журналистов не пускать, чтобы,…

  • Новости, когда август

    В общаге РГУ/ЮФУ обнаружены крысы! Это из тележки. Ну что же, новость дня, Julio.

  • Правоверные католики

    В Ростове садовые товарищества взбунтовались против реформации Люди требуют не трогать созданный ими рай ======================= Так пишет Таймс. Уж…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments