diff options
author | Eirik Oeverby <ltning@anduin.net> | 2009-03-14 00:27:08 +0100 |
---|---|---|
committer | Eirik Oeverby <ltning@anduin.net> | 2009-03-14 00:27:08 +0100 |
commit | f9a5fbfa1079f9a8dcfdfe4ad1bd50c1317ec8ac (patch) | |
tree | 406f5d5a94b035ff18efbc398c562dd8924ce388 /config/jailctl/jailctl_list.inc | |
parent | 662b06322bd35b323b9f1fb528abaa4a424515d1 (diff) | |
download | pfsense-packages-f9a5fbfa1079f9a8dcfdfe4ad1bd50c1317ec8ac.tar.gz pfsense-packages-f9a5fbfa1079f9a8dcfdfe4ad1bd50c1317ec8ac.tar.bz2 pfsense-packages-f9a5fbfa1079f9a8dcfdfe4ad1bd50c1317ec8ac.zip |
Added pfJailctl and jail_template packages
See http://doc.pfsense.org/index.php/PfJailctl_package for details.
Diffstat (limited to 'config/jailctl/jailctl_list.inc')
-rw-r--r-- | config/jailctl/jailctl_list.inc | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/config/jailctl/jailctl_list.inc b/config/jailctl/jailctl_list.inc new file mode 100644 index 00000000..d1869bd6 --- /dev/null +++ b/config/jailctl/jailctl_list.inc @@ -0,0 +1,112 @@ +<?php +include('/usr/local/pkg/jailctl.inc'); + +$jconfig=$config['installedpackages']['pfjailctlsettings']['config'][0]; +$jails=$config['installedpackages']['pfjailctl']['config']; +is_array($jails) ? $num_jails=count($jails) : $num_jails=0; + + +if($num_jails) { + for ($i=0;$i<$num_jails;$i++) { + $jail=$jails[$i]; + $jstatus=jailctl_jailstatus($config, $jail); + $_path=$jstatus['jpath']; + $_name=$jail['jname']; + $_ip=$jail['jip']; + $_hostname=$jstatus['jhostname']; + $_dnsservers=$jconfig['jdnsservers']; + $_passwd=$jconfig['jpasswd']; + $_template=$jail['jtemplates']; + $mounts=$GLOBALS['jailctl_tmp']['mounts']; + $unionmounts=$GLOBALS['jailctl_tmp']['unionmounts']; + $mount_unionfs=$GLOBALS['jailctl_tmp']['mount_unionfs']; + $mount_nullfs=$GLOBALS['jailctl_tmp']['mount_nullfs']; + + if($_GET['jaction'] && $_GET['id']==$i) { + switch ($_GET['jaction']) { + case 'create': +# if($jstate!='New') break; + jailctl_create($config, $jail); + if($jconfig['debug']) { + echo("Create script:<br><pre>"); + echo(file_get_contents("/tmp/jcreate_".$_name)); + echo("</pre>"); + } else { + header('Location: /pkg.php?xml=jailctl.xml'); + } + flush(); + exit; + + case 'start': +# if($jstate!='Stopped') break; + exec('umount -f '.$_path.'/dev'); + if($_template) { + $jail['juse_unionfs']=='on' ? $mount=$mount_unionfs : $mount=$mount_nullfs ; + foreach($mounts as $mp) { + exec($mount.' '.$_template.'/'.$mp.' '.$_path.'/'.$mp, $_cmd); + } + foreach($unionmounts as $mp) { + exec($mount_unionfs.' '.$_template.'/'.$mp.' '.$_path.'/'.$mp, $_cmd); + } + } + + $cmd='jailctl start '.$_name; + exec($cmd, $_cmd); + if($jconfig['debug']) { + echo("<script>alert('".addcslashes(implode("\\n", $_cmd), "'")."'); this.location.replace('/pkg.php?xml=jailctl.xml');</script>"); + } else { + header('Location: /pkg.php?xml=jailctl.xml'); + } + flush(); + exit; + + case 'stop': +# if($jstate!='Running') break; + $cmd='jailctl stop '.$_name; + exec($cmd, $_cmd); + if($_template) { + foreach($mounts as $mp) { + exec('umount -f '.$_template.'/'.$mp.' '.$_path.'/'.$mp, $_cmd); + } + foreach($unionmounts as $mp) { + exec('umount -f '.$_template.'/'.$mp.' '.$_path.'/'.$mp, $_cmd); + } + } + exec('umount -f '.$_path.'/dev'); + if($jconfig['debug']) { + echo("<script>alert('".addcslashes(implode("\\n", $_cmd), "'")."'); this.location.replace('/pkg.php?xml=jailctl.xml');</script>"); + } else { + header('Location: /pkg.php?xml=jailctl.xml'); + } + flush(); + exit; + } + } + + $config['installedpackages']['pfjailctl']['config'][$i]['jstate']=$jstatus['jstate']; + $config['installedpackages']['pfjailctl']['config'][$i]['jpath']=$jstatus['jpath']; + $config['installedpackages']['pfjailctl']['config'][$i]['jifdesc']= + $jstatus['jifdesc']." (".$jstatus['jrealif'].")"; + + $jactions=Array(); + switch ($jstatus['jstate']) { + case 'Building': + $jactions[]=""; + break; + case 'New': + $jactions[]="<a href='/pkg.php?xml=jailctl.xml&jaction=create&id=".$i."'>Create</a>"; + break; + case 'Stopped': + $jactions[]="<a href='/pkg.php?xml=jailctl.xml&jaction=start&id=".$i."'>Start</a>"; + #$jactions[]="<a href='/pkg.php?xml=jailctl.xml&jaction=upgrade&id=".$i."'>Upgrade</a>"; + break; + case 'Running': + $jactions[]="<a href='/pkg.php?xml=jailctl.xml&jaction=stop&id=".$i."'>Stop</a>"; + break; + } + $config['installedpackages']['pfjailctl']['config'][$i]['jactions']=implode(' | ', $jactions); + } +} + + +?>
\ No newline at end of file |