[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ezjail] trigger ezjail-admin restart from within the jail(s)



Philipp Wuensche wrote:
> Stefan Grundmann wrote:
>> Hi,
>>
>> might be useful for someone here...
> 
> Nice, but using the jails configfile filename to build the jails rootdir
> path is not working! I made a patch, which extracts the rootdir from the
> jails configfile and uses the last part for argument to the daemon. This
> is a bit strange, because the daemon is the using this and the
> configured base to build the same path again.

Oops, and here is the patch. ;)

greetings,
cryx

diff --git a/ezjail_restartd/files/ezjail_restartd.in b/ezjail_restartd/files/ezjail_restartd.in
index e850f53..c990d8b 100644
--- a/ezjail_restartd/files/ezjail_restartd.in
+++ b/ezjail_restartd/files/ezjail_restartd.in
@@ -16,17 +16,25 @@ rcvar=ezjail_restartd_enable
 
 load_rc_config ${name}
 
-ezjail_cfgs="%%PREFIX%%/etc/ezjail"
+ezjail_cfgs="%%PREFIX%%/etc/ezjail/"
+ezjail_config="%%PREFIX%%/etc/ezjail.conf"
 required_dirs="${ezjail_cfgs}"
+required_files="${ezjail_config}"
 
 ezjail_restartd_find_jails() {
-    find -X ${ezjail_cfgs} -maxdepth 1 -type f \
-        -exec basename '{}' ';' 2>/dev/null | xargs
+    for jailcfg in `find -X ${ezjail_cfgs} -maxdepth 1 -type f | xargs`; do
+      . ${jailcfg}
+      jail_safename=${jailcfg##*/}
+      eval jail_rootdir=\"\$jail_${jail_safename}_rootdir\"
+      echo -n "${jail_rootdir##*/} "
+    done
 }
 
+. ${ezjail_config}
+
 : ${ezjail_restartd_enable:=NO}
 : ${ezjail_restartd_trigger:="var/reboot/trigger"} 
-: ${ezjail_restartd_base:="/usr/jails"}
+: ${ezjail_restartd_base:=$ezjail_jaildir}
 : ${ezjail_restartd_admin_cmd:="%%PREFIX%%/bin/ezjail-admin"}
 : ${ezjail_restartd_jails:=`ezjail_restartd_find_jails`}