aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Stefan Haischt <dsh@pfsense.org>2006-08-15 15:06:54 +0000
committerDaniel Stefan Haischt <dsh@pfsense.org>2006-08-15 15:06:54 +0000
commit94be140cc8597228b2b7e07fbb85027fd0993b92 (patch)
tree555036f49463238e5ef784cb4cbe4ed6d3edb397
parent255f3c2826af0a38fd463e27ad385e2e1e199f50 (diff)
downloadpfsense-packages-94be140cc8597228b2b7e07fbb85027fd0993b92.tar.gz
pfsense-packages-94be140cc8597228b2b7e07fbb85027fd0993b92.tar.bz2
pfsense-packages-94be140cc8597228b2b7e07fbb85027fd0993b92.zip
initial version of a FreeNAS package
-rw-r--r--packages/freenas/conf.default/config.xml179
-rw-r--r--packages/freenas/conf.kernel/pfSense.6.freenas433
-rw-r--r--packages/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch1386
-rw-r--r--packages/freenas/doc/README.txt46
-rw-r--r--packages/freenas/pkg/freenas.xml345
-rw-r--r--packages/freenas/pkg/freenas_disks.inc899
-rw-r--r--packages/freenas/pkg/freenas_functions.inc38
-rw-r--r--packages/freenas/pkg/freenas_guiconfig.inc104
-rw-r--r--packages/freenas/pkg/freenas_services.inc1600
-rw-r--r--packages/freenas/pkg/freenas_utils.inc675
-rw-r--r--packages/freenas/www/diag_ad_infos.php156
-rw-r--r--packages/freenas/www/diag_ataidle_infos.php145
-rw-r--r--packages/freenas/www/diag_disk_infos.php141
-rw-r--r--packages/freenas/www/diag_fn_logs_daemon.php109
-rw-r--r--packages/freenas/www/diag_fn_logs_ftp.php109
-rw-r--r--packages/freenas/www/diag_fn_logs_rsyncd.php108
-rw-r--r--packages/freenas/www/diag_fn_logs_samba.php165
-rw-r--r--packages/freenas/www/diag_fn_logs_settings.php296
-rw-r--r--packages/freenas/www/diag_fn_logs_smartd.php109
-rw-r--r--packages/freenas/www/diag_fn_logs_sshd.php108
-rw-r--r--packages/freenas/www/diag_iscsi_infos.php133
-rw-r--r--packages/freenas/www/diag_mounts_infos.php128
-rw-r--r--packages/freenas/www/diag_part_infos.php134
-rw-r--r--packages/freenas/www/diag_raid_infos.php135
-rw-r--r--packages/freenas/www/diag_smart_infos.php133
-rw-r--r--packages/freenas/www/diag_space_infos.php128
-rw-r--r--packages/freenas/www/disks_manage.php203
-rw-r--r--packages/freenas/www/disks_manage_edit.php276
-rw-r--r--packages/freenas/www/disks_manage_init.php294
-rw-r--r--packages/freenas/www/disks_manage_iscsi.php199
-rw-r--r--packages/freenas/www/disks_mount.php208
-rw-r--r--packages/freenas/www/disks_mount_edit.php279
-rw-r--r--packages/freenas/www/disks_raid_gmirror.php223
-rw-r--r--packages/freenas/www/disks_raid_gmirror_edit.php267
-rw-r--r--packages/freenas/www/disks_raid_gmirror_infos.php132
-rw-r--r--packages/freenas/www/disks_raid_gmirror_init.php167
-rw-r--r--packages/freenas/www/disks_raid_gmirror_tools.php184
-rw-r--r--packages/freenas/www/disks_raid_gvinum.php222
-rw-r--r--packages/freenas/www/disks_raid_gvinum_edit.php266
-rw-r--r--packages/freenas/www/disks_raid_gvinum_infos.php132
-rw-r--r--packages/freenas/www/disks_raid_gvinum_init.php169
-rw-r--r--packages/freenas/www/disks_raid_gvinum_tools.php207
-rw-r--r--packages/freenas/www/services_afp.php190
-rw-r--r--packages/freenas/www/services_ftp.php347
-rw-r--r--packages/freenas/www/services_nfs.php219
-rw-r--r--packages/freenas/www/services_rsyncd.php263
-rw-r--r--packages/freenas/www/services_rsyncd_client.php565
-rw-r--r--packages/freenas/www/services_samba.php416
-rw-r--r--packages/freenas/www/status_disks.php119
49 files changed, 13489 insertions, 0 deletions
diff --git a/packages/freenas/conf.default/config.xml b/packages/freenas/conf.default/config.xml
new file mode 100644
index 00000000..74ed6186
--- /dev/null
+++ b/packages/freenas/conf.default/config.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0"?>
+<!-- FreeNAS default system configuration -->
+<freenas>
+ <version>1.1</version>
+ <lastchange/>
+ <system>
+ <hostname>freenas</hostname>
+ <domain>local</domain>
+ <dnsserver/>
+ <dnsallowoverride/>
+ <username>admin</username>
+ <password>$1$KLfrklGE$9mMLCl/tNeqZJzdCJw6Gb0</password>
+ <timezone>Etc/UTC</timezone>
+ <time-update-interval>300</time-update-interval>
+ <timeservers>pool.ntp.org</timeservers>
+ <webgui>
+ <protocol>http</protocol>
+ <!--
+ <port></port>
+ <certificate></certificate>
+ <private-key></private-key>
+ <noassigninterfaces/>
+ <expanddiags/>
+ <noantilockout></noantilockout>
+ -->
+ </webgui>
+ <!-- <disableconsolemenu/> -->
+ <!-- <disablefirmwarecheck/> -->
+ <!-- <shellcmd></shellcmd> -->
+ <!-- <earlyshellcmd></earlyshellcmd> -->
+ <!-- <harddiskstandby></harddiskstandby> -->
+ <!-- <polling/> -->
+ </system>
+ <interfaces>
+ <lan>
+ <if>sis0</if>
+ <ipaddr>192.168.1.250</ipaddr>
+ <subnet>24</subnet>
+ <media/>
+ <mediaopt/>
+ <!--
+ <wireless>
+ *see below (opt[n])*
+ </wireless>
+ -->
+ </lan>
+ <!--
+ <opt[n]>
+ <enable/>
+ <descr></descr>
+ <if></if>
+ <ipaddr></ipaddr>
+ <subnet></subnet>
+ <media></media>
+ <mediaopt></mediaopt>
+ <bridge>lan|wan|opt[n]</bridge>
+ <wireless>
+ <standard>11a|11b|11g</standard>
+ <mode>hostap *or* bss *or* ibss</mode>
+ <ssid></ssid>
+ <channel></channel>
+ <wep>
+ <enable/>
+ <key>
+ <txkey/>
+ <value></value>
+ </key>
+ </wep>
+ </wireless>
+ </opt[n]>
+ -->
+ </interfaces>
+ <!--
+ <vlans>
+ <vlan>
+ <tag></tag>
+ <if></if>
+ <descr></descr>
+ </vlan>
+ </vlans>
+ -->
+ <staticroutes>
+ <!--
+ <route>
+ <interface>lan|opt[n]|pptp</interface>
+ <network>xxx.xxx.xxx.xxx/xx</network>
+ <gateway>xxx.xxx.xxx.xxx</gateway>
+ <descr></descr>
+ </route>
+ -->
+ </staticroutes>
+ <disks>
+ <!--
+ <disk>
+ <device>xxx</device>
+ <type>IDE|SCSI</type>
+ <position>master|slave|number</position>
+ <desc>xxx</desc>
+ <status>ok|new|missing</status>
+ </disk>
+ -->
+
+ </disks>
+ <mounts>
+ <!--
+ <mount>
+ <device>xxx</device>
+ <fstype>msdosfs|ufs|ntfs|etc...</fstype>
+ <options>xxx</options>
+ </mount>
+ -->
+ </mounts>
+ <samba>
+ <!-- <enable/> -->
+ <netbiosname>freenas</netbiosname>
+ <workgroup>WORKGROUP</workgroup>
+ <serverdesc>FreeNAS Server</serverdesc>
+ <security>share</security>
+ <localmaster>yes</localmaster>
+ </samba>
+ <ftp>
+ <!-- <enable/> -->
+ <numberclients>5</numberclients>
+ <maxconperip>2</maxconperip>
+ <timeout>300</timeout>
+ <port>21</port>
+ <anonymous>yes</anonymous>
+ <localuser>yes</localuser>
+ <pasv_max_port>0</pasv_max_port>
+ <pasv_min_port>0</pasv_min_port>
+ </ftp>
+ <afp>
+ <!-- <enable/> -->
+ </afp>
+ <rsyncd>
+ <!-- <enable/> -->
+ <readonly>no</readonly>
+ <port>873</port>
+ </rsyncd>
+ <sshd>
+ <!-- <enable/> -->
+ <port>22</port>
+ </sshd>
+
+ <nfs>
+ <!-- <enable/> -->
+ </nfs>
+ <snmpd>
+ <!-- <enable/> -->
+ <syslocation/>
+ <syscontact/>
+ <rocommunity>public</rocommunity>
+ </snmpd>
+ <diag>
+ <ipv6nat>
+ <!-- <enable/> -->
+ <ipaddr/>
+ </ipv6nat>
+ <!-- <ipfstatentries></ipfstatentries> -->
+ </diag>
+ <bridge>
+ <!-- <filteringbridge/> -->
+ </bridge>
+ <syslog>
+ <!--
+ <reverse/>
+ <enable/>
+ <remoteserver>xxx.xxx.xxx.xxx</remoteserver>
+ <system/>
+ <nologdefaultblock/>
+ <resolve/>
+ -->
+ </syslog>
+ <access>
+ <userid>1002</userid>
+ <groupid>1002</groupid>
+ </access>
+
+</freenas> \ No newline at end of file
diff --git a/packages/freenas/conf.kernel/pfSense.6.freenas b/packages/freenas/conf.kernel/pfSense.6.freenas
new file mode 100644
index 00000000..aee11302
--- /dev/null
+++ b/packages/freenas/conf.kernel/pfSense.6.freenas
@@ -0,0 +1,433 @@
+#
+# GENERIC -- Generic kernel configuration file for FreeBSD/i386
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.429.2.7.2.2 2006/05/01 00:15:12 scottl Exp $
+
+machine i386
+cpu I486_CPU
+cpu I586_CPU
+cpu I686_CPU
+ident pfSense
+
+# To statically compile in device wiring instead of /boot/device.hints
+#hints "GENERIC.hints" # Default places to look for devices.
+
+makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
+
+#FREENAS ADD lines:
+options NO_SWAPPING
+options HZ=1000
+
+#options SCHED_ULE # ULE scheduler
+options SCHED_4BSD # 4BSD scheduler
+options PREEMPTION # Enable kernel thread preemption
+options INET # InterNETworking
+options INET6 # IPv6 communications protocols
+options FFS # Berkeley Fast Filesystem
+options SOFTUPDATES # Enable FFS soft updates support
+options UFS_ACL # Support for access control lists
+options UFS_DIRHASH # Improve performance on big directories
+options MD_ROOT # MD is a potential root device
+options NFSCLIENT # Network Filesystem Client
+options NFSSERVER # Network Filesystem Server
+options NFS_ROOT # NFS usable as /, requires NFSCLIENT
+options MSDOSFS # MSDOS Filesystem
+options MSDOSFS_LARGE # MSDOS Filesystem for FAT32 > 128GB
+options CD9660 # ISO 9660 Filesystem
+options PROCFS # Process filesystem (requires PSEUDOFS)
+options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_GPT # GUID Partition Tables.
+options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
+options COMPAT_FREEBSD4 # Compatible with FreeBSD4
+options COMPAT_FREEBSD5 # Compatible with FreeBSD5
+options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
+options KTRACE # ktrace(1) support
+options SYSVSHM # SYSV-style shared memory
+options SYSVMSG # SYSV-style message queues
+options SYSVSEM # SYSV-style semaphores
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+options KBD_INSTALL_CDEV # install a CDEV entry in /dev
+options AHC_REG_PRETTY_PRINT # Print register bitfields in debug
+ # output. Adds ~128k to driver.
+options AHD_REG_PRETTY_PRINT # Print register bitfields in debug
+ # output. Adds ~215k to driver.
+options ADAPTIVE_GIANT # Giant mutex is adaptive.
+
+#FreeNAS include ACPI in the kernel:
+device acpi # acpi -- Advanced Configuration and Power Management support
+
+device apic # I/O APIC
+
+# Bus support.
+device eisa
+device pci
+
+# Floppy drives
+device fdc
+
+# ATA and ATAPI devices
+device ata
+device atadisk # ATA disk drives
+device ataraid # ATA RAID drives
+device atapicd # ATAPI CDROM drives
+device atapifd # ATAPI floppy drives
+#device atapifd # ATAPI floppy drives
+device atapist # ATAPI tape drives
+options ATA_STATIC_ID # Static device numbering
+
+# SCSI Controllers
+device ahb # EISA AHA1742 family
+device ahc # AHA2940 and onboard AIC7xxx devices
+device ahd # AHA39320/29320 and onboard AIC79xx devices
+device amd # AMD 53C974 (Tekram DC-390(T))
+device isp # Qlogic family
+device ispfw # Firmware for QLogic HBAs- normally a module
+device mpt # LSI-Logic MPT-Fusion
+#device ncr # NCR/Symbios Logic
+device sym # NCR/Symbios Logic (newer chipsets + those of `ncr')
+device trm # Tekram DC395U/UW/F DC315U adapters
+
+device adv # Advansys SCSI adapters
+device adw # Advansys wide SCSI adapters
+device aha # Adaptec 154x SCSI adapters
+device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60.
+device bt # Buslogic/Mylex MultiMaster SCSI adapters
+
+device ncv # NCR 53C500
+device nsp # Workbit Ninja SCSI-3
+device stg # TMC 18C30/18C50
+
+#FREENAS ADD SPECIAL DRIVERSAdding special IOI-A100U2W drivers:
+device ihb # IOI-A100U2W drivers
+
+# SCSI peripherals
+device scbus # SCSI bus (required for SCSI)
+device ch # SCSI media changers
+device da # Direct Access (disks)
+device sa # Sequential Access (tape etc)
+device cd # CD
+device pass # Passthrough device (direct SCSI access)
+device ses # SCSI Environmental Services (and SAF-TE)
+
+# RAID controllers interfaced to the SCSI subsystem
+device amr # AMI MegaRAID
+device arcmsr # Areca SATA II RAID
+device asr # DPT SmartRAID V, VI and Adaptec SCSI RAID
+device ciss # Compaq Smart RAID 5*
+device dpt # DPT Smartcache III, IV - See NOTES for options
+device hptmv # Highpoint RocketRAID 182x
+device rr232x # Highpoint RocketRAID 232x
+device iir # Intel Integrated RAID
+device ips # IBM (Adaptec) ServeRAID
+device mly # Mylex AcceleRAID/eXtremeRAID
+device twa # 3ware 9000 series PATA/SATA RAID
+
+# RAID controllers
+device aac # Adaptec FSA RAID
+device aacp # SCSI passthrough for aac (requires CAM)
+device ida # Compaq Smart RAID
+device mfi # LSI MegaRAID SAS
+device mlx # Mylex DAC960 family
+device pst # Promise Supertrak SX6000
+device twe # 3ware ATA RAID
+
+# atkbdc0 controls both the keyboard and the PS/2 mouse
+device atkbdc # AT keyboard controller
+device atkbd # AT keyboard
+device psm # PS/2 mouse
+
+device kbdmux # keyboard multiplexer
+
+device vga # VGA video card driver
+
+device splash # Splash screen and screen saver support
+
+# syscons is the default console driver, resembling an SCO console
+device sc
+
+# Enable this for the pcvt (VT220 compatible) console driver
+#device vt
+#options XSERVER # support for X server on a vt console
+#options FAT_CURSOR # start with block cursor
+
+device agp # support several AGP chipsets
+
+# Power management support (see NOTES for more options)
+#device apm
+# Add suspend/resume support for the i8254.
+device pmtimer
+
+# PCCARD (PCMCIA) support
+# PCMCIA and cardbus bridge support
+device cbb # cardbus (yenta) bridge
+device pccard # PC Card (16-bit) bus
+device cardbus # CardBus (32-bit) bus
+
+# Serial (COM) ports
+device sio # 8250, 16[45]50 based serial ports
+
+# Parallel port
+device ppc
+device ppbus # Parallel port bus (required)
+device lpt # Printer
+device ppi # Parallel port interface device
+#device vpo # Requires scbus and da
+
+# If you've got a "dumb" serial or parallel PCI card that is
+# supported by the puc(4) glue driver, uncomment the following
+# line to enable it (connects to the sio and/or ppc drivers):
+#device puc
+
+# PCI Ethernet NICs.
+device de # DEC/Intel DC21x4x (``Tulip'')
+device em # Intel PRO/1000 adapter Gigabit Ethernet Card
+device ixgb # Intel PRO/10GbE Ethernet Card
+device txp # 3Com 3cR990 (``Typhoon'')
+device vx # 3Com 3c590, 3c595 (``Vortex'')
+
+# PCI Ethernet NICs that use the common MII bus controller code.
+# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
+device miibus # MII bus support
+device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet
+device bfe # Broadcom BCM440x 10/100 Ethernet
+device bge # Broadcom BCM570xx Gigabit Ethernet
+device dc # DEC/Intel 21143 and various workalikes
+device fxp # Intel EtherExpress PRO/100B (82557, 82558)
+device lge # Level 1 LXT1001 gigabit Ethernet
+device nge # NatSemi DP83820 gigabit Ethernet
+device nve # nVidia nForce MCP on-board Ethernet Networking
+device pcn # AMD Am79C97x PCI 10/100(precedence over 'lnc')
+device re # RealTek 8139C+/8169/8169S/8110S
+device rl # RealTek 8129/8139
+device sf # Adaptec AIC-6915 (``Starfire'')
+device sis # Silicon Integrated Systems SiS 900/SiS 7016
+device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet
+device ste # Sundance ST201 (D-Link DFE-550TX)
+device ti # Alteon Networks Tigon I/II gigabit Ethernet
+device tl # Texas Instruments ThunderLAN
+device tx # SMC EtherPower II (83c170 ``EPIC'')
+device vge # VIA VT612x gigabit Ethernet
+device vr # VIA Rhine, Rhine II
+device wb # Winbond W89C840F
+device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
+
+# ISA Ethernet NICs. pccard NICs included.
+device cs # Crystal Semiconductor CS89x0 NIC
+# 'device ed' requires 'device miibus'
+device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards
+device ex # Intel EtherExpress Pro/10 and Pro/10+
+device ep # Etherlink III based cards
+device fe # Fujitsu MB8696x based cards
+device ie # EtherExpress 8/16, 3C507, StarLAN 10 etc.
+device le # NE2100, NE32-VL Lance Ethernet cards
+device sn # SMC's 9000 series of Ethernet chips
+device xe # Xircom pccard Ethernet
+
+# Wireless NIC cards
+device wlan # 802.11 support
+device an # Aironet 4500/4800 802.11 wireless NICs.
+device awi # BayStack 660 and others
+device ral # Ralink Technology RT2500 wireless NICs.
+device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs.
+#device wl # Older non 802.11 Wavelan wireless NIC.
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device sl # Kernel SLIP
+device ppp # Kernel PPP
+device tun # Packet tunnel.
+device pty # Pseudo-ttys (telnet etc)
+device md # Memory "disks"
+device gif # IPv6 and IPv4 tunneling
+device faith # IPv6-to-IPv4 relaying (translation)
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
+
+# USB support
+device uhci # UHCI PCI->USB interface
+device ohci # OHCI PCI->USB interface
+device ehci # EHCI PCI->USB interface (USB 2.0)
+device usb # USB Bus (required)
+#device udbp # USB Double Bulk Pipe devices
+device ugen # Generic
+device uhid # "Human Interface Devices"
+device ukbd # Keyboard
+device ulpt # Printer
+device umass # Disks/Mass storage - Requires scbus and da
+device ums # Mouse
+device ural # Ralink Technology RT2500USB wireless NICs
+device urio # Diamond Rio 500 MP3 player
+device uscanner # Scanners
+# USB Ethernet, requires miibus
+device aue # ADMtek USB Ethernet
+device axe # ASIX Electronics USB Ethernet
+device cdce # Generic USB over Ethernet
+device cue # CATC USB Ethernet
+device kue # Kawasaki LSI USB Ethernet
+device rue # RealTek RTL8150 USB Ethernet
+
+# FireWire support
+device firewire # FireWire bus code
+device sbp # SCSI over FireWire (Requires scbus and da)
+device fwe # Ethernet over FireWire (non-standard!)
+device fwip
+
+# pfSense addons
+
+# Wireless NIC cards
+device wlan # 802.11 support
+device wlan_wep
+device wlan_ccmp
+device wlan_tkip
+device wlan_xauth
+device wlan_acl
+device ath
+device ath_rate_sample
+device ath_hal
+device an # Aironet 4500/4800 802.11 wireless NICs.
+device awi # BayStack 660 and others
+device iwi # Intel PRO/Wireless 2200BG
+device ipw
+device ral # Ralink Technology RT2500 wireless NICs.
+device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs.
+device wl # Older non 802.11 Wavelan wireless NIC.
+
+options COMPAT_FREEBSD5
+
+options UNIONFS # Union filesystem
+
+device bktr
+
+#options IPFIREWALL
+#options DUMMYNET
+#options IPDIVERT
+options IPFIREWALL_DEFAULT_TO_ACCEPT
+options IPFIREWALL_FORWARD
+options IPFIREWALL_VERBOSE
+options IPFIREWALL_VERBOSE_LIMIT
+
+device carp
+device pf
+device pflog
+device pfsync
+device vlan
+device gre
+
+options IPSTEALTH
+options TCP_DROP_SYNFIN #drop TCP packets with SYN+FIN
+options GEOM_UZIP
+options GEOM_LABEL
+
+options INCLUDE_CONFIG_FILE
+
+#options BRIDGE
+options NETGRAPH #netgraph(4) system
+options NETGRAPH_ASYNC
+options NETGRAPH_BPF
+options NETGRAPH_BRIDGE
+options NETGRAPH_CISCO
+options NETGRAPH_ECHO
+options NETGRAPH_ETHER
+options NETGRAPH_FRAME_RELAY
+options NETGRAPH_HOLE
+options NETGRAPH_IFACE
+options NETGRAPH_KSOCKET
+
+options NETGRAPH_LMI
+options NETGRAPH_MPPC_ENCRYPTION
+options NETGRAPH_ONE2MANY
+options NETGRAPH_PPP
+options NETGRAPH_PPPOE
+options NETGRAPH_PPTPGRE
+options NETGRAPH_RFC1490
+options NETGRAPH_SOCKET
+options NETGRAPH_TEE
+options NETGRAPH_TTY
+options NETGRAPH_UI
+options NETGRAPH_VJC
+
+device ubsa
+device ucom
+
+options FAST_IPSEC
+#options IPSEC_NAT_T
+device enc
+
+device crypto # core crypto support
+device cryptodev # /dev/crypto for access to h/w
+device rndtest # FIPS 140-2 entropy tester
+device hifn # Hifn 7951, 7781, etc.
+options HIFN_DEBUG # enable debugging support: hw.hifn.debug
+options HIFN_RNDTEST # enable rndtest support
+device ubsec # Broadcom 5501, 5601, 58xx
+
+options ALTQ
+options ALTQ_CBQ
+options ALTQ_RED
+options ALTQ_RIO
+options ALTQ_HFSC
+options ALTQ_PRIQ
+options ALTQ_NOPCC # Required for SMP builds !!
+
+
+# Bridging
+device if_bridge
+
+options MSGMNB=8192 # max # of bytes in a queue
+options MSGMNI=40 # number of message queue identifiers
+options MSGSEG=512 # number of message segments per queue
+options MSGSSZ=32 # size of a message segment
+options MSGTQL=2048 # max messages in system
+
+device tap
+device hme
+
+# Needed for FreeSBIE 2
+options NULLFS
+
+# Kbdmux
+device kbdmux
+
+device speaker
+
+options DEVICE_POLLING
+
+options ZERO_COPY_SOCKETS
+
+#device natpt
+
+device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet
+
+options TCP_SIGNATURE
+
+# To make an SMP kernel, the next two lines are needed
+options SMP # Symmetric MultiProcessor Kernel
+device apic # I/O APIC
+
+# Allow gmirror to function
+options GEOM_MIRROR
+options GEOM_MBR
+
+options PREEMPTION
+
+
diff --git a/packages/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch b/packages/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch
new file mode 100644
index 00000000..74ee8795
--- /dev/null
+++ b/packages/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch
@@ -0,0 +1,1386 @@
+? etc/afpd/afp_avahi.c
+? etc/afpd/afp_avahi.c.org
+? etc/afpd/afp_avahi.h
+? etc/afpd/afp_avahi.h.org
+? etc/afpd/afp_bonjour.c
+? etc/afpd/afp_bonjour.c.org
+? etc/afpd/afp_bonjour.h
+? etc/afpd/afp_bonjour.h.org
+? etc/afpd/afp_howl.c
+? etc/afpd/afp_howl.c.org
+? etc/afpd/afp_howl.h
+? etc/afpd/afp_howl.h.org
+? etc/afpd/afp_zeroconf.c
+? etc/afpd/afp_zeroconf.c.org
+? etc/afpd/afp_zeroconf.h
+? etc/afpd/afp_zeroconf.h.org
+? macros/zeroconf.m4
+? macros/zeroconf.m4.org
+Index: configure.in
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/configure.in,v
+retrieving revision 1.203
+diff -u -r1.203 configure.in
+--- configure.in 28 Apr 2005 20:49:17 -0000 1.203
++++ configure.in 5 May 2006 10:46:30 -0000
+@@ -398,6 +398,9 @@
+ dnl Check for optional server location protocol support (used by MacOS X)
+ NETATALK_SRVLOC
+
++dnl Check for optional Zeroconf support
++NETATALK_ZEROCONF
++
+ dnl Check for PAM libs
+ netatalk_cv_use_pam=no
+ AC_PATH_PAM([
+Index: config/afpd.conf.tmpl
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/config/afpd.conf.tmpl,v
+retrieving revision 1.16
+diff -u -r1.16 afpd.conf.tmpl
+--- config/afpd.conf.tmpl 28 Apr 2005 20:49:20 -0000 1.16
++++ config/afpd.conf.tmpl 5 May 2006 10:46:31 -0000
+@@ -51,6 +51,8 @@
+ # empty string.
+ # -noslp Don't register this server with the Service
+ # Location Protocol.
++# -nozeroconf Don't register this server with the Multicats
++# DNS Protocol.
+ #
+ #
+ # Authentication Methods:
+Index: contrib/a2boot/Makefile.am
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/contrib/a2boot/Makefile.am,v
+retrieving revision 1.5
+diff -u -r1.5 Makefile.am
+--- contrib/a2boot/Makefile.am 28 Apr 2005 20:49:21 -0000 1.5
++++ contrib/a2boot/Makefile.am 5 May 2006 10:46:32 -0000
+@@ -10,7 +10,7 @@
+ EXTRA_DIST = COPYRIGHT VERSION
+
+ CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/sys \
+- @CFLAGS@ @SLP_CFLAGS@ \
++ @CFLAGS@ @SLP_CFLAGS@ @ZEROCONF_CFLAGS@ \
+ -D_PATH_A_GS_BLOCKS=\"$(PKGCONFDIR)/a2boot/ProDOS16\ Boot\ Blocks\" \
+ -D_PATH_A_2E_BLOCKS=\"$(PKGCONFDIR)/a2boot/Apple\ :2f:2fe\ Boot\ Blocks\" \
+ -D_PATH_P16_IMAGE=\"$(PKGCONFDIR)/a2boot/ProDOS16\ Image\"
+Index: etc/afpd/Makefile.am
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/etc/afpd/Makefile.am,v
+retrieving revision 1.38
+diff -u -r1.38 Makefile.am
+--- etc/afpd/Makefile.am 30 Apr 2005 21:33:41 -0000 1.38
++++ etc/afpd/Makefile.am 5 May 2006 10:46:33 -0000
+@@ -8,19 +8,21 @@
+ file.c enumerate.c desktop.c filedir.c fork.c appl.c gettok.c \
+ mangle.c status.c afp_options.c afp_asp.c afp_dsi.c messages.c \
+ afp_config.c nfsquota.c quota.c uam.c afs.c uid.c afp_util.c \
+- catsearch.c afprun.c
++ catsearch.c afprun.c \
++ afp_zeroconf.c afp_avahi.c afp_bonjour.c afp_howl.c
+
+ afpd_LDADD = $(top_builddir)/libatalk/cnid/libcnid.la $(top_builddir)/libatalk/libatalk.la
+ afpd_LDFLAGS = -export-dynamic
+
+ noinst_HEADERS = auth.h afp_config.h desktop.h directory.h file.h \
+ filedir.h fork.h globals.h icon.h mangle.h misc.h status.h switch.h \
+- uam_auth.h uid.h unix.h volume.h
++ uam_auth.h uid.h unix.h volume.h \
++ afp_zeroconf.h afp_avahi.h afp_bonjour.h afp_howl.h
+
+-LIBS = @LIBS@ @PAM_LIBS@ @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@
++LIBS = @LIBS@ @PAM_LIBS@ @QUOTA_LIBS@ @SLP_LIBS@ @ZEROCONF_LIBS@ @WRAP_LIBS@
+
+ CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/sys \
+- @CFLAGS@ @SLP_CFLAGS@ \
++ @CFLAGS@ @SLP_CFLAGS@ @ZEROCONF_CFLAGS@ \
+ -D_PATH_AFPDDEFVOL=\"$(pkgconfdir)/AppleVolumes.default\" \
+ -D_PATH_AFPDSYSVOL=\"$(pkgconfdir)/AppleVolumes.system\" \
+ -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \
+Index: etc/afpd/afp_config.c
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/etc/afpd/afp_config.c,v
+retrieving revision 1.23
+diff -u -r1.23 afp_config.c
+--- etc/afpd/afp_config.c 28 Apr 2005 20:49:39 -0000 1.23
++++ etc/afpd/afp_config.c 5 May 2006 10:46:35 -0000
+@@ -50,6 +50,9 @@
+ #ifdef USE_SRVLOC
+ #include <slp.h>
+ #endif /* USE_SRVLOC */
++#ifdef USE_ZEROCONF
++#include "afp_zeroconf.h"
++#endif /* USE_ZEROCONF */
+
+ #include "globals.h"
+ #include "afp_config.h"
+@@ -154,9 +157,9 @@
+ }
+ #endif /* USE_SRVLOC */
+
+-#ifdef USE_SRVLOC
+ static void dsi_cleanup(const AFPConfig *config)
+ {
++#ifdef USE_SRVLOC
+ SLPError err;
+ SLPError callbackerr;
+ SLPHandle hslp;
+@@ -189,8 +192,16 @@
+ srvloc_dereg_err:
+ dsi->srvloc_url[0] = '\0';
+ SLPClose(hslp);
+-}
++#elif defined (USE_ZEROCONF)
++ DSI *dsi = (DSI *)config->obj.handle;
++
++ /* Do nothing if we didn't register. */
++ if (!dsi || dsi->zeroconf_registered == 0)
++ return;
++
++ zeroconf_deregister();
+ #endif /* USE_SRVLOC */
++}
+
+ #ifndef NO_DDP
+ static void asp_cleanup(const AFPConfig *config)
+@@ -355,6 +366,10 @@
+ struct servent *afpovertcp;
+ int afp_port = 548;
+ char *srvloc_hostname, *hostname;
++#elif defined (USE_ZEROCONF)
++ struct servent *afpovertcp;
++ int afp_port = 548;
++ char *hostname = NULL;
+ #endif /* USE_SRVLOC */
+
+ if ((config = (AFPConfig *) calloc(1, sizeof(AFPConfig))) == NULL) {
+@@ -449,6 +464,36 @@
+ }
+ #endif /* USE_SRVLOC */
+
++#ifdef USE_ZEROCONF
++ dsi->zeroconf_registered = 0; /* Mark that we haven't registered. */
++
++ if (!(options->flags & OPTION_NOZEROCONF)) {
++ /* XXX We don't want to tack on the port number if we don't have to.
++ * Why?
++ * Well, this seems to break MacOS < 10. If the user _really_ wants to
++ * use a non-default port, they can, but be aware, this server might
++ * not show up int the Network Browser.
++ */
++ afpovertcp = getservbyname("afpovertcp", "tcp");
++ if (afpovertcp != NULL) {
++ afp_port = ntohs(afpovertcp->s_port);
++ }
++
++ /* If specified use the FQDN to register with srvloc, otherwise use IP. */
++ p = NULL;
++ if (options->fqdn) {
++ hostname = options->fqdn;
++ p = strchr(hostname, ':');
++ }
++ else
++ hostname = inet_ntoa(dsi->server.sin_addr);
++
++ if (!(options->flags & OPTION_NOSLP)) {
++ zeroconf_register(afp_port, hostname);
++ dsi->zeroconf_registered = 1; /* Mark that we have registered. */
++ }
++ }
++#endif /* USE_ZEROCONF */
+
+ config->fd = dsi->serversock;
+ config->obj.handle = dsi;
+@@ -469,6 +514,9 @@
+ #ifdef USE_SRVLOC
+ config->server_cleanup = dsi_cleanup;
+ #endif
++#ifdef USE_ZEROCONF
++ config->server_cleanup = dsi_cleanup;
++#endif
+ return config;
+ }
+
+Index: etc/afpd/afp_options.c
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/etc/afpd/afp_options.c,v
+retrieving revision 1.35
+diff -u -r1.35 afp_options.c
+--- etc/afpd/afp_options.c 28 Apr 2005 20:49:39 -0000 1.35
++++ etc/afpd/afp_options.c 5 May 2006 10:46:39 -0000
+@@ -202,10 +202,15 @@
+ /* parse toggles */
+ if (strstr(buf, " -nodebug"))
+ options->flags &= ~OPTION_DEBUG;
++
+ #ifdef USE_SRVLOC
+ if (strstr(buf, " -noslp"))
+ options->flags |= OPTION_NOSLP;
+ #endif /* USE_SRVLOC */
++#ifdef USE_ZEROCONF
++ if (strstr(buf, " -nozeroconf"))
++ options->flags |= OPTION_NOZEROCONF;
++#endif
+
+ if (strstr(buf, " -nouservolfirst"))
+ options->flags &= ~OPTION_USERVOLFIRST;
+@@ -578,6 +583,12 @@
+ puts( "No" );
+ #endif
+
++#ifdef USE_ZEROCONF
++ puts( "Yes" );
++#else
++ puts( "No" );
++#endif
++
+ printf( " TCP wrappers support:\t" );
+ #ifdef TCPWRAP
+ puts( "Yes" );
+Index: etc/afpd/globals.h
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/etc/afpd/globals.h,v
+retrieving revision 1.21
+diff -u -r1.21 globals.h
+--- etc/afpd/globals.h 28 Apr 2005 20:49:43 -0000 1.21
++++ etc/afpd/globals.h 5 May 2006 10:46:39 -0000
+@@ -40,6 +40,7 @@
+ #define OPTION_CUSTOMICON (1 << 4)
+ #define OPTION_NOSLP (1 << 5)
+ #define OPTION_ANNOUNCESSH (1 << 6)
++#define OPTION_NOZEROCONF (1 << 7)
+
+ #ifdef FORCE_UIDGID
+ /* set up a structure for this */
+Index: include/atalk/dsi.h
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/include/atalk/dsi.h,v
+retrieving revision 1.6
+diff -u -r1.6 dsi.h
+--- include/atalk/dsi.h 3 May 2005 14:55:12 -0000 1.6
++++ include/atalk/dsi.h 5 May 2006 10:46:41 -0000
+@@ -85,6 +85,10 @@
+ char srvloc_url[512];
+ #endif
+
++#ifdef USE_ZEROCONF
++ int zeroconf_registered;
++#endif
++
+ /* buffer for OSX deadlock */
+ int noblocking;
+ char *buffer;
+Index: macros/summary.m4
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/macros/summary.m4,v
+retrieving revision 1.2
+diff -u -r1.2 summary.m4
+--- macros/summary.m4 28 Apr 2005 20:50:05 -0000 1.2
++++ macros/summary.m4 5 May 2006 10:46:46 -0000
+@@ -44,6 +44,7 @@
+ AC_MSG_RESULT([ Options:])
+ AC_MSG_RESULT([ CUPS support: $netatalk_cv_use_cups])
+ AC_MSG_RESULT([ SLP support: $netatalk_cv_srvloc])
++ AC_MSG_RESULT([ Zeroconf support: $netatalk_cv_zeroconf])
+ AC_MSG_RESULT([ tcp wrapper support: $netatalk_cv_tcpwrap])
+ dnl if test x"$netatalk_cv_linux_sendfile" != x; then
+ dnl AC_MSG_RESULT([ Linux sendfile support: $netatalk_cv_linux_sendfile])
+Index: man/man5/afpd.conf.5.tmpl
+===================================================================
+RCS file: /cvsroot/netatalk/netatalk/man/man5/afpd.conf.5.tmpl,v
+retrieving revision 1.4
+diff -u -r1.4 afpd.conf.5.tmpl
+--- man/man5/afpd.conf.5.tmpl 28 Apr 2005 20:50:06 -0000 1.4
++++ man/man5/afpd.conf.5.tmpl 5 May 2006 10:46:48 -0000
+@@ -210,6 +210,9 @@
+ Protocol (if SLP support was compiled in). This is useful if you are
+ running multiple servers and want one to be hidden, perhaps because
+ it is advertised elsewhere, ie. by a SLP Directory Agent.
++\-noslp
++Do not register this server using the Multicast DNS
++Protocol (if Zeroconf support was compiled in).
+ .SH "MISCELLANEOUS OPTIONS"
+ .TP
+ \-admingroup \fI[group]\fR
+--- etc/afpd/afp_avahi.c.org 2006-04-21 10:29:22.000000000 +0200
++++ etc/afpd/afp_avahi.c 2006-04-22 08:34:34.000000000 +0200
+@@ -0,0 +1,500 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Avahi based Zeroconf support
++ * Docs: http://avahi.org/download/doxygen/
++ *
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#ifdef HAVE_AVAHI
++
++#include "afp_avahi.h"
++
++static void publish_reply(AvahiEntryGroup *g,
++ AvahiEntryGroupState state,
++ void *userdata);
++
++/*
++ * This function tries to register the AFP DNS
++ * SRV service type.
++ */
++static void register_stuff(struct context *ctx) {
++ char r[128];
++ int ret;
++
++ assert(ctx->client);
++
++ if (!ctx->group) {
++
++ if (!(ctx->group = avahi_entry_group_new(ctx->client,
++ publish_reply,
++ ctx))) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to create entry group: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ goto fail;
++ }
++
++ }
++
++ LOG(log_info, logtype_afpd, "Adding service '%s'\n", ctx->name);
++
++ if (avahi_entry_group_is_empty(ctx->group)) {
++ /* Register our service */
++
++ if (avahi_entry_group_add_service(ctx->group,
++ AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ 0,
++ ctx->name,
++ AFP_DNS_SERVICE_TYPE,
++ NULL,
++ NULL,
++ ctx->port,
++ NULL) < 0) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to add service: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ goto fail;
++ }
++
++ if (avahi_entry_group_commit(ctx->group) < 0) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to commit entry group: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ goto fail;
++ }
++ }
++
++ return;
++
++ fail:
++ avahi_client_free (ctx->client);
++#ifndef HAVE_AVAHI_THREADED_POLL
++ avahi_simple_poll_quit(ctx->simple_poll);
++#else
++ avahi_threaded_poll_quit(ctx->threaded_poll);
++#endif
++}
++
++/* Called when publishing of service data completes */
++static void publish_reply(AvahiEntryGroup *g,
++ AvahiEntryGroupState state,
++ AVAHI_GCC_UNUSED void *userdata)
++{
++ struct context *ctx = userdata;
++
++ assert(g == ctx->group);
++
++ switch (state) {
++
++ case AVAHI_ENTRY_GROUP_ESTABLISHED :
++ /* The entry group has been established successfully */
++ break;
++
++ case AVAHI_ENTRY_GROUP_COLLISION: {
++ char *n;
++
++ /* Pick a new name for our service */
++
++ n = avahi_alternative_service_name(ctx->name);
++ assert(n);
++
++ avahi_free(ctx->name);
++ ctx->name = n;
++
++ register_stuff(ctx);
++ break;
++ }
++
++ case AVAHI_ENTRY_GROUP_FAILURE: {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to register service: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ avahi_client_free (avahi_entry_group_get_client(g));
++#ifndef HAVE_AVAHI_THREADED_POLL
++ avahi_simple_poll_quit(ctx->simple_poll);
++#else
++ avahi_threaded_poll_quit(ctx->threaded_poll);
++#endif
++ break;
++ }
++
++ case AVAHI_ENTRY_GROUP_UNCOMMITED:
++ case AVAHI_ENTRY_GROUP_REGISTERING:
++ ;
++ }
++}
++
++static void client_callback(AvahiClient *client,
++ AvahiClientState state,
++ void *userdata)
++{
++ struct context *ctx = userdata;
++
++ ctx->client = client;
++
++ switch (state) {
++
++ case AVAHI_CLIENT_S_RUNNING:
++
++ /* The server has startup successfully and registered its host
++ * name on the network, so it's time to create our services */
++ if (!ctx->group)
++ register_stuff(ctx);
++ break;
++
++ case AVAHI_CLIENT_S_COLLISION:
++
++ if (ctx->group)
++ avahi_entry_group_reset(ctx->group);
++ break;
++
++ case AVAHI_CLIENT_FAILURE: {
++
++ if (avahi_client_errno(client) == AVAHI_ERR_DISCONNECTED) {
++ int error;
++
++ avahi_client_free(ctx->client);
++ ctx->client = NULL;
++ ctx->group = NULL;
++
++ /* Reconnect to the server */
++
++#ifndef HAVE_AVAHI_THREADED_POLL
++ if (!(ctx->client = avahi_client_new(avahi_simple_poll_get(ctx->simple_poll),
++#else
++ if (!(ctx->client = avahi_client_new(avahi_threaded_poll_get(ctx->threaded_poll),
++#endif
++ AVAHI_CLIENT_NO_FAIL,
++ client_callback,
++ ctx,
++ &error))) {
++
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to contact server: %s\n",
++ avahi_strerror(error));
++
++ avahi_client_free (ctx->client);
++#ifndef HAVE_AVAHI_THREADED_POLL
++ avahi_simple_poll_quit(ctx->simple_poll);
++#else
++ avahi_threaded_poll_quit(ctx->threaded_poll);
++#endif
++ }
++
++ } else {
++ LOG(log_error,
++ logtype_afpd,
++ "Client failure: %s\n",
++ avahi_strerror(avahi_client_errno(client)));
++
++ avahi_client_free (ctx->client);
++#ifndef HAVE_AVAHI_THREADED_POLL
++ avahi_simple_poll_quit(ctx->simple_poll);
++#else
++ avahi_threaded_poll_quit(ctx->threaded_poll);
++#endif
++ }
++
++ break;
++ }
++
++ case AVAHI_CLIENT_S_REGISTERING:
++ case AVAHI_CLIENT_CONNECTING:
++ ;
++ }
++}
++
++static void* thread(void *userdata) {
++#ifndef HAVE_AVAHI_THREADED_POLL
++ struct context *ctx = userdata;
++ sigset_t mask;
++ int r;
++
++ /* Make sure that signals are delivered to the main thread */
++ sigfillset(&mask);
++ pthread_sigmask(SIG_BLOCK, &mask, NULL);
++
++ pthread_mutex_lock(&ctx->mutex);
++
++ /* Run the main loop */
++ LOG(log_info, logtype_afpd, "Starting avahi loop...");
++ r = avahi_simple_poll_loop(ctx->simple_poll);
++
++ /* Cleanup some stuff */
++ if (ctx->client)
++ avahi_client_free(ctx->client);
++ ctx->client = NULL;
++ ctx->group = NULL;
++
++ pthread_mutex_unlock(&ctx->mutex);
++#endif
++ return NULL;
++}
++
++static int poll_func(struct pollfd *ufds,
++ unsigned int nfds,
++ int timeout,
++ void *userdata) {
++#ifndef HAVE_AVAHI_THREADED_POLL
++ pthread_mutex_t *mutex = userdata;
++ int r;
++
++ /* Before entering poll() we unlock the mutex, so that
++ * avahi_simple_poll_quit() can succeed from another thread. */
++
++ pthread_mutex_unlock(mutex);
++ r = poll(ufds, nfds, timeout);
++ pthread_mutex_lock(mutex);
++
++ return r;
++#else
++ return 0;
++#endif
++}
++
++/*
++ * Tries to setup the Zeroconf thread and any
++ * neccessary config setting.
++ */
++void* av_zeroconf_setup(unsigned long port, const char *name) {
++ struct context *ctx = NULL;
++
++ /* default service name, if there's none in
++ * the config file.
++ */
++ char service[256] = "AFP Server on ";
++ int error, ret;
++
++ /* initialize the struct that holds our
++ * config settings.
++ */
++ ctx = malloc(sizeof(struct context));
++ assert(ctx);
++ ctx->client = NULL;
++ ctx->group = NULL;
++#ifndef HAVE_AVAHI_THREADED_POLL
++ ctx->simple_poll = NULL;
++ pthread_mutex_init(&ctx->mutex, NULL);
++#else
++ ctx->threaded_poll = NULL;
++#endif
++ ctx->thread_running = 0;
++
++ LOG(log_info,
++ logtype_afpd,
++ "Setting port for Zeroconf service to: %i.\n",
++ port);
++ ctx->port = port;
++
++ /* Prepare service name */
++ if (!name) {
++ LOG(log_info,
++ logtype_afpd,
++ "Assigning default service name.\n");
++ gethostname(service+14, sizeof(service)-15);
++ service[sizeof(service)-1] = 0;
++
++ ctx->name = strdup(service);
++ }
++ else {
++ ctx->name = strdup(name);
++ }
++
++ assert(ctx->name);
++
++/* first of all we need to initialize our threading env */
++#ifdef HAVE_AVAHI_THREADED_POLL
++ if (!(ctx->threaded_poll = avahi_threaded_poll_new())) {
++ goto fail;
++ }
++#else
++ if (!(ctx->simple_poll = avahi_simple_poll_new())) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to create event loop object.\n");
++ goto fail;
++ }
++
++ avahi_simple_poll_set_func(ctx->simple_poll, poll_func, &ctx->mutex);
++#endif
++
++/* now we need to acquire a client */
++#ifdef HAVE_AVAHI_THREADED_POLL
++ if (!(ctx->client = avahi_client_new(avahi_threaded_poll_get(ctx->threaded_poll),
++ AVAHI_CLIENT_NO_FAIL,
++ client_callback,
++ ctx,
++ &error))) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to create client object: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ goto fail;
++ }
++#else
++ if (!(ctx->client = avahi_client_new(avahi_simple_poll_get(ctx->simple_poll),
++ AVAHI_CLIENT_NO_FAIL,
++ client_callback,
++ ctx,
++ &error))) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to create client object: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ goto fail;
++ }
++#endif
++
++ return ctx;
++
++fail:
++
++ if (ctx)
++ av_zeroconf_unregister(ctx);
++
++ return NULL;
++}
++
++/*
++ * This function finally runs the loop impl.
++ */
++int av_zeroconf_run(void *u) {
++ struct context *ctx = u;
++ int ret;
++
++#ifdef HAVE_AVAHI_THREADED_POLL
++ /* Finally, start the event loop thread */
++ if (avahi_threaded_poll_start(ctx->threaded_poll) < 0) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to create thread: %s\n",
++ avahi_strerror(avahi_client_errno(ctx->client)));
++ goto fail;
++ } else {
++ LOG(log_info, logtype_afpd, "Successfully started avahi loop.\n");
++ }
++#else
++ /* Create the mDNS event handler */
++ if ((ret = pthread_create(&ctx->thread_id, NULL, thread, ctx)) < 0) {
++ LOG(log_error,
++ logtype_afpd,
++ "Failed to create thread: %s\n", strerror(ret));
++ goto fail;
++ } else {
++ LOG(log_info, logtype_afpd, "Successfully started avahi loop.\n");
++ }
++#endif
++
++ ctx->thread_running = 1;
++
++ return 0;
++
++fail:
++
++ if (ctx)
++ av_zeroconf_unregister(ctx);
++
++ return -1;
++}
++
++/*
++ * Used to lock access to the loop.
++ * Currently unused.
++ */
++void av_zeroconf_lock(void *u) {
++#ifdef HAVE_AVAHI_THREADED_POLL
++ struct context *ctx = u;
++
++ avahi_threaded_poll_lock(ctx->threaded_poll);
++#endif
++}
++
++/*
++ * Used to unlock access to the loop.
++ * Currently unused.
++ */
++void av_zeroconf_unlock(void *u) {
++#ifdef HAVE_AVAHI_THREADED_POLL
++ struct context *ctx = u;
++
++ avahi_threaded_poll_unlock(ctx->threaded_poll);
++#endif
++}
++
++/*
++ * Tries to shutdown this loop impl.
++ * Call this function from outside this thread.
++ */
++void av_zeroconf_shutdown(void *u) {
++ struct context *ctx = u;
++
++ /* Call this when the app shuts down */
++#ifdef HAVE_AVAHI_THREADED_POLL
++ avahi_threaded_poll_stop(ctx->threaded_poll);
++ avahi_free(ctx->name);
++ avahi_client_free(ctx->client);
++ avahi_threaded_poll_free(ctx->threaded_poll);
++#else
++ av_zeroconf_unregister(ctx);
++#endif
++}
++
++/*
++ * Tries to shutdown this loop impl.
++ * Call this function from inside this thread.
++ */
++int av_zeroconf_unregister(void *u) {
++ struct context *ctx = u;
++
++ if (ctx->thread_running) {
++#ifndef HAVE_AVAHI_THREADED_POLL
++ pthread_mutex_lock(&ctx->mutex);
++ avahi_simple_poll_quit(ctx->simple_poll);
++ pthread_mutex_unlock(&ctx->mutex);
++
++ pthread_join(ctx->thread_id, NULL);
++#else
++ /* First, block the event loop */
++ avahi_threaded_poll_lock(ctx->threaded_poll);
++
++ /* Than, do your stuff */
++ avahi_threaded_poll_quit(ctx->threaded_poll);
++
++ /* Finally, unblock the event loop */
++ avahi_threaded_poll_unlock(ctx->threaded_poll);
++#endif
++ ctx->thread_running = 0;
++ }
++
++ avahi_free(ctx->name);
++
++ if (ctx->client)
++ avahi_client_free(ctx->client);
++
++#ifndef HAVE_AVAHI_THREADED_POLL
++ if (ctx->simple_poll)
++ avahi_simple_poll_free(ctx->simple_poll);
++
++ pthread_mutex_destroy(&ctx->mutex);
++#else
++ if (ctx->threaded_poll)
++ avahi_threaded_poll_free(ctx->threaded_poll);
++#endif
++
++ free(ctx);
++
++ return 0;
++}
++
++#endif /* USE_AVAHI */
+--- etc/afpd/afp_avahi.h.org 2006-04-21 10:29:23.000000000 +0200
++++ etc/afpd/afp_avahi.h 2006-04-22 07:40:05.000000000 +0200
+@@ -0,0 +1,58 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Avahi based Zeroconf support
++ * Docs: http://avahi.org/download/doxygen/
++ *
++ */
++
++#ifndef AFPD_AVAHI_H
++#define AFPD_AVAHI_H
++
++#include <stdlib.h>
++#include <assert.h>
++#include <string.h>
++
++#include <avahi-client/client.h>
++#include <avahi-client/publish.h>
++
++#include <avahi-common/alternative.h>
++
++#ifndef HAVE_AVAHI_THREADED_POLL
++#include <avahi-common/simple-watch.h>
++#include <signal.h> /* SIG_BLOCK */
++#else
++#include <avahi-common/thread-watch.h>
++#endif
++
++#include <avahi-common/malloc.h>
++#include <avahi-common/error.h>
++
++#include <atalk/logger.h>
++
++#define AFP_DNS_SERVICE_TYPE "_afpovertcp._tcp"
++
++struct context {
++ int thread_running;
++ pthread_t thread_id;
++ pthread_mutex_t mutex;
++ char *name;
++#ifndef HAVE_AVAHI_THREADED_POLL
++ AvahiSimplePoll *simple_poll;
++#else
++ AvahiThreadedPoll *threaded_poll;
++#endif
++ AvahiClient *client;
++ AvahiEntryGroup *group;
++ unsigned long port;
++};
++
++/* prototype definitions */
++void* av_zeroconf_setup(unsigned long, const char *);
++int av_zeroconf_run(void*);
++int av_zeroconf_unregister(void*);
++void av_zeroconf_shutdown(void*);
++void av_zeroconf_lock(void *);
++void av_zeroconf_unlock(void *);
++
++#endif /* AFPD_AVAHI_H */
+--- etc/afpd/afp_bonjour.h.org 2006-04-21 10:29:30.000000000 +0200
++++ etc/afpd/afp_bonjour.h 2006-04-21 07:37:05.000000000 +0200
+@@ -0,0 +1,27 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Bonjour based Zeroconf support
++ * Docs: http://developer.apple.com/documentation/Networking/Reference/DNSServiceDiscovery_CRef/dns_sd/
++ *
++ */
++
++#ifndef AFPD_BONJOUR_H
++#define AFPD_BONJOUR_H
++
++#include <stdlib.h>
++#include <assert.h>
++#include <string.h>
++
++#include <dns_sd.h> /* DNSServiceRegister(), DNSServiceDiscoveryDeallocate() */
++
++#include <atalk/logger.h>
++
++#define AFP_DNS_SERVICE_TYPE "_afpovertcp._tcp"
++
++/* prototype definitions */
++void* bo_zeroconf_setup(unsigned long, const char *);
++int bo_zeroconf_unregister(void);
++int bo_zeroconf_run(void);
++
++#endif /* AFPD_BONJOUR_H */
+--- etc/afpd/afp_bonjour.c.org 2006-04-21 10:29:28.000000000 +0200
++++ etc/afpd/afp_bonjour.c 2006-04-21 09:45:13.000000000 +0200
+@@ -0,0 +1,112 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Bonjour based Zeroconf support
++ * Docs: http://developer.apple.com/documentation/Networking/Reference/DNSServiceDiscovery_CRef/dns_sd/
++ *
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#ifdef HAVE_BONJOUR
++
++#include "afp_bonjour.h"
++
++DNSServiceRef publish_session = NULL;
++
++static void DNSSD_API
++publish_reply(DNSServiceRef,
++ const DNSServiceFlags,
++ DNSServiceErrorType,
++ const char *,
++ const char *,
++ const char *,
++ void *);
++
++static void DNSSD_API
++publish_reply (DNSServiceRef sdRef,
++ const DNSServiceFlags flags,
++ DNSServiceErrorType errorCode,
++ const char *name,
++ const char *regtype,
++ const char *domain,
++ void *context)
++{
++}
++
++void* bo_zeroconf_setup(unsigned long port, const char *name) {
++ DNSServiceErrorType err;
++ char service[256] = "AFP Server on ";
++
++ /* Prepare service name */
++ if (!name) {
++ LOG(log_info, logtype_afpd,, "Assigning default service name.\n");
++ gethostname(service+14, sizeof(service)-15);
++ service[sizeof(service)-1] = 0;
++
++ name = strdup(service);
++ }
++
++ assert(name);
++ assert(port);
++
++ err = DNSServiceRegister (&publish_session,
++ 0, /* flags */
++ 0, /* interface; 0 for all */
++ name, /* name */
++ AFP_DNS_SERVICE_TYPE, /* type */
++ NULL, /* domain */
++ NULL, /* hostname */
++ htons (port), /* port in network byte order */
++ 0, /* text record length */
++ NULL, /* text record */
++ publish_reply, /* callback */
++ NULL); /* context */
++
++ if (err == kDNSServiceErr_NoError) {
++ LOG(log_info, logtype_afpd, "Adding service '%s'\n", name);
++ } else {
++ LOG(log_error, logtype_afpd, "Adding service '%s' failed\n", name);
++ bo_zeroconf_unregister();
++ }
++}
++
++int bo_zeroconf_run(void) {
++ fd_set set;
++ int fd;
++ struct timeval timeout;
++
++ /* Initialize the file descriptor set. */
++ FD_ZERO (&set);
++ FD_SET (fd, &set);
++
++ /* Initialize the timeout data structure. */
++ /* TODO: Should the value for sec be configurable? */
++ timeout.tv_sec = 10;
++ timeout.tv_usec = 0;
++
++ if (publish_session != NULL) {
++ fd = DNSServiceRefSockFD(publish_session);
++
++ if (select(FD_SETSIZE,
++ &set, NULL, NULL,
++ &timeout) > 0) {
++ DNSServiceProcessResult(publish_session);
++ }
++ }
++
++ return 0;
++}
++
++int bo_zeroconf_unregister(void) {
++ if (publish_session != NULL) {
++ DNSServiceRefDeallocate(publish_session);
++ publish_session = NULL;
++ }
++
++ return 0;
++}
++
++#endif /* HAVE_BONJOUR */
+--- etc/afpd/afp_howl.c.org 2006-04-21 10:29:34.000000000 +0200
++++ etc/afpd/afp_howl.c 2006-04-21 09:46:11.000000000 +0200
+@@ -0,0 +1,92 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Howl based Zeroconf support
++ * Doc: http://www.porchdogsoft.com/products/howl/docs/
++ *
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#ifdef HAVE_HOWL
++
++#include "afp_howl.h"
++
++sw_discovery discovery = NULL;
++
++static sw_result HOWL_API publish_reply(sw_discovery,
++ sw_discovery_oid,
++ sw_discovery_publish_status,
++ sw_opaque);
++
++static sw_result HOWL_API publish_reply(sw_discovery discovery,
++ sw_discovery_oid oid,
++ sw_discovery_publish_status status,
++ sw_opaque extra) {
++ static sw_string
++ status_text[] =
++ {
++ "Started",
++ "Stopped",
++ "Name Collision",
++ "Invalid"
++ };
++
++ LOG(log_info, logtype_afpd, "publish reply: %s\n", status_text[status]);
++ return SW_OKAY;
++}
++
++void* ho_zeroconf_setup(unsigned long port, const char *name) {
++ sw_result result;
++ sw_discovery_publish_id id;
++ char service[256] = "AFP Server on ";
++
++ if (sw_discovery_init (&discovery) != SW_OKAY) {
++ LOG(log_error,
++ logtype_afpd,
++ "AFPD could not be started. \nTry running mDNSResponder.");
++ return;
++ }
++
++ /* Prepare service name */
++ if (!name) {
++ LOG(log_info, logtype_afpd, "Assigning default service name.\n");
++ gethostname(service+14, sizeof(service)-15);
++ service[sizeof(service)-1] = 0;
++
++ name = strdup(service);
++ }
++
++ assert(name);
++
++ if (!(result = sw_discovery_publish (discovery,
++ 0,
++ name,
++ AFP_DNS_SERVICE_TYPE,
++ NULL,
++ NULL,
++ port,
++ NULL,
++ 0,
++ publish_reply,
++ NULL,
++ &id)) != SW_OKAY) {
++ LOG(log_info, logtype_afpd, "Adding service '%s'\n", name);
++ } else {
++ LOG(log_error, logtype_afpd, "Adding service '%s' failed\n", name);
++ ho_zeroconf_unregister();
++ }
++}
++
++void* ho_zeroconf_run(void) {
++ sw_discovery_run(discovery);
++}
++
++void* ho_zeroconf_unregister(void) {
++ sw_discovery_stop_run(discovery);
++ sw_discovery_fina(discovery);
++}
++
++#endif /* USE_HOWL */
+--- etc/afpd/afp_howl.h.org 2006-04-21 10:29:33.000000000 +0200
++++ etc/afpd/afp_howl.h 2006-04-21 07:37:11.000000000 +0200
+@@ -0,0 +1,27 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Howl based Zeroconf support
++ * Doc: http://www.porchdogsoft.com/products/howl/docs/
++ *
++ */
++
++#ifndef AFPD_HOWL_H
++#define AFPD_HOWL_H
++
++#include <stdlib.h>
++#include <assert.h>
++#include <string.h>
++
++#include <howl.h>
++
++#include <atalk/logger.h>
++
++#define NTP_DNS_SERVICE_TYPE "_afpovertcp._tcp"
++
++/* prototype definitions */
++void* ho_zeroconf_setup(unsigned long, const char *);
++void* ho_zeroconf_unregister(void);
++void* ho_zeroconf_run(void);
++
++#endif /* AFPD_HOWL_H */
+--- etc/afpd/afp_zeroconf.h.org 2006-04-21 10:29:39.000000000 +0200
++++ etc/afpd/afp_zeroconf.h 2006-04-21 11:39:20.000000000 +0200
+@@ -0,0 +1,40 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Zeroconf facade, that abstracts access to a
++ * particular Zeroconf implementation
++ * Doc: http://www.dns-sd.org/
++ *
++ */
++
++#ifndef AFPD_ZEROCONF_H
++#define AFPD_ZEROCONF_H
++
++#include <netinet/in.h> /* htons() */
++#include <atalk/logger.h>
++
++# ifdef HAVE_BONJOUR
++# include "afp_bonjour.h"
++# elif defined (HAVE_HOWL)
++# include "afp_howl.h"
++# elif defined (HAVE_AVAHI)
++# include "afp_avahi.h"
++# endif
++
++#define AFP_PORT 548
++
++/*
++ * Prototype Definitions
++ */
++
++/*
++ * registers the ntpd service with a particular Zerconf implemenation.
++ */
++void zeroconf_register(int port, char *hostname);
++
++/*
++ * de-registers the ntpd service with a particular Zerconf implemenation.
++ */
++void zeroconf_deregister(void);
++
++#endif AFPD_ZEROCONF_H
+--- etc/afpd/afp_zeroconf.c.org 2006-04-21 10:29:38.000000000 +0200
++++ etc/afpd/afp_zeroconf.c 2006-04-21 13:12:38.000000000 +0200
+@@ -0,0 +1,97 @@
++/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
++/*
++ * Author: Daniel S. Haischt <me@daniel.stefan.haischt.name>
++ * Purpose: Zeroconf facade, that abstracts access to a
++ * particular Zeroconf implementation
++ * Doc: http://www.dns-sd.org/
++ *
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include "afp_zeroconf.h"
++
++/*
++ * Global Definitions
++ */
++#ifdef HAVE_AVAHI
++struct context *ctx = NULL;
++#endif
++
++/*
++ * Functions (actually they are just facades)
++ */
++void zeroconf_register(int port, char *hostname)
++{
++#ifdef HAVE_BONJOUR
++ LOG(log_info,
++ logtype_afpd,
++ "Attempting to register with mDNS using Apple's Bonjour\n");
++ if (hostname && strlen(hostname) > 0 && port)
++ {
++ bo_zeroconf_setup(port, hostname);
++ }
++ else if (hostname && strlen(hostname) > 0)
++ {
++ bo_zeroconf_setup(AFP_PORT, hostname);
++ }
++ else
++ {
++ bo_zeroconf_setup(AFP_PORT, NULL);
++ }
++ bo_zeroconf_run();
++#elif defined (HAVE_HOWL)
++ LOG(log_info,
++ logtype_afpd,
++ "Attempting to register with mDNS using Porchdog's Howl\n");
++ if (hostname && strlen(hostname) > 0 && port)
++ {
++ ho_zeroconf_setup(port, hostname);
++ }
++ else if (hostname && strlen(hostname) > 0)
++ {
++ ho_zeroconf_setup(AFP_PORT, hostname);
++ }
++ else
++ {
++ ho_zeroconf_setup(AFP_PORT, NULL);
++ }
++ bo_zeroconf_run();
++#elif defined (HAVE_AVAHI)
++ LOG(log_info, logtype_afpd, "Attempting to register with mDNS using Avahi\n");
++ if (hostname && strlen(hostname) > 0 && port)
++ {
++ ctx = av_zeroconf_setup(port, hostname);
++ }
++ else if (hostname && strlen(hostname) > 0)
++ {
++ ctx = av_zeroconf_setup(AFP_PORT, hostname);
++ }
++ else
++ {
++ ctx = av_zeroconf_setup(AFP_PORT, NULL);
++ }
++ av_zeroconf_run(ctx);
++#endif
++}
++
++void zeroconf_deregister(void)
++{
++#ifdef HAVE_BONJOUR
++ LOG(log_error,
++ logtype_afpd,
++ "Attempting to de-register mDNS using Apple's Bonjour\n");
++ bo_zeroconf_unregister();
++#elif defined (HAVE_HOWL)
++ LOG(log_error,
++ logtype_afpd,
++ "Attempting to de-register mDNS using Porchdog's Howl\n");
++ ho_zeroconf_unregister();
++#elif defined (HAVE_AVAHI)
++ LOG(log_error, logtype_afpd, "Attempting to de-register mDNS using Avahi\n");
++ if (ctx)
++ av_zeroconf_shutdown(ctx);
++#endif
++}
+--- macros/zeroconf.m4.org 2006-04-21 10:29:51.000000000 +0200
++++ macros/zeroconf.m4 2006-04-22 07:26:56.000000000 +0200
+@@ -0,0 +1,101 @@
++dnl Check for optional Zeroconf support
++
++dnl $Id$
++
++AC_DEFUN([NETATALK_ZEROCONF], [
++
++ ZEROCONF_LIBS=""
++ ZEROCONF_CFLAGS=""
++ found_zeroconf=no
++ zeroconf_dir=""
++
++ AC_ARG_ENABLE(zeroconf,
++ [ --enable-zeroconf[[=DIR]] enable Zeroconf support [[auto]]],
++ [zeroconf=$enableval],
++ [zeroconf=try]
++ )
++
++ dnl make sure atalk_libname is defined beforehand
++ [[ -n "$atalk_libname" ]] || AC_MSG_ERROR([internal error, atalk_libname undefined])
++
++ if test "x$zeroconf" != "xno"; then
++
++ savedcppflags="$CPPFLAGS"
++ savedldflags="$LDFLAGS"
++
++ if test "x$zeroconf" = "xyes" -o "x$zeroconf" = "xtry"; then
++ zeroconf_dir="/usr"
++ else
++ zeroconf_dir="$zeroconf"
++ fi
++
++ # mDNS support using Apple's Bonjour
++ AC_CHECK_HEADER(dns_sd.h,
++ [AC_CHECK_LIB(dns_sd,
++ DNSServiceRegister,
++ [AC_DEFINE(USE_ZEROCONF, 1,
++ [Use DNS-SD registration])])])
++ case "$ac_cv_lib_dns_sd_DNSServiceRegister" in
++ yes)
++ ZEROCONF_LIBS="-L$zeroconf_dir/lib -ldns_sd"
++ ZEROCONF_LIBS="-I$zeroconf_dir/include"
++ AC_DEFINE(HAVE_BONJOUR, 1, [Use Bonjour/DNS-SD registration])
++ found_zeroconf=yes
++ ;;
++ esac
++ # mDNS support using Porchdog's Howl
++ AC_CHECK_HEADER(howl.h,
++ [AC_CHECK_LIB(howl,
++ sw_discovery_publish,
++ [AC_DEFINE(USE_ZEROCONF, 1,
++ [Use DNS-SD registration])])])
++ case "$ac_cv_lib_howl_sw_discovery_publish" in
++ yes)
++ PKG_CHECK_MODULES(HOWL, [ howl >= 1.0.0 ])
++ ZEROCONF_LIBS="$HOWL_LIBS"
++ ZEROCONF_CFLAGS="$HOWL_CFLAGS"
++ AC_DEFINE(HAVE_HOWL, 1, [Use Howl/DNS-SD registration])
++ found_zeroconf=yes
++ ;;
++ esac
++ # mDNS support using Avahi
++ AC_CHECK_HEADER(avahi-client/client.h,
++ [AC_CHECK_LIB(avahi-client,
++ avahi_client_new,
++ [AC_DEFINE(USE_ZEROCONF, 1,
++ [Use DNS-SD registration])])])
++ case "$ac_cv_lib_avahi_client_avahi_client_new" in
++ yes)
++ PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 ])
++ PKG_CHECK_MODULES(AVAHI_TPOLL, [ avahi-client >= 0.6.4 ],
++ [AC_DEFINE(HAVE_AVAHI_THREADED_POLL, 1, [Uses Avahis threaded poll implementation])],
++ [AC_MSG_WARN(This Avahi implementation is not supporting threaded poll objects. Maybe this is not what you want.)])
++ ZEROCONF_LIBS="$AVAHI_LIBS"
++ ZEROCONF_CFLAGS="$AVAHI_CFLAGS"
++ AC_DEFINE(HAVE_AVAHI, 1, [Use Avahi/DNS-SD registration])
++ found_zeroconf=yes
++ ;;
++ esac
++
++ CPPFLAGS="$savedcppflags"
++ LDFLAGS="$savedldflags"
++ fi
++
++ netatalk_cv_zeroconf=no
++ AC_MSG_CHECKING([whether to enable Zerconf support])
++ if test "x$found_zeroconf" = "xyes"; then
++ AC_MSG_RESULT([yes])
++ AC_DEFINE(USE_ZEROCONF, 1, [Define to enable Zeroconf support])
++ netatalk_cv_zeroconf=yes
++ else
++ AC_MSG_RESULT([no])
++ if test "x$zeroconf" != "xno" -a "x$zeroconf" != "xtry"; then
++ AC_MSG_ERROR([Zeroconf installation not found])
++ fi
++ fi
++
++ LIB_REMOVE_USR_LIB(ZEROCONF_LIBS)
++ CFLAGS_REMOVE_USR_INCLUDE(ZEROCONF_CFLAGS)
++ AC_SUBST(ZEROCONF_LIBS)
++ AC_SUBST(ZEROCONF_CFLAGS)
++])
diff --git a/packages/freenas/doc/README.txt b/packages/freenas/doc/README.txt
new file mode 100644
index 00000000..5f6e5c84
--- /dev/null
+++ b/packages/freenas/doc/README.txt
@@ -0,0 +1,46 @@
+FreeNAS Port for pfSense
+=~=~=~=~=~=~=~=~=~=~=~=~
+
+This is a port of the FreeNAS PHP sources to pfSense.
+It is based on FreeNAS 0.68 and was tested on pfSense
+HEAD.
+
+*** NOTE ***
+
+You should be aware that this package installes a custom
+kernel and some additional kernel modules.
+
+Maintainer:
+-----------
+
+Daniel S. Haischt <me@daniel.stefan.haischt.name>
+
+Dependencies:
+-------------
+
+* ataidle-0.9
+* avahi+libdns-0.6.12
+* pkgconfig-0.20
+* perl-5.8.8
+* libiconv-1.9.2_2
+* libxml2-2.6.26
+* libdaemon-0.10_1
+* gettext-0.14.5_2
+* glib-2.10.3
+* expat-2.0.0_1
+* dbus-0.62
+* wzdftpd-0.7.2_1
+* e2fsprogs-1.39_1
+* smartmontools-5.36
+* aaccli-1.0
+* rsync-2.6.8_2
+* scponly-4.6_1
+* unison-2.13.16_1
+* cracklib-2.7_2
+* samba-3.0.23,1
+* db44-4.4.20.2
+* popt-1.7_1
+* cyrus-sasl-2.1.22
+* openldap-sasl-client-2.3.24
+* netatalk-2.0.3_3,1
+* pam_ldap-1.8.2 \ No newline at end of file
diff --git a/packages/freenas/pkg/freenas.xml b/packages/freenas/pkg/freenas.xml
new file mode 100644
index 00000000..ef90cf2b
--- /dev/null
+++ b/packages/freenas/pkg/freenas.xml
@@ -0,0 +1,345 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<packagegui>
+ <name>freenas</name>
+ <version>1.0</version>
+ <title>System: Disks: Management</title>
+ <include_file>/usr/local/pkg/freenas.inc</include_file>
+ <!-- Menu is where this packages menu will appear -->
+ <menu>
+ <name>FreeNAS Disks</name>
+ <section>System</section>
+ <configfile>freenas.xml</configfile>
+ <url>/disk_manage.php</url>
+ </menu>
+ <menu>
+ <name>FreeNAS RAID</name>
+ <section>System</section>
+ <url>/disks_raid_gmirror.php</url>
+ </menu>
+ <menu>
+ <name>FreeNAS Mounts</name>
+ <section>System</section>
+ <url>/disks_mount.php</url>
+ </menu>
+ <menu>
+ <name>FreeNAS Infos</name>
+ <section>Diagnostics</section>
+ <url>/diag_disk_infos.php</url>
+ </menu>
+ <menu>
+ <name>FreeNAS Logs</name>
+ <section>Diagnostics</section>
+ <url>/diag_fn_logs_samba.php</url>
+ </menu>
+ <menu>
+ <name>Disk Status</name>
+ <section>Status</section>
+ <url>/status_disks.php</url>
+ </menu>
+ <service>
+ <name>dspam</name>
+ <rcfile>/usr/local/etc/rc.d/dspam.sh</rcfile>
+ </service>
+ <tabs />
+ <!--
+ configpath gets expanded out automatically and config items
+ will be stored in that location
+ -->
+ <configpath>['installedpackages']['freenas']['config']</configpath>
+ <!-- PHP files (disk management) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_manage.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_manage_edit.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_manage_init.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_manage_iscsi.php</item>
+ </additional_files_needed>
+ <!-- PHP files (RAID management) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_edit.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_init.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_tools.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_edit.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_init.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_tools.php</item>
+ </additional_files_needed>
+ <!-- PHP files (mount management) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_mount.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/disks_mount_edit.php</item>
+ </additional_files_needed>
+ <!-- PHP files (diagnostics) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_ad_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_ataidle_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_disk_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_iscsi_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_mounts_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_part_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_raid_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_smart_infos.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_space_infos.php</item>
+ </additional_files_needed>
+ <!-- PHP files (logs) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_daemon.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_ftp.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_rsyncd.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_samba.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_settings.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_smartd.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_sshd.php</item>
+ </additional_files_needed>
+ <!-- PHP files (services) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/services_afp.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/services_ftp.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/services_nfs.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/services_rsyncd.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/services_rsyncd_client.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/services_samba.php</item>
+ </additional_files_needed>
+ <!-- PHP files (misc) -->
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/www/status_disks.php</item>
+ </additional_files_needed>
+ <!-- package files -->
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/pkg/freenas_disks.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/pkg/freenas_functions.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/pkg/freenas_guiconfig.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/pkg/freenas_services.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/pkg/freenas_utils.inc</item>
+ </additional_files_needed>
+ <!-- kernel binaries -->
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/iscsi_initiator.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/ext2fs.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/geom_concat.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/geom_gpt.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/geom_mirror.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/geom_stripe.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/geom_vinum.ko</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/kernel.gz</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/ntfs.ko</item>
+ </additional_files_needed>
+ <!-- kernel binaries -->
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freenas/bin/iscontrol</item>
+ </additional_files_needed>
+ <!--
+ fields gets invoked when the user adds or edits a item. The following items
+ will be parsed and rendered for the user as a gui with input, and selectboxes.
+ -->
+ <!--
+ Arbitrary PHP Code, that gets executed if a certain event gets triggered.
+ -->
+ <custom_php_resync_config_command>
+ sync_package_freenas();
+ </custom_php_resync_config_command>
+ <custom_php_install_command>
+ custom_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ custom_php_deinstall_command();
+ </custom_php_deinstall_command>
+</packagegui>
diff --git a/packages/freenas/pkg/freenas_disks.inc b/packages/freenas/pkg/freenas_disks.inc
new file mode 100644
index 00000000..4cc9f5c5
--- /dev/null
+++ b/packages/freenas/pkg/freenas_disks.inc
@@ -0,0 +1,899 @@
+<?php
+/*
+ disks.inc
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* include all configuration functions */
+require_once("functions.inc");
+
+$freenas_config =& $config['installedpackages']['freenas']['config'][0];
+
+function disks_mount_all()
+{
+ global $freenas_config, $g;
+
+ if ($g['booting'])
+ echo "Mounting Partitions... ";
+
+ /* For each device configured:*/
+
+ if (is_array($freenas_config['mounts']['mount']))
+ {
+ foreach ($freenas_config['mounts']['mount'] as $mountent)
+ {
+ /* Advanced Umount filesystem if not booting mode (mount edition)*/
+ if (!$g['booting'])
+ disks_umount_adv($mountent);
+
+ /* mount filesystem */
+ disks_mount($mountent);
+
+ }
+ }
+
+ if ($g['booting'])
+ echo "done\n";
+
+ return 0;
+
+}
+
+function disks_mount($mount)
+{
+ global $config, $g;
+
+ /* mount the specified $mount partition */
+ /* The $mount variable is the all config table for the mount point*/
+
+ /* Create one directory for each device under mnt */
+
+ $mountname=escapeshellcmd($mount['sharename']);
+
+ @mkdir ("/mnt/$mountname",0777);
+
+ /* mount the filesystems */
+
+ /* Must use a special dev name for software RAID volume */
+
+ if (strcmp($mount['partition'],"gvinum") == 0)
+ $devname="/dev/gvinum/{$mount['mdisk']}";
+ else if (strcmp($mount['partition'],"gmirror") == 0)
+ $devname="/dev/mirror/{$mount['mdisk']}";
+ else
+ $devname="/dev/{$mount['mdisk']}{$mount['partition']}";
+
+ /* check the fileystem only if there is a problem*/
+
+ switch ($mount['fstype'])
+ {
+ case "ufs":
+
+ if (mwexec("/sbin/mount -t ufs -o acls {$devname} /mnt/$mountname") == 0)
+ {
+ /* Change this directory into 777 mode */
+ mwexec("/bin/chmod 777 /mnt/$mountname");
+ return 0;
+ }
+ else
+ {
+ /* If it's NOK, Check filesystem and do a fsck, answer Yes to all question*/
+ mwexec("/sbin/fsck -y -t ufs {$devname}");
+ /* Re-try to mount the partition */
+ if (mwexec("/sbin/mount -t ufs -o acls {$devname} /mnt/$mountname") == 0)
+ {
+ /* Change this directory into 777 mode */
+ mwexec("/bin/chmod 777 /mnt/$mountname");
+ return 0;
+ }
+ else
+ {
+ /* Not OK, remove the directory, prevent writing on RAM */
+ @rmdir ("/mnt/$mountname");
+ return 1;
+ }
+
+ }
+ break;
+
+ case "msdosfs":
+ if (mwexec("/sbin/mount_msdosfs -u ftp -g ftp -m 777 {$devname} /mnt/$mountname") == 0)
+ return 0;
+ else
+ {
+ exec("/sbin/fsck_msdosfs -y {$devname}");
+ if (mwexec("/sbin/mount_msdosfs -u ftp -g ftp -m 777 {$devname} /mnt/$mountname") == 0)
+ return 0;
+ else
+ {
+ /* Not OK, remove the directory, prevent writing on RAM */
+ @rmdir ("/mnt/$mountname");
+ return 1;
+ }
+ }
+
+ break;
+
+ case "ntfs":
+ if (mwexec("/sbin/mount_ntfs -u ftp -g ftp -m 777 {$devname} /mnt/$mountname") == 0)
+ return 0;
+ else
+ {
+ /* Not OK, remove the directory, prevent writing on RAM */
+ @rmdir ("/mnt/$mountname");
+ return 1;
+ }
+ break;
+
+ case "ext2fs":
+ if (mwexec("/sbin/mount_ext2fs {$devname} /mnt/$mountname") == 0)
+ {
+ /* Change this directory into 777 mode */
+ mwexec("/bin/chmod 777 /mnt/$mountname");
+ return 0;
+ }
+ else
+ {
+ exec("/usr/local/sbin/e2fsck -f -p -y {$devname}");
+ if (mwexec("/sbin/mount_ext2fs {$devname} /mnt/$mountname") == 0)
+ {
+ /* Change this directory into 777 mode */
+ mwexec("/bin/chmod 777 /mnt/$mountname");
+ return 0;
+ }
+ else
+ {
+ /* Not OK, remove the directory, prevent writing on RAM */
+ @rmdir ("/mnt/$mountname");
+ return 1;
+ }
+ }
+ break;
+ }
+
+}
+
+function disks_umount($mount)
+{
+ global $config, $g;
+
+ /* Umout the specified mount point */
+ /* The $mount variable is the all config table for the mount point*/
+
+ $mountname=escapeshellcmd($mount['sharename']);
+
+ if (mwexec("/sbin/umount $mountname") == 0)
+ {
+ if (@rmdir ("/mnt/$mountname"))
+ return 0;
+ else
+ return 1;
+
+ }
+
+ else
+ return 1;
+
+}
+
+function disks_umount_adv($mount)
+{
+ global $config, $g;
+
+ /* Advanced unmout the specified mount point without using the sharename (changing it)*/
+ /* The $mount variable is the all config table for the mount point*/
+
+ $mountpart="{$mount['partition']}";
+
+ if ((strcmp($mountpart,"gvinum") == 0) || (strcmp($mountpart,"gmirror") == 0))
+ $complete = "{$mount['mdisk']}";
+ else
+ $complete = "{$mount['mdisk']}{$mount['partition']}";
+
+ // get the mount list
+ $detmount = get_mounts_list();
+
+ foreach ($detmount as $detmountk => $detmountv)
+ {
+
+ // If we found the mount point on the device
+
+ if (strcmp($detmountv['mdisk'],$complete) == 0)
+ {
+ $mountname="{$detmountv['mp']}";
+ }
+
+ }
+
+ if ($mountname)
+ {
+ exec("/sbin/umount $mountname");
+ @rmdir ("$mountname");
+ return 0;
+ }
+ else
+ return 1;
+}
+
+function disks_mount_status($mount)
+{
+ // This option check if the mount are mounted
+ global $config, $g;
+ $detmount = get_mounts_list();
+ $status="ERROR";
+
+ // Recreate the full system name device+s+partition number
+ /* mount the filesystems */
+
+ $mountpart="{$mount['partition']}";
+
+ if ((strcmp($mountpart,"gvinum") == 0) || (strcmp($mountpart,"gmirror") == 0))
+ $complete = "{$mount['mdisk']}";
+ else
+ $complete = "{$mount['mdisk']}{$mount['partition']}";
+
+ //echo "debug, display complete: $complete <br>";
+
+ foreach ($detmount as $detmountk => $detmountv)
+ {
+
+ //echo "debug, display detmountv[mdisk]: {$detmountv['mdisk']} <br>";
+
+ if (strcmp($detmountv['mdisk'],$complete) == 0)
+ {
+ $status="OK";
+ return $status;
+ }
+
+ }
+ return $status;
+}
+
+function disks_check_mount($disk)
+{
+ // This option check if the partition 1 of the disk is mounted
+ // Return 0 if not, 1 if yes
+ global $config, $g;
+ $detmount = get_mounts_list();
+ $status=0;
+
+ // Recreate the full system name device+s+partition number
+ /* mount the filesystems */
+
+ $complete = "{$disk}" . "s1";
+
+ foreach ($detmount as $detmountk => $detmountv)
+ {
+
+ //echo "debug, display detmountv[mdisk]: {$detmountv['mdisk']} <br>";
+
+ if (strcmp($detmountv['mdisk'],$complete) == 0)
+ {
+ $status="1";
+ return $status;
+ }
+
+ }
+ return $status;
+}
+
+
+
+function disks_status($diskname)
+{
+ // This option check if the configured disk is online
+ global $config, $g;
+ $detectedlist = get_physical_disks_list();
+ $status="MISSING";
+ foreach ($detectedlist as $detecteddisk => $detecteddiskv)
+ {
+
+ if ($detecteddisk == $diskname['name'])
+ {
+ $status="ONLINE";
+ if (($detecteddiskv['size'] != $diskname['size']) || ($detecteddiskv['desc'] != $diskname['desc']))
+ $status="CHANGED";
+ break;
+ }
+ }
+ return $status;
+}
+
+
+function disks_addfstab($cfgdev,$cfgtype) {
+ global $config, $g;
+
+ /* Open or create fstab in RW */
+ $fd = fopen("{$g['etc_path']}/fstab", "w");
+
+ if ( $fd )
+ {
+ /* check for the precence of dev */
+ /* ADD (check if it's ADD line or replace) the line for the dev */
+ $fstab = "/dev/$cfgdev /mnt/$cfgdev $cfgtype rw 1 1\n";
+
+ /* write out an fstab */
+ fwrite($fd, $fstab);
+
+ /* close file */
+ fclose($fd);
+ }
+ else
+ {
+ die( "fopen failed for {$g['etc_path']}/fstab" ) ;
+ }
+
+}
+
+function disks_umount_all() {
+ global $freenas_config, $g;
+
+ /* Sync disks*/
+ mwexec("/usr/bin/sync");
+
+ if (is_array($freenas_config['mounts']['mount']))
+ {
+ foreach ($freenas_config['mounts']['mount'] as $mountent)
+ {
+
+ /* Umount filesystem */
+ disks_umount($mountent);
+
+ }
+ }
+
+ return 0;
+
+}
+
+function disks_raid_configure()
+{
+ global $freenas_config, $g;
+
+ /* Generate the raid.conf file */
+
+ if ($freenas_config['raid']['vdisk'])
+ {
+
+ foreach ($freenas_config['raid']['vdisk'] as $a_raid_conf)
+ {
+
+ if (file_exists($g['varrun_path'] . "/raid.conf.dirty") &&
+ !in_array("{$a_raid_conf['name']}\n",file($g['varrun_path'] . "/raid.conf.dirty"))) continue;
+
+ /* generate raid.conf */
+ $fd = fopen("{$g['varetc_path']}/raid-{$a_raid_conf['name']}.conf", "w");
+ if (!$fd)
+ {
+ printf("Error: cannot open raid.conf in services_raid_configure().\n");
+ return 1;
+ }
+
+ $raidconf="";
+ foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv)
+ {
+ $raidconf .= <<<EOD
+drive disk_{$diskrv} device /dev/{$diskrv}s1a
+
+EOD;
+
+ }
+
+ $raidconf .= <<<EOD
+volume {$a_raid_conf['name']}
+
+EOD;
+
+ switch ($a_raid_conf['type'])
+ {
+ case "0":
+ $raidconf .= <<<EOD
+plex org striped 256k
+
+EOD;
+ foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv)
+ {
+ /* Get the disksize */
+ $disksize=get_disks_size($diskrv);
+ /* Remove the ending 'B' in 'MB' */
+ $disksize=rtrim($disksize, 'B');
+ /* $raidconf .= <<<EOD
+sd length {$disksize} drive disk_{$diskrv}
+
+EOD; */
+ $raidconf .= <<<EOD
+sd length 0 drive disk_{$diskrv}
+
+EOD;
+
+ }
+ break;
+ case "1":
+ foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv)
+ {
+ $raidconf .= <<<EOD
+plex org concat
+
+EOD;
+
+ /* Get the disksize */
+ $disksize=get_disks_size($diskrv);
+ /* Remove the ending 'B' in 'MB' */
+ $disksize=rtrim($disksize, 'B');
+ /* $raidconf .= <<<EOD
+sd length {$disksize} drive disk_{$diskrv}
+
+EOD; */
+
+ $raidconf .= <<<EOD
+sd length 0 drive disk_{$diskrv}
+
+EOD;
+
+ }
+
+ break;
+ case "5":
+ $raidconf .= <<<EOD
+plex org raid5 256k
+
+EOD;
+ foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv)
+ {
+ /* Get the disksize */
+ $disksize=get_disks_size($diskrv);
+ /* Remove the ending 'B' in 'MB' */
+ $disksize=rtrim($disksize, 'B');
+ /* $raidconf .= <<<EOD
+sd length {$disksize} drive disk_{$diskrv}
+
+EOD; */
+
+ $raidconf .= <<<EOD
+sd length 0 drive disk_{$diskrv}
+
+EOD;
+
+ }
+ break;
+
+ }
+ fwrite($fd, $raidconf);
+ fclose($fd);
+
+ /* Create each volume */
+
+ mwexec("/sbin/gvinum create {$g['varetc_path']}/raid-{$a_raid_conf['name']}.conf");
+
+ }
+
+
+ /* start each volume */
+
+ foreach ($freenas_config['raid']['vdisk'] as $a_raid_conf)
+ {
+ exec("/sbin/gvinum lv $raidname",$rawdata);
+ if (strpos($rawdata[0],"State: up")>=0) continue;
+
+ mwexec("/sbin/gvinum start {$a_raid_conf['name']}");
+ }
+
+ }
+
+ return 0;
+}
+
+function disks_raid_gmirror_configure()
+{
+ global $freenas_config, $g;
+
+ /* Create the gmirror device */
+
+ if ($freenas_config['gmirror']['vdisk']) {
+
+ // Load gmirror
+
+ mwexec("/sbin/gmirror load");
+
+ foreach ($freenas_config['gmirror']['vdisk'] as $a_raid_conf) {
+
+ /* Create each volume */
+
+ $cmd = "/sbin/gmirror label -b {$a_raid_conf['balance']} {$a_raid_conf['name']} ";
+
+ foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv) {
+ $cmd .= "{$diskrv} ";
+ }
+
+ mwexec($cmd);
+
+ }
+ }
+
+ return 0;
+}
+
+function disks_raid_start()
+{
+ global $config, $g;
+
+ /* Start software RAID */
+ disks_raid_gvinum_start();
+ disks_raid_gmirror_start();
+
+ return 0;
+
+}
+
+
+function disks_raid_gvinum_start()
+{
+ global $freenas_config, $g;
+
+ /* Generate the raid.conf file */
+
+ if ($freenas_config['raid']['vdisk']) {
+
+ if ($g['booting'])
+ echo "Start gvinum raid... ";
+
+ /* start each volume */
+
+ foreach ($freenas_config['raid']['vdisk'] as $a_raid_conf) {
+ mwexec("/sbin/gvinum start {$a_raid_conf['name']}");
+ }
+
+ if ($g['booting'])
+ echo "done\n";
+
+ }
+
+ return 0;
+}
+
+function disks_raid_gmirror_start()
+{
+ global $freenas_config, $g;
+
+ /* Start Geom mirror */
+
+ if ($freenas_config['gmirror']['vdisk']) {
+
+ if ($g['booting'])
+ echo "Start gmirror raid... ";
+
+ // Load geom mirror module
+
+ mwexec("/sbin/gmirror load");
+
+ if ($g['booting'])
+ echo "done\n";
+
+ }
+
+ return 0;
+}
+
+function disks_raid_stop()
+{
+ /* Stop software RAID */
+
+ disks_raid_gvinum_stop();
+ disks_raid_gmirror_stop();
+
+ return 0;
+
+}
+
+function disks_raid_gvinum_stop()
+{
+ global $freenas_config, $g;
+
+ /* Generate the raid.conf file */
+
+ if ($freenas_config['raid']['vdisk']) {
+
+ /* stop each volume */
+
+ foreach ($freenas_config['raid']['vdisk'] as $a_raid_conf) {
+ mwexec("/sbin/gvinum stop {$a_raid_conf['name']}");
+ }
+
+ }
+
+ return 0;
+}
+
+function disks_raid_gmirror_stop()
+{
+ global $freenas_config, $g;
+
+ /* Generate the raid.conf file */
+
+ if ($freenas_config['gmirror']['vdisk']) {
+
+ /* start each volume */
+
+ foreach ($freenas_config['gmirror']['vdisk'] as $a_raid_conf) {
+ mwexec("/sbin/gmirror stop {$a_raid_conf['name']}");
+ }
+
+
+ }
+
+ return 0;
+}
+
+function disks_raid_gvinum_delete($raidname)
+{
+ global $freenas_config, $g;
+
+ /* Delete a gvinum volume */
+
+ //echo "DEBUG: delete {$raidname}";
+
+ exec("/sbin/gvinum lv $raidname",$rawdata);
+ if (strpos($rawdata[0],"State: up") === false) {
+ return 0;
+ }
+
+ mwexec("/sbin/gvinum rm -r $raidname");
+
+ foreach ($freenas_config['raid']['vdisk'] as $a_raid) {
+ if ($a_raid['name'] == $raidname) {
+ foreach ($a_raid['diskr'] as $disk) {
+ mwexec("/sbin/gvinum rm -r disk_{$disk}");
+ }
+ }
+ }
+
+ return 0;
+}
+
+function disks_raid_gmirror_delete($raidname)
+{
+ global $freenas_config, $g;
+
+ /* Delete a gmirror volume */
+
+ // Stop the volume
+
+ mwexec("/sbin/gmirror stop $raidname");
+
+ // Clear the gmirror information on the hard drive
+
+ foreach ($freenas_config['gmirror']['vdisk'] as $a_raid) {
+ if ($a_raid['name'] == $raidname) {
+ foreach ($a_raid['diskr'] as $disk) {
+ mwexec("/sbin/gmirror clear {$disk}");
+ }
+ }
+ }
+
+ return 0;
+}
+
+function fdisk_hd_install($harddrive)
+{
+ global $config, $g;
+
+ /* Initialise HARD DRIVE for installing FreeNAS (creating 2 partition) */
+
+ /* getting disk information */
+ $fdisk_info=fdisk_get_info($harddrive);
+
+ /* setting FreeNAS partition size to 32Mb*/
+
+ $part_freenas_size=32;
+
+ /* convert Mb to b */
+ $part_freenas_size=$part_freenas_size * 1024 * 1024;
+
+ $part1_size=$part_freenas_size / $fdisk_info['sec_size'];
+ $part2_size=$fdisk_info['total'] - $part1_size;
+
+ /* Create fdisk config file */
+
+
+ /* generate fdisk.conf */
+ $fd = fopen("{$g['varetc_path']}/fdisk.conf", "w");
+ if (!$fd)
+ {
+ printf("Error: cannot open fdisk.conf in fdisk_hd_install().\n");
+ return 1;
+ }
+
+ $fdiskconf .= <<<EOD
+g c{$fdisk_info['cyl']} h{$fdisk_info['head']} s{$fdisk_info['sect']}
+p 1 165 1 $part1_size
+p 2 165 $part1_size $part2_size
+p 3 0 0 0
+p 4 0 0 0
+a 1
+
+EOD;
+
+ fwrite($fd, $fdiskconf);
+ fclose($fd);
+
+ /* Fdisk the disk */
+
+ /* Warning: Ask two questions to the user */
+ mwexec("/sbin/fdisk -f {$g['varetc_path']}/fdisk.conf /dev/$harddrive");
+
+ return 0;
+}
+
+function fdisk_get_info($harddrive)
+{
+
+ /* Return information about an harddrive
+
+ $result['total'] : size
+ $result['cyl'] : cylinders
+ $result['head'] : heads
+ $result['sect'] : sectors/track
+ $result['sec_size'] : Media sector size
+
+ */
+
+ global $config, $g;
+
+ exec("/sbin/fdisk /dev/$harddrive",$rawdata);
+
+ $result=array();
+
+ foreach ($rawdata as $line)
+ {
+ /* separe the line by space or egal*/
+
+ $aline= preg_split("/[\s,]+|=/", $line);
+
+ $first_word = chop($aline[0]);
+
+ if ($aline[0] == "Media")
+ {
+ $result['sec_size']=chop($aline[4]);
+ continue ;
+ }
+
+ if ($aline[0] == "cylinders")
+ {
+
+ $result['cyl']=chop($aline[1]);
+ $result['head']=chop($aline[3]);
+ $result['sect']=chop($aline[5]);
+ continue ;
+ }
+
+ }
+
+ $result['total'] = $result['cyl'] * $result['head'] * $result['sect'] ;
+
+ return $result;
+
+}
+
+function disks_bsdlabel($harddrive,$partition,$type)
+{
+ global $config, $g;
+
+ // Generating BSD Label table
+
+ passthru("/sbin/bsdlabel " . escapeshellarg($harddrive) ."$partition > {$g['tmp_path']}/label.tmp");
+
+ // put this file on a array
+ $tableau = file("{$g['tmp_path']}/label.tmp");
+
+ // Open this file in add mode
+ $handle = fopen("{$g['tmp_path']}/label.tmp", 'a');
+
+ while(list(,$val) = each($tableau))
+ {
+ // If the line contain the word "unused"
+
+ if (ereg ("unused",$val))
+ {
+ // Replacing c: by a:
+ $val = ereg_replace ("c:","a:", $val);
+ // Peplacing unused by $type
+ $val = ereg_replace ("unused",$type, $val);
+ // Adding this line add the end of the file
+ fwrite($handle, $val);
+ }
+ }
+ // Closing file
+ fclose($handle);
+
+ // Injecting this new partition table
+ passthru("/sbin/bsdlabel -R -B " . escapeshellarg($harddrive) ."$partition {$g['tmp_path']}/label.tmp");
+}
+
+
+function disks_set_ataidle()
+{
+ global $g, $freenas_config;
+
+ if (is_array($freenas_config['disks']['disk']))
+ {
+ foreach ($freenas_config['disks']['disk'] as $disk)
+ {
+
+ if ($disk['type']=="IDE")
+ {
+ /* If UDMA mode forced, launch atacontrol */
+ if (isset($disk['udma']) && ($disk['udma'] != "auto"))
+ mwexec("/sbin/atacontrol mode {$disk['name']} {$disk['udma']}");
+
+ /* Don't use ataidle if all is disabled */
+ if (($disk['harddiskstandby'] == 0) && ($disk['apm'] == 0) && ($disk['acoustic'] == 0))
+ continue;
+
+ /* Found the channel and device number from the /dev name */
+ /* Divise the number by 2, the interger is the channel number, the rest is the device */
+
+ $value=trim($disk['name'],'ad');
+
+ $value=intval($value);
+ $channel = $value/2;
+ $device=$value % 2;
+ $channel=intval($channel);
+ $time=$disk['harddiskstandby'];
+ $apm=$disk['apm'];
+ $ac=$disk['acoustic'];
+
+ /* mwexec("/usr/local/sbin/ataidle -A $ac -P $apm -S $time $channel $device"); */
+
+ $cmd = "/usr/local/sbin/ataidle ";
+
+ if ($disk['acoustic'] != 0)
+ $cmd .= "-A $ac ";
+ if ($disk['apm'] != 0)
+ $cmd .= "-P $apm ";
+ if ($disk['harddiskstandby'] !=0)
+ $cmd .= "-S $time ";
+
+ $cmd .= "$channel $device";
+
+ mwexec($cmd);
+
+
+ }
+
+ }
+ return 1;
+ }
+
+ return 0;
+
+}
+
+?>
diff --git a/packages/freenas/pkg/freenas_functions.inc b/packages/freenas/pkg/freenas_functions.inc
new file mode 100644
index 00000000..02be42b5
--- /dev/null
+++ b/packages/freenas/pkg/freenas_functions.inc
@@ -0,0 +1,38 @@
+<?php
+
+/* $Id$ */
+/*
+ functions.inc
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ Originally part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* include all configuration functions */
+require_once ("freenas_disks.inc");
+require_once ("freenas_utils.inc");
+require_once ("freenas_services.inc");
+?> \ No newline at end of file
diff --git a/packages/freenas/pkg/freenas_guiconfig.inc b/packages/freenas/pkg/freenas_guiconfig.inc
new file mode 100644
index 00000000..f46cf8df
--- /dev/null
+++ b/packages/freenas/pkg/freenas_guiconfig.inc
@@ -0,0 +1,104 @@
+<?php
+/*
+ guiconfig.inc
+ part of m0n0wall (http://m0n0.ch/wall)
+
+ Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Modified for FreeNAS (http://freenas.org) by Olivier Cochard <cochard@gmail.com>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$d_mountdirty_path = $g['varrun_path'] . "/mount.dirty";
+$d_diskdirty_path = $g['varrun_path'] . "/disk.dirty";
+$d_raidconfdirty_path = $g['varrun_path'] . "/raid.conf.dirty";
+$d_userconfdirty_path = $g['varrun_path'] . "/user.conf.dirty";
+$d_groupconfdirty_path = $g['varrun_path'] . "/group.conf.dirty";
+
+$freenas_config =& $config['installedpackages']['freenas']['config'][0];
+
+function mount_sort() {
+ global $g, $freenas_config;
+
+ function mountcmp($a, $b) {
+ return strcmp($a['mdisk'], $b['mdisk']);
+ }
+
+ usort($freenas_config['mounts']['mount'], "mountcmp");
+}
+
+function disks_sort() {
+ global $g, $freenas_config;
+
+ function diskcmp($a, $b) {
+ return strcmp($a['name'], $b['name']);
+ }
+
+ usort($freenas_config['disks']['disk'], "diskcmp");
+}
+
+function gvinum_sort() {
+ global $g, $freenas_config;
+
+ function gvinumcmp($a, $b) {
+ return strcmp($a['name'], $b['name']);
+ }
+
+ usort($freenas_config['raid']['vdisk'], "gvinumcmp");
+
+}
+
+function gmirror_sort() {
+ global $g, $freenas_config;
+
+ function gmirrorcmp($a, $b) {
+ return strcmp($a['name'], $b['name']);
+ }
+
+ usort($freenas_config['gmirror']['vdisk'], "gmirrorcmp");
+
+}
+
+/* TODO: This needs to be changed */
+function users_sort() {
+ global $g, $config;
+
+ function userscmp($a, $b) {
+ return strcmp($a['login'], $b['login']);
+ }
+
+ usort($config['access']['user'], "userscmp");
+}
+
+/* TODO: This needs to be changed */
+function groups_sort() {
+ global $g, $config;
+
+ function groupscmp($a, $b) {
+ return strcmp($a['name'], $b['name']);
+ }
+
+ usort($config['access']['group'], "groupscmp");
+}
+?> \ No newline at end of file
diff --git a/packages/freenas/pkg/freenas_services.inc b/packages/freenas/pkg/freenas_services.inc
new file mode 100644
index 00000000..a2d8d531
--- /dev/null
+++ b/packages/freenas/pkg/freenas_services.inc
@@ -0,0 +1,1600 @@
+<?php
+/* $Id$ */
+/*
+ services.inc
+ part of m0n0wall (http://m0n0.ch/wall)
+
+ Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Modified for FreeNAS (http://freenas.org) by Olivier Cochard <cochard@gmail.com>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$freenas_config =& $config['installedpackages']['freenas']['config'][0];
+
+function services_samba_configure() {
+ global $freenas_config, $g;
+
+ /* kill any running samba */
+
+ killbyname("smbd");
+ killbyname("winbindd");
+ killbyname("nmbd");
+
+ if (isset($freenas_config['samba']['enable']))
+ {
+
+ if ($g['booting'])
+ echo "Starting Samba... ";
+
+ /* generate smb.conf */
+ $fd = fopen("{$g['varetc_path']}/smb.conf", "w");
+ if (!$fd) {
+ printf("Error: cannot open smb.conf in services_samba_configure().\n");
+ return 1;
+ }
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ return 0;
+
+
+ $sambaconf = <<<EOD
+[global]
+encrypt passwords = yes
+netbios name = {$freenas_config['samba']['netbiosname']}
+workgroup = {$freenas_config['samba']['workgroup']}
+server string = {$freenas_config['samba']['serverdesc']}
+load printers = no
+security = {$freenas_config['samba']['security']}
+dns proxy = no
+socket options = IPTOS_LOWDELAY TCP_NODELAY
+EOD;
+
+ if ($freenas_config['samba']['sndbuf']) {
+ $sambaconf .= <<<EOD
+ SO_SNDBUF={$freenas_config['samba']['sndbuf']}
+EOD;
+ }
+ else {
+ $sambaconf .= <<<EOD
+ SO_SNDBUF=16384
+EOD;
+ }
+
+ if ($freenas_config['samba']['rcvbuf']) {
+ $sambaconf .= <<<EOD
+ SO_RCVBUF={$freenas_config['samba']['rcvbuf']}
+EOD;
+ }
+ else {
+ $sambaconf .= <<<EOD
+ SO_RCVBUF=16384
+EOD;
+ }
+
+ if ($freenas_config['samba']['winssrv']) {
+ $sambaconf .= <<<EOD
+
+wins server = {$freenas_config['samba']['winssrv']}
+
+EOD;
+ }
+
+ if (isset ($freenas_config['samba']['unixcharset'])) {
+ $sambaconf .= <<<EOD
+
+unix charset = {$freenas_config['samba']['unixcharset']}
+
+EOD;
+ }
+ else {
+ $sambaconf .= <<<EOD
+
+unix charset = UTF-8
+
+EOD;
+
+ }
+
+
+
+ $sambaconf .= <<<EOD
+
+local master = {$freenas_config['samba']['localmaster']}
+time server = {$freenas_config['samba']['timesrv']}
+guest account = ftp
+display charset = UTF-8
+max log size = 100
+#syslog only = yes
+syslog = 3
+load printers = no
+printing = bsd
+printcap name = /dev/null
+disable spoolss = Yes
+log level = {$freenas_config['samba']['loglevel']}
+dos charset = {$freenas_config['samba']['doscharset']}
+smb passwd file = {$g['varetc_path']}/private/smbpasswd
+private dir = {$g['varetc_path']}/private
+
+EOD;
+
+ switch ($freenas_config['samba']['security']) {
+ case "share":
+ $sambaconf .= <<<EOD
+create mask = 0666
+directory mask = 0777
+passdb backend = smbpasswd
+
+EOD;
+
+ $guestmode = <<<EOD
+guest ok = yes
+
+EOD;
+
+ break;
+ case "domain":
+ $sambaconf .= <<<EOD
+passdb backend = smbpasswd
+allow trusted domains = No
+dns proxy = No
+ldap ssl = no
+idmap backend = rid:{$freenas_config['samba']['workgroup']}=10000-20000
+idmap uid = 10000-20000
+idmap gid = 10000-20000
+winbind enum groups = yes
+winbind enum users = yes
+winbind use default domain = Yes
+template homedir = /mnt
+template shell = /bin/sh
+
+EOD;
+
+ $guestmode = <<<EOD
+guest ok = no
+
+EOD;
+ break;
+ case "user":
+ $sambaconf .= <<<EOD
+passdb backend = smbpasswd
+
+EOD;
+ $guestmode = <<<EOD
+guest ok = no
+
+EOD;
+ break;
+ }
+
+
+
+ foreach ($freenas_config['mounts']['mount'] as $mountent) {
+ /* Unmount filesystem if not booting mode*/
+
+ $sambaconf .= <<<EOD
+
+[{$mountent['sharename']}]
+comment = {$mountent['desc']}
+path = /mnt/{$mountent['sharename']}
+public = yes
+writeable = yes
+printable = no
+veto files = /.snap/
+{$guestmode}
+
+EOD;
+
+ if ( (is_array($freenas_config['samba']['hidemount']) && in_array($mountent['sharename'],$freenas_config['samba']['hidemount'])))
+
+ $sambaconf .= <<<EOD
+browseable = no
+
+EOD;
+
+ }
+
+ if (isset($freenas_config['samba']['recyclebin'])) {
+ $sambaconf .= <<<EOD
+vfs object = recycle
+recycle:repository = Recycle Bin
+recycle:keeptree = Yes
+recycle:versions = Yes
+
+EOD;
+ }
+
+ fwrite($fd, $sambaconf);
+ fclose($fd);
+
+ /* run nmbd and nmbd */
+
+ if (isset($freenas_config['ad']['enable'])) {
+ mwexec("/usr/local/bin/net rpc join -S {$freenas_config['ad']['ad_srv_name']} -U {$freenas_config['ad']['admin_name']}%{$freenas_config['ad']['admin_pass']}");
+ }
+
+ mwexec("/usr/local/sbin/nmbd -D -s {$g['varetc_path']}/smb.conf");
+
+ if (isset($freenas_config['ad']['enable'])) {
+ mwexec("/usr/local/sbin/winbindd -s {$g['varetc_path']}/smb.conf");
+ //mwexec("/usr/local/sbin/wbinfo --set-auth-user {$freenas_config['ad']['admin_name']}%{$freenas_config['ad']['admin_pass']}");
+ }
+
+ mwexec("/usr/local/sbin/smbd -D -s {$g['varetc_path']}/smb.conf");
+
+
+ /* TEST: Wait for samba starting */
+ sleep(2);
+
+ /* Generate the samba password file */
+ system_user_samba();
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function services_rsyncd_configure() {
+ global $freenas_config, $g;
+
+ /* kill any running rsync daemon */
+
+ sigkillbypid("{$g['varrun_path']}/rsyncd.pid", "TERM");
+
+ if (isset($freenas_config['rsyncd']['enable'])) {
+
+ if ($g['booting'])
+ echo "Starting RSYNC daemon... ";
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ return 1;
+
+ /* generate rsyncd.conf */
+ $fd = fopen("{$g['varetc_path']}/rsyncd.conf", "w");
+ if (!$fd) {
+ printf("Error: cannot open rsyncd.conf in services_rsyncd_configure().\n");
+ return 1;
+ }
+
+ $rsyncdconf = <<<EOD
+read only = {$freenas_config['rsyncd']['readonly']}
+syslog facility = local4
+list = yes
+port = {$freenas_config['rsyncd']['port']}
+pid file = {$g['varrun_path']}/rsyncd.pid
+
+EOD;
+
+ if (!empty($freenas_config['rsyncd']['maxcon'])) {
+ $rsyncdconf .= <<<EOD
+max connections = {$freenas_config['rsyncd']['maxcon']}
+
+EOD;
+ }
+
+ if (!empty($freenas_config['rsyncd']['motd'])) {
+ $rsyncdconf .= <<<EOD
+motd file = {$g['varetc_path']}/rsyncd.motd
+
+EOD;
+ }
+
+ if (isset($freenas_config['rsyncd']['rsyncd_user'])) {
+ $rsyncdconf .= <<<EOD
+uid = {$freenas_config['rsyncd']['rsyncd_user']}
+
+EOD;
+
+ }
+ else {
+ $rsyncdconf .= <<<EOD
+uid = ftp
+gid = ftp
+
+EOD;
+ }
+
+
+
+ foreach ($freenas_config['mounts']['mount'] as $mountent) {
+ /* Unmount filesystem if not booting mode*/
+
+ $rsyncdconf .= <<<EOD
+
+[{$mountent['sharename']}]
+comment = {$mountent['desc']}
+path = /mnt/{$mountent['sharename']}
+
+EOD;
+ }
+
+ fwrite($fd, $rsyncdconf);
+ fclose($fd);
+
+ // Generate MOTD file if configured
+
+ if (!empty($freenas_config['rsyncd']['motd'])) {
+ $fd = fopen("{$g['varetc_path']}/rsyncd.motd", "w");
+ if (!$fd) {
+ printf("Error: cannot open rsyncd.motd in services_rsyncd_configure().\n");
+ return 1;
+ }
+
+ $motd = <<<EOD
+{$freenas_config['rsyncd']['motd']}
+
+EOD;
+
+ fwrite($fd, $motd);
+ fclose($fd);
+ }
+
+ /* run rsync Daemon */
+ mwexec("/usr/local/bin/rsync --daemon --config={$g['varetc_path']}/rsyncd.conf");
+
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function services_nfs_configure() {
+ global $freenas_config, $g;
+
+ /* kill any running nfsd */
+
+ killbyname("rpc.statd");
+ killbyname("rpc.lockd");
+ killbypid("{$g['varrun_path']}/mountd.pid");
+ forcekillbyname("nfsd");
+ killbyname("rpcbind");
+
+
+ if (isset($freenas_config['nfs']['enable']))
+ {
+
+ if ($g['booting'])
+ echo "Starting NFS... ";
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ return 1;
+
+ /* generate exports */
+ $fd = fopen("{$g['varetc_path']}/exports", "w");
+ if (!$fd) {
+ printf("Error: cannot open exports in services_nfs_configure().\n");
+ return 1;
+ }
+
+ list($network,$subnet) =
+ explode('/', $freenas_config['nfs']['nfsnetwork']);
+
+ $subnet=gen_subnet_mask($subnet);
+
+ $a_mount = &$freenas_config['mounts']['mount'];
+
+ foreach ($a_mount as $mount)
+ {
+ $nfsconf .= <<<EOD
+/mnt/{$mount['sharename']} -alldirs -maproot=root
+EOD;
+
+ if ($freenas_config['nfs']['mapall'] == "yes")
+ {
+
+ $nfsconf .= <<<EOD
+-mapall=root
+EOD;
+
+ }
+
+ $nfsconf .= <<<EOD
+-network {$network} -mask $subnet
+
+EOD;
+
+ }
+ fwrite($fd, $nfsconf);
+ fclose($fd);
+
+ /* run rpcbind, nfsd and mountd */
+ mwexec("/usr/sbin/rpcbind");
+ mwexec("/usr/sbin/nfsd -u -t -n 4");
+ mwexec("/usr/sbin/mountd -r {$g['varetc_path']}/exports");
+ mwexec("/usr/sbin/rpc.lockd");
+ mwexec("/usr/sbin/rpc.statd");
+
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+
+}
+
+function services_ftpd_configure() {
+ global $freenas_config, $g;
+ // services_vsftpd_configure();
+ // services_pureftpd_configure();
+ services_wzdftpd_configure();
+}
+
+function services_wzdftpd_configure() {
+ global $freenas_config, $g;
+
+ /* kill any WZDFTPD */
+ killbyname("wzdftpd");
+
+ if (isset($freenas_config['ftp']['enable'])) {
+
+ if ($g['booting'])
+ echo "Starting FTP server... ";
+
+ if (! file_exists("/var/log/wzdftpd"))
+ mkdir("/var/log/wzdftpd");
+
+ if (! file_exists("{$g['varetc_path']}/wzdftpd"))
+ mkdir("{$g['varetc_path']}/wzdftpd");
+
+ /* generate wzd.cfg */
+ $fd = fopen("{$g['varetc_path']}/wzdftpd/wzd.cfg", "w");
+ if (!$fd) {
+ printf("Error: cannot open vsftpd.conf in services_vsftpd_configure().\n");
+ return 1;
+ }
+
+ $ftpconf = <<<EOD
+[GLOBAL]
+config version = 0.7.2
+backup config = true
+port = {$freenas_config['ftp']['port']}
+
+EOD;
+
+ if ($freenas_config['ftp']['pasv_min_port'] && $freenas_config['ftp']['pasv_max_port']) {
+ $ftpconf .= <<<EOD
+pasv_low_range={$freenas_config['ftp']['pasv_min_port']}
+pasv_high_range={$freenas_config['ftp']['pasv_max_port']}
+
+EOD;
+ }
+
+ $ftpconf =. <<<EOD
+
+pasv_low_range = 2500
+pasv_high_range = 3000
+pasv_ip = {$freenas_config['ftp']['pasv_address']}
+dir_message = .message
+logfile = /var/log/wzdftpd/wzd.log
+max_threads = 32
+
+backend = ${datarootdir}/wzdftpd/backends/libwzdplaintext.so > 124
+backend = ${datarootdir}/wzdftpd/backends/libwzdpam.so
+
+max_ul_speed = 0
+max_dl_speed = 0
+deny_access_files_uploaded = 1
+
+tls_certificate = /usr/local/etc/wzdftpd/wzd.pem
+sitefile_ginfo = /usr/local/etc/wzdftpd/file_ginfo.txt
+sitefile_group = /usr/local/etc/wzdftpd/file_group.txt
+sitefile_user = /usr/local/etc/wzdftpd/file_user.txt
+
+[pre_ip_check]
+localhost = allow
+
+[perms]
+site_addip = +O +G
+site_adduser = +O +G
+site_backend = +O
+site_chacl = +O
+site_change = +O +G
+site_changegrp = +O +G
+site_checkperm = +O
+site_chgrp = +O
+site_chmod = +O
+site_chown = +O
+site_chpass = *
+site_chratio = +O +G
+site_close = +O
+site_color = !=guest *
+site_delip = +O +G
+site_deluser = +O +G
+site_flags = -admin
+site_free = *
+site_ginfo = +O +G
+site_give = *
+site_group = +O
+site_groups = +O
+site_grpadd = +O
+site_grpaddip = +O
+site_grpchange = +O
+site_grpdel = +O
+site_grpdelip = +O
+site_grpkill = +O
+site_grpratio = +O
+site_grpren = +O
+site_gsinfo = +O +G
+site_help = *
+site_idle = *
+site_invite = !=guest *
+site_kick = +O
+site_kill = +O
+site_link = +O
+site_msg = +O
+site_perm = +O
+site_purge = +O +G
+site_readd = +O +G
+site_reload = +O
+site_reopen = +O
+site_rules = *
+site_rusage = +O
+site_savecfg = +O
+site_sections = +O
+site_shutdown = +O
+site_su = +O
+site_swho = +O
+site_tagline = !=guest *
+site_take = +O
+site_unlock = +O
+site_uptime = *
+site_user = +O +G
+site_users = -admin
+site_utime = *
+site_vars = +O
+site_vars_group = +O
+site_vars_user = +O
+site_version = +O
+site_who = !=guest *
+site_wipe = +O
+site_vfsls = +O
+site_vfsadd = +O
+site_vfsdel = +O
+
+[modules]
+${datarootdir}/wzdftpd/modules/libwzd_debug.so = deny
+${datarootdir}/wzdftpd/modules/libwzd_test.so = deny
+${datarootdir}/wzdftpd/modules/libwzd_sfv.so = allow
+${datarootdir}/wzdftpd/modules/libwzd_tcl.so = deny
+${datarootdir}/wzdftpd/modules/libwzd_perl.so = deny
+
+EOD;
+
+ if (empty($config['system']['zeroconf_disable'])) {
+ $ftpconf .= <<<EOD
+${datarootdir}/wzdftpd/modules/libwzd_zeroconf.so = allow
+
+[ZEROCONF]
+zeroconf_port = {$freenas_config['ftp']['port']}
+zeroconf_username = root
+zeroconf_path = /
+
+EOD;
+
+ }
+
+ $ftpconf .= <<<EOD
+[sfv]
+progressmeter = [WzD] - %3d%% Complete - [WzD]
+del_progressmeter = \[.*] - ...% Complete - \[WzD]
+incomplete_indicator = ../(incomplete)-%0
+other_completebar = [WzD] - ( %.0mM %fF - COMPLETE ) - [WzD]
+
+[plaintext]
+param = /usr/local/etc/wzdftpd/users
+
+[sections]
+ALL = /* ^([]\[A-Za-z0-9_.'() \t+-])*$
+
+[cron]
+
+[events]
+
+[custom_commands]
+site_rules = !/usr/local/etc/wzdftpd/file_rules.txt
+
+site_groups = !/usr/local/etc/wzdftpd/file_groups.txt
+site_help = !/usr/local/etc/wzdftpd/file_help.txt
+site_swho = !/usr/local/etc/wzdftpd/file_swho.txt
+site_users = !/usr/local/etc/wzdftpd/file_users.txt
+site_vfsls = !/usr/local/etc/wzdftpd/file_vfs.txt
+site_who = !/usr/local/etc/wzdftpd/file_who.txt
+
+[vfs]
+
+[messages]
+
+EOD;
+
+ if (isset($freenas_config['ftp']['banner'])) {
+ $ftpconf .= "200 = {$freenas_config['ftp']['banner']}";
+ }
+
+ fwrite($fd, $ftpconf);
+ fclose($fd);
+
+ /* run vsftpd */
+ mwexec("/usr/local/sbin/wzdftpd -f {$g['varetc_path']}/wzdftpd/wzd.cfg");
+
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function services_vsftpd_configure() {
+ global $freenas_config, $g;
+
+ /* kill any VSFTPD */
+ killbyname("vsftpd");
+
+ if (isset($freenas_config['ftp']['enable'])) {
+
+ if ($g['booting'])
+ echo "Starting FTP server... ";
+
+ /* generate vfstpd.conf */
+ $fd = fopen("{$g['varetc_path']}/vsftpd.conf", "w");
+ if (!$fd) {
+ printf("Error: cannot open vsftpd.conf in services_vsftpd_configure().\n");
+ return 1;
+ }
+
+ $ftpconf = <<<EOD
+# Standalone mode
+listen=YES
+background=YES
+listen_port={$freenas_config['ftp']['port']}
+max_clients={$freenas_config['ftp']['numberclients']}
+max_per_ip={$freenas_config['ftp']['maxconperip']}
+xferlog_enable=YES
+#vsftpd_log_file=/var/log/ftp.log
+syslog_enable=YES
+# Access rights
+anonymous_enable={$freenas_config['ftp']['anonymous']}
+local_enable={$freenas_config['ftp']['localuser']}
+write_enable=YES
+hide_file=.snap
+anon_other_write_enable=YES
+anon_upload_enable=YES
+anon_mkdir_write_enable=YES
+chroot_local_user=YES
+local_umask=066
+anon_umask=066
+chmod_enable=YES
+pasv_address={$freenas_config['ftp']['pasv_address']}
+# Features
+ls_recurse_enable=YES
+# Performance
+idle_session_timeout={$freenas_config['ftp']['timeout']}
+
+EOD;
+ if (isset($freenas_config['ftp']['banner'])) {
+ $ftpconf .= <<<EOD
+ftpd_banner={$freenas_config['ftp']['banner']}
+
+EOD;
+ }
+ else {
+ $ftpconf .= <<<EOD
+ftpd_banner=Welcome to FreeNAS FTP service
+
+EOD;
+ }
+
+ if ($freenas_config['ftp']['pasv_min_port'] && $freenas_config['ftp']['pasv_max_port']) {
+ $ftpconf .= <<<EOD
+pasv_max_port={$freenas_config['ftp']['pasv_max_port']}
+pasv_min_port={$freenas_config['ftp']['pasv_min_port']}
+
+EOD;
+ }
+
+ if ($freenas_config['ftp']['pasv_address']) {
+ $ftpconf .= <<<EOD
+pasv_address={$freenas_config['ftp']['pasv_address']}
+
+EOD;
+ }
+
+ fwrite($fd, $ftpconf);
+ fclose($fd);
+
+ /* run vsftpd */
+ mwexec("/usr/local/sbin/vsftpd {$g['varetc_path']}/vsftpd.conf");
+
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function services_pureftpd_configure() {
+
+ // Stop the pure-ftpd process and re-start it
+
+ global $freenas_config, $g;
+
+ /* kill any Pure-FTPD */
+ killbyname("pure-ftpd");
+
+ if (isset($freenas_config['ftp']['enable'])) {
+
+ if ($g['booting'])
+ echo "Starting FTP server... ";
+
+ /* Generate the banner file */
+
+ $fd = fopen("/mnt/.banner", "w");
+ if (!$fd) {
+ printf("Error: cannot open .banner in services_pureftpd_configure().\n");
+ return 1;
+ }
+
+ if (empty($freenas_config['ftp']['banner'])) {
+ $banner = <<<EOD
+Welcome to FreeNAS FTP service
+
+EOD;
+ } else {
+ $banner = <<<EOD
+{$freenas_config['ftp']['banner']}
+
+EOD;
+ }
+
+ fwrite($fd, $banner);
+ fclose($fd);
+
+
+ /* run pure-ftpd */
+
+ $cmd = "/usr/local/sbin/pure-ftpd -S {$freenas_config['ftp']['port']} -c {$freenas_config['ftp']['numberclients']} -C {$freenas_config['ftp']['maxconperip']} -I {$freenas_config['ftp']['timeout']} -M U 077:077 -B -b ";
+
+ if ( (isset($freenas_config['ftp']['anonymous'])) && (!isset($freenas_config['ftp']['localuser'])))
+ $cmd .= "-e ";
+
+ if ( (!isset($freenas_config['ftp']['anonymous'])) && (isset($freenas_config['ftp']['localuser'])))
+ $cmd .= "-E ";
+
+ if ($freenas_config['ftp']['pasv_min_port'] && $freenas_config['ftp']['pasv_max_port'])
+ $cmd .= "-p {$freenas_config['ftp']['pasv_min_port']}:{$freenas_config['ftp']['pasv_max_port']} ";
+
+ if ($freenas_config['ftp']['pasv_address'])
+ $cmd .= "-P {$freenas_config['ftp']['pasv_address']} ";
+
+ if ($freenas_config['ftp']['natmode'])
+ $cmd .= "-N ";
+
+ if ($freenas_config['ftp']['passiveip'])
+ $cmd .= "-P {$freenas_config['ftp']['passiveip']} ";
+
+ if ($freenas_config['ftp']['fxp'])
+ $cmd .= "-W ";
+
+
+ mwexec($cmd);
+
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+
+ return 0;
+}
+
+function services_smart_configure() {
+ global $config, $g;
+
+ /* kill any running smartd */
+ killbyname("smartd");
+
+ if (isset($config['system']['smart'])) {
+
+ if ($g['booting'])
+ echo "Starting smartd... ";
+
+ /* run smartd */
+ mwexec("/usr/local/sbin/smartd --logfacility=local5");
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function services_cron_configure() {
+ global $freenas_config, $g;
+
+ /* kill any running cron */
+ killbyname("cron");
+
+ /* generate crontab */
+ $fd = fopen("{$g['varetc_path']}/crontab", "w");
+
+ $crontabconf = <<<EOD
+SHELL=/bin/sh
+PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
+HOME=/var/log
+#
+#minute hour mday month wday who command
+#
+
+EOD;
+
+ if (!$fd) {
+ printf("Error: cannot open crontab in services_cron_configure().\n");
+ return 1;
+ }
+
+ if (isset($freenas_config['rsyncclient']['enable'])) {
+
+ if ($g['booting'])
+ echo "Configuring cron for rsync client... ";
+
+ if ($freenas_config['rsyncclient']['all_mins'] == "0") {
+ foreach ($freenas_config['rsyncclient']['minute'] as $minutev) {
+ if (strlen($cron_min) > 0)
+ $cron_min = $cron_min . "," . $minutev;
+ else
+ $cron_min = $minutev;
+ }
+ }
+ else
+ $cron_min = "*";
+
+
+ if ($freenas_config['rsyncclient']['all_hours'] == "0") {
+ foreach ($freenas_config['rsyncclient']['hour'] as $hourv) {
+ if (strlen($cron_hour) > 0)
+ $cron_hour = $cron_hour . "," . $hourv;
+ else
+ $cron_hour = $hourv;
+ }
+ }
+ else
+ $cron_hour = "*";
+
+ if ($freenas_config['rsyncclient']['all_days'] == "0") {
+ foreach ($freenas_config['rsyncclient']['day'] as $dayv) {
+ if (strlen($cron_day) > 0)
+ $cron_day = $cron_day . "," . $dayv;
+ else
+ $cron_day = $dayv;
+ }
+ }
+ else
+ $cron_day = "*";
+
+ if ($freenas_config['rsyncclient']['all_months'] == "0") {
+ foreach ($freenas_config['rsyncclient']['month'] as $monthv) {
+ if (strlen($cron_month) > 0)
+ $cron_month = $cron_month . "," . $monthv;
+ else
+ $cron_month = $monthv;
+ }
+ }
+ else
+ $cron_month = "*";
+
+
+ if ($freenas_config['rsyncclient']['all_weekday'] == "0") {
+ foreach ($freenas_config['rsyncclient']['weekday'] as $weekdayv) {
+ if (strlen($cron_weekday) > 0)
+ $cron_weekday = $cron_weekday . "," . $weekdayv;
+ else
+ $cron_weekday = $weekdayv;
+ }
+ }
+ else
+ $cron_weekday = "*";
+
+ $crontabconf .= <<<EOD
+{$cron_min} {$cron_hour} {$cron_day} {$cron_month} {$cron_weekday} root {$g['varrun_path']}/sync.sh
+
+EOD;
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ // Erase all variable used previously
+ unset ($cron_min, $cron_hour, $cron_day, $cron_month, $cron_weekday);
+
+ if (isset($freenas_config['shutdown']['enable'])) {
+
+ if ($g['booting'])
+ echo "Configuring cron for shutdown... ";
+
+ if ($freenas_config['shutdown']['all_mins'] == "0") {
+ foreach ($freenas_config['shutdown']['minute'] as $minutev) {
+ if (strlen($cron_min) > 0)
+ $cron_min = $cron_min . "," . $minutev;
+ else
+ $cron_min = $minutev;
+ }
+ }
+ else
+ $cron_min = "*";
+
+
+ if ($freenas_config['shutdown']['all_hours'] == "0") {
+ foreach ($freenas_config['shutdown']['hour'] as $hourv) {
+ if (strlen($cron_hour) > 0)
+ $cron_hour = $cron_hour . "," . $hourv;
+ else
+ $cron_hour = $hourv;
+ }
+ }
+ else
+ $cron_hour = "*";
+
+ if ($freenas_config['shutdown']['all_days'] == "0") {
+ foreach ($freenas_config['shutdown']['day'] as $dayv) {
+ if (strlen($cron_day) > 0)
+ $cron_day = $cron_day . "," . $dayv;
+ else
+ $cron_day = $dayv;
+ }
+ }
+ else
+ $cron_day = "*";
+
+ if ($freenas_config['shutdown']['all_months'] == "0") {
+ foreach ($freenas_config['shutdown']['month'] as $monthv) {
+ if (strlen($cron_month) > 0)
+ $cron_month = $cron_month . "," . $monthv;
+ else
+ $cron_month = $monthv;
+ }
+ }
+ else
+ $cron_month = "*";
+
+
+ if ($freenas_config['shutdown']['all_weekday'] == "0") {
+ foreach ($freenas_config['shutdown']['weekday'] as $weekdayv) {
+ if (strlen($cron_weekday) > 0)
+ $cron_weekday = $cron_weekday . "," . $weekdayv;
+ else
+ $cron_weekday = $weekdayv;
+ }
+ }
+ else
+ $cron_weekday = "*";
+
+ $crontabconf .= <<<EOD
+{$cron_min} {$cron_hour} {$cron_day} {$cron_month} {$cron_weekday} root /etc/rc.shutdown
+
+EOD;
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ fwrite($fd, $crontabconf);
+ fclose($fd);
+
+ /* run cron */
+ mwexec("/usr/sbin/cron -s");
+
+ return 0;
+
+}
+
+function services_rsyncclient_configure()
+{
+ global $freenas_config, $g;
+
+ // Generate a shell script that is used by cron
+ // Generate crontab works
+
+ if (isset($freenas_config['rsyncclient']['enable']))
+ {
+
+ if ($g['booting'])
+ echo "Generating synchronizing cron script... ";
+
+ /* generate /var/run/sync.sh script */
+ $fd = fopen("{$g['varrun_path']}/sync.sh", "w");
+ if (!$fd)
+ {
+ printf("Error: cannot open /var/run/sync.sh in services_rsyncclient_configure().\n");
+ return 1;
+ }
+
+ $syncscript = <<<EOD
+#!/bin/sh
+
+if [ -r /var/run/rsync-running ]; then
+exit
+fi
+/usr/bin/touch /var/run/rsync-running
+
+EOD;
+
+ $opt_delete="";
+ if (isset($freenas_config['rsyncclient']['opt_delete']))
+ $opt_delete = "--delete --delete-after ";
+
+ foreach ($freenas_config['rsyncclient']['sharetosync'] as $sharek => $sharev)
+ {
+ $syncscript .= <<<EOD
+/usr/local/bin/rsync -rtz {$opt_delete}rsync://{$freenas_config['rsyncclient']['rsyncserverip']}/{$sharev} /mnt/{$sharev}
+
+EOD;
+ }
+
+ $syncscript .= <<<EOD
+/bin/rm -f /var/run/rsync-running
+
+EOD;
+
+ fwrite($fd,$syncscript);
+ fclose($fd);
+
+ /* Add exectutive right to the script */
+ exec("/bin/chmod 770 {$g['varrun_path']}/sync.sh");
+
+ if ($g['booting'])
+ echo "done\n";
+ return 0;
+ }
+
+ return 0;
+}
+
+function services_afpd_configure()
+{
+ global $freenas_config, $config, $g;
+
+ /* kill any VSFTPD */
+ killbyname("afpd");
+
+ if (isset($freenas_config['afp']['enable'])) {
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ return 1;
+
+ if ($g['booting'])
+ echo "Starting AFP server... ";
+
+ if (empty($freenas_config['afp']['afpname']))
+ $afpname="-";
+ else
+ $afpname=$freenas_config['afp']['afpname'];
+
+ /* generate afpd.conf */
+ $fd = fopen("{$g['varetc_path']}/afpd.conf", "w");
+ if (!$fd) {
+ printf("Error: cannot open afpd.conf in services_afpd_configure().\n");
+ return 1;
+ }
+
+ $afpconf = <<<EOD
+{$afpname} -transall
+EOD;
+
+ if (empty($config['system']['zeroconf_disable'])) {
+ $afpconf .= <<<EOD
+ -noslp -fqdn {$config['system']['hostname']} -uamlist
+EOD;
+ } else {
+ $afpconf .= <<<EOD
+ -uamlist
+EOD;
+ }
+
+ if (isset($freenas_config['afp']['guest']) && isset($freenas_config['afp']['local']) )
+ $afpconf .= <<<EOD
+ uams_guest.so,uams_clrtxt.so,uams_dhx.so
+EOD;
+ else if (isset($freenas_config['afp']['guest']))
+ $afpconf .= <<<EOD
+ uams_guest.so
+EOD;
+ else if (isset($freenas_config['afp']['local']))
+ $afpconf .= <<<EOD
+ uams_clrtxt.so,uams_dhx.so
+EOD;
+
+ $afpconf .= <<<EOD
+ -nosavepassword -defaultvol {$g['varetc_path']}/AppleVolumes.default -systemvol {$g['varetc_path']}/AppleVolumes.system -uampath /etc/uams -guestname ftp
+
+EOD;
+ fwrite($fd, $afpconf);
+ fclose($fd);
+
+ /* generate AppleVolumes.default */
+ $fd = fopen("{$g['varetc_path']}/AppleVolumes.default", "w");
+ if (!$fd)
+ {
+ printf("Error: cannot open AppleVolumes.default in services_afpd_configure().\n");
+ return 1;
+ }
+
+ $a_mount = &$freenas_config['mounts']['mount'];
+ foreach ($a_mount as $mount)
+ {
+ $AppleVolumes .= <<<EOD
+/mnt/{$mount['sharename']} "{$mount['sharename']}"
+
+EOD;
+
+ }
+
+ fwrite($fd, $AppleVolumes);
+ fclose($fd);
+
+
+ /* run afpdpd */
+ mwexec("/usr/local/sbin/afpd -F {$g['varetc_path']}/afpd.conf");
+
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function services_nis_configure()
+{
+ global $freenas_config, $g;
+
+ return 0;
+}
+
+function services_iscsi_configure()
+{
+ global $freenas_config, $g;
+
+ if (isset($freenas_config['iscsi']['enable']))
+ {
+ if ($g['booting'])
+ echo "Starting iSCSI driver... ";
+
+ mwexec("/sbin/kldload kdload /boot/kernel/iscsi_initiator.ko");
+ mwexec("/sbin/sysctl debug.iscsi=0");
+ mwexec("/usr/local/sbin/iscontrol targetaddress={$freenas_config['iscsi']['targetaddress']} TargetName={$freenas_config['iscsi']['targetname']}");
+
+ if ($g['booting'])
+ echo "done\n";
+ }
+
+ return 0;
+}
+
+function service_zeroconf_configure() {
+ //services_mdnsresponder_configure();
+ //services_howl_configure();
+ services_avahi_configure();
+}
+
+function services_avahi_configure() {
+ global $freenas_config, $config, $g;
+
+ $service_template = <<<EOD
+<?xml version="1.0" standalone='no'?>
+<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
+<service-group>
+
+ <name replace-wildcards="yes">@SERVICE_DESC@ on %h</name>
+
+ <service>
+ <type>@TYPE@</type>
+ <port>@PORT@</port>
+ @TXT_RECORDS@
+ </service>
+
+</service-group>
+
+EOD;
+
+ /* kill any running dbus daemon */
+ sigkillbypid("{$g['varrun_path']}/dbus/dbus.pid"", "TERM");
+
+ /* kill any running avahi daemons */
+ mwexec("/usr/local/sbin/avahi-daemon -k");
+
+
+ if (isset($config['system']['zeroconf_disable']))
+ return 0;
+
+ if (! file_exists("/usr/local/etc/avahi/services"))
+ mwexec("mkdir -p /usr/local/etc/avahi/services");
+
+ if (isset($config['system']['webgui']['port'])) {
+ $webservice = str_replace("@PORT@",
+ "{$config['system']['webgui']['port']}",
+ $service_template);
+ $webservice = str_replace("@TYPE@",
+ "_http._tcp",
+ $webservice);
+ $webservice = str_replace("@SERVICE_DESC@",
+ "pfSense webGUI",
+ $webservice);
+ $webservice = str_replace("@TXT_RECORDS@",
+ "",
+ $webservice);
+
+ file_put_contents("/usr/local/etc/avahi/services/http.service", $webservice);
+ } else {
+ $webservice = str_replace("@PORT@",
+ "80",
+ $service_template);
+ $webservice = str_replace("@TYPE@",
+ "_http._tcp",
+ $webservice);
+ $webservice = str_replace("@SERVICE_DESC@",
+ "pfSense webGUI",
+ $webservice);
+ $webservice = str_replace("@TXT_RECORDS@",
+ "",
+ $webservice);
+
+ file_put_contents("/usr/local/etc/avahi/services/http.service", $webservice);
+ }
+
+
+
+ if (isset($freenas_config['afp']['enable'])) {
+ /* NOP */
+ }
+
+ if (isset($freenas_config['rsyncd']['enable'])) {
+ $rsyncservice = str_replace("@PORT@",
+ "{$config['rsyncd']['port']}",
+ $service_template);
+ $rsyncservice = str_replace("@TYPE@",
+ "_rsync._tcp",
+ $rsyncservice);
+ $rsyncservice = str_replace("@SERVICE_DESC@",
+ "Remote Sync Daemon",
+ $rsyncservice);
+ $rsyncservice = str_replace("@TXT_RECORDS@",
+ "",
+ $rsyncservice);
+
+ file_put_contents("/usr/local/etc/avahi/services/rsync.service", $rsyncservice);
+ }
+
+ if (isset($config['sshd']['enable'])) {
+ $sshservice = str_replace("@PORT@",
+ "22",
+ $service_template);
+ $sshservice = str_replace("@TYPE@",
+ "_ssh._tcp",
+ $sshservice);
+ $sshservice = str_replace("@SERVICE_DESC@",
+ "Remote Terminal",
+ $sshservice);
+ $sshservice = str_replace("@TXT_RECORDS@",
+ "",
+ $sshservice);
+
+ file_put_contents("/usr/local/etc/avahi/services/ssh.service", $sshservice);
+ }
+
+ if (isset($freenas_config['ftp']['enable'])) {
+ /* NOP */
+ }
+
+ if (isset($freenas_config['samba']['enable'])) {
+ $cifsservice = str_replace("@PORT@",
+ "139",
+ $service_template);
+ $cifsservice = str_replace("@TYPE@",
+ "_smb._tcp",
+ $cifsservice);
+ $cifsservice = str_replace("@SERVICE_DESC@",
+ "Samba Server",
+ $cifsservice);
+ $cifsservice = str_replace("@TXT_RECORDS@",
+ "",
+ $cifsservice);
+
+ file_put_contents("/usr/local/etc/avahi/services/cifs.service", $cifsservice);
+ }
+
+ if (isset($freenas_config['nfs']['enable'])) {
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ break;
+
+ $a_mount = &$freenas_config['mounts']['mount'];
+
+ foreach ($a_mount as $mount) {
+ $sharename = str_replace(" ", "", $mount['sharename']);
+ $sharename = strtolower($sharename);
+
+ $nfsservice = str_replace("@PORT@",
+ "2049",
+ $service_template);
+ $nfsservice = str_replace("@TYPE@",
+ "_nfs._tcp",
+ $nfsservice);
+ $nfsservice = str_replace("@SERVICE_DESC@",
+ "NFS Mount: {$mount['sharename']}",
+ $nfsservice);
+ $nfsservice = str_replace("@TXT_RECORDS@",
+ "path=/mnt/{$mount['sharename']}",
+ $nfsservice);
+
+ file_put_contents("/usr/local/etc/avahi/services/{$sharename}_nfs.service", $nfsservice);
+ }
+ }
+
+
+ /* run dbus */
+ mwexec("/usr/local/bin/dbus-daemon --system");
+
+ /* run avahi */
+ mwexec("/usr/local/sbin/avahi-daemon -D");
+
+ if ($g['booting'])
+ echo "done\n";
+
+ return 0;
+}
+
+function services_howl_configure()
+{
+ global $freenas_config, $config, $g;
+
+
+ /* kill any mDNSResponder */
+ killbyname("mDNSResponder");
+
+ if (isset($config['system']['zeroconf_disable']))
+ return 0;
+
+ $fd = fopen("{$g['varetc_path']}/mDNSResponder.conf", "w");
+ if (!$fd)
+ {
+ printf("Error: cannot open mDNSResponder.conf in services_howl_configure().\n");
+ return 1;
+ }
+
+ if ($config['system']['webgui']['port'])
+ {
+ $mDNSResponder = <<<EOD
+"{$config['system']['hostname']} Web Admin" _http._tcp local. {$config['system']['webgui']['port']}
+
+EOD;
+ }
+ else
+ {
+ $mDNSResponder = <<<EOD
+"{$config['system']['hostname']} Web Admin" _http._tcp local. 80
+
+EOD;
+ }
+
+
+ if (isset($freenas_config['afp']['enable']))
+ {
+ $mDNSResponder .= <<<EOD
+"{$config['system']['hostname']} AFP Server" _afpovertcp._tcp local. 548
+
+EOD;
+ }
+
+ if (isset($freenas_config['rsyncd']['enable']))
+ {
+ $mDNSResponder .= <<<EOD
+"{$config['system']['hostname']} RSYNC Server" _rsync._tcp. local. {$freenas_config['rsyncd']['port']}
+
+EOD;
+ }
+
+ if (isset($config['sshd']['enable']))
+ {
+ $mDNSResponder .= <<<EOD
+"{$config['system']['hostname']} SSH Server" _ssh._tcp local. {$config['sshd']['port']}
+
+EOD;
+ }
+
+ if (isset($freenas_config['ftp']['enable']))
+ {
+ $mDNSResponder .= <<<EOD
+"{$config['system']['hostname']} FTP Server" _ftp._tcp local. {$freenas_config['ftp']['port']}
+
+EOD;
+ }
+
+ if (isset($freenas_config['samba']['enable']))
+ {
+ $mDNSResponder .= <<<EOD
+"{$config['system']['hostname']} Samba Server" _smb._tcp local. 139
+
+EOD;
+ }
+
+ if (isset($freenas_config['nfs']['enable']))
+ {
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ break;
+
+ $a_mount = &$freenas_config['mounts']['mount'];
+
+ foreach ($a_mount as $mount)
+ {
+ $mDNSResponder .= <<<EOD
+"{$config['system']['hostname']} NFS: {$mount['sharename']}" _nfs._tcp local. 2049 path=/mnt/{$mount['sharename']}
+
+EOD;
+ }
+ }
+
+ fwrite($fd, $mDNSResponder);
+ fclose($fd);
+
+
+ /* run mDNSResponder */
+ mwexec("/usr/local/sbin/mDNSResponder -f {$g['varetc_path']}/mDNSResponder.conf");
+
+ if ($g['booting'])
+ echo "done\n";
+
+ return 0;
+}
+
+function services_mdnsresponder_configure()
+{
+ global $freenas_config, $config, $g;
+
+
+ /* kill any running snmpd */
+ sigkillbypid("{$g['varrun_path']}/mDNSResponder.pid", "TERM");
+
+
+ if (isset($config['system']['zeroconf_disable']))
+ return 0;
+
+ $fd = fopen("{$g['varetc_path']}/mDNSResponder.conf", "w");
+ if (!$fd) {
+ printf("Error: cannot open mDNSResponder.conf in services_bonjour_configure().\n");
+ return 1;
+ }
+
+ if ($config['system']['webgui']['port']) {
+ $mDNSResponder = <<<EOD
+"{$config['system']['hostname']} Web Admin"
+_http._tcp local.
+{$config['system']['webgui']['port']}
+
+EOD;
+ }
+ else {
+ $mDNSResponder = <<<EOD
+"{$config['system']['hostname']} Web Admin"
+_http._tcp local.
+80
+
+EOD;
+ }
+
+
+ if (isset($freenas_config['afp']['enable'])) {
+ $mDNSResponder .= <<<EOD
+
+"{$config['system']['hostname']} AFP Server"
+_afpovertcp._tcp local.
+548
+
+EOD;
+ }
+
+ if (isset($freenas_config['rsyncd']['enable'])) {
+ $mDNSResponder .= <<<EOD
+
+"{$config['system']['hostname']} RSYNC Server"
+_rsync._tcp. local.
+{$freenas_config['rsyncd']['port']}
+
+EOD;
+ }
+
+ if (isset($config['sshd']['enable'])) {
+ $mDNSResponder .= <<<EOD
+
+"{$freenas_config['system']['hostname']} SSH Server"
+_ssh._tcp local.
+{$config['sshd']['port']}
+
+EOD;
+ }
+
+ if (isset($freenas_config['ftp']['enable'])) {
+ $mDNSResponder .= <<<EOD
+
+"{$config['system']['hostname']} FTP Server"
+_ftp._tcp local.
+{$freenas_config['ftp']['port']}
+
+EOD;
+ }
+
+ if (isset($freenas_config['samba']['enable'])) {
+ $mDNSResponder .= <<<EOD
+
+"{$config['system']['hostname']} Samba Server"
+_smb._tcp local.
+139
+
+EOD;
+ }
+
+ if (isset($freenas_config['nfs']['enable'])) {
+
+ /* If no share configured, exit */
+ if (!is_array($freenas_config['mounts']['mount']))
+ break;
+
+ $a_mount = &$freenas_config['mounts']['mount'];
+
+ foreach ($a_mount as $mount) {
+ $mDNSResponder .= <<<EOD
+
+"{$config['system']['hostname']} NFS: {$mount['sharename']}"
+_nfs._tcp local.
+2049 path=/mnt/{$mount['sharename']}
+
+EOD;
+ }
+ }
+
+ fwrite($fd, $mDNSResponder);
+ fclose($fd);
+
+
+ /* run mDNSResponder */
+ mwexec("/usr/local/sbin/mDNSResponderPosix -b -f {$g['varetc_path']}/mDNSResponder.conf");
+
+ if ($g['booting'])
+ echo "done\n";
+
+ return 0;
+}
+?> \ No newline at end of file
diff --git a/packages/freenas/pkg/freenas_utils.inc b/packages/freenas/pkg/freenas_utils.inc
new file mode 100644
index 00000000..12c71a12
--- /dev/null
+++ b/packages/freenas/pkg/freenas_utils.inc
@@ -0,0 +1,675 @@
+<?php
+/* $Id$ */
+/*
+ utils.inc
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* returns true if $desc is a valid description (alphanum and space, _ , - , .)*/
+function is_validdesc($desc)
+{
+
+ if (!is_string($desc))
+ return false;
+
+ if (preg_match("/^[A-Za-z0-9]([A-Za-z0-9_\-\.\s]*[A-Za-z0-9])*$/", $desc))
+ return true;
+ else
+ return false;
+}
+
+/* returns true if $login is a valid login name (alphanum,dot, _ , -)*/
+function is_validlogin($login)
+{
+
+ if (!is_string($login))
+ return false;
+
+ if (preg_match("/^[A-Za-z0-9]([A-Za-z0-9_\-\.\s]*[A-Za-z0-9])*$/", $login))
+ return true;
+
+ else
+ return false;
+}
+
+/* returns true if $login is a valid share name (alphanum,dot, _ , -)*/
+function is_validsharename($sharename)
+{
+
+ if (!is_string($sharename))
+ return false;
+
+ if (preg_match("/^[A-Za-z0-9]([A-Za-z0-9_\-\.\s]*[A-Za-z0-9])*$/", $sharename))
+ return true;
+
+ else
+ return false;
+}
+
+function get_mounts_list()
+{
+ // Return list of mounted disk
+ //example: Array
+ // [0] => Array
+ // (
+ // [mp] => /mnt/ad0s1
+ // [mdisk] => ad0s1
+ // )
+
+
+ global $g;
+
+ exec("/sbin/mount",$rawdata);
+
+ $mountlist = array();
+ $i=0;
+
+ foreach ($rawdata as $line)
+ {
+ $aline = explode(" ", $line);
+
+ if ((chop($aline[0]) == "/dev/md0") || (chop($aline[0]) == "devfs") || (chop($aline[0]) == "/dev/fd0"))
+ continue;
+ $mountlist[$i]['mp']=chop($aline[2]);
+ // Get the complete name /dev/devicename
+
+ $complete=explode("/",chop($aline[0]));
+
+ $devname=$complete[2];
+
+ // Test if it's a gvinum or gmirror device
+ if ((strcmp($devname,"gvinum") == 0) || (strcmp($devname,"mirror") == 0))
+ $devname=$complete[3];
+
+ $mountlist[$i]['mdisk']=$devname;
+ $i++;
+ }
+
+ return $mountlist;
+}
+
+function get_sraid_disks_list()
+{
+ /* Return list of ALL software volume: gvinum, gmirror */
+ $disklist = array_merge((array)get_gvinum_disks_list(),(array)get_gmirror_disks_list());
+ return $disklist;
+
+}
+
+function get_gvinum_disks_list()
+{
+ /* Get information about gvinum volume */
+ global $g;
+
+ /* Return list of Software RAID disk */
+
+ //[volumename] => Array
+ // (
+ // [type] => Software RAID - gvinum
+ // [desc] => UP
+ // [size] => 6149 MB
+ // )
+
+
+ /* on envoie la commande d'affichage de la liste des volumes*/
+ exec("/sbin/gvinum list",$rawdata);
+
+ foreach ($rawdata as $line)
+ {
+
+
+ /* Separe la ligne par les espace */
+ $aline = preg_split("/\s+/", $line);
+
+ /* Récupčre la ligne commencant par 'V' */
+ if ($aline[0] != "V")
+ {
+ continue ;
+ }
+
+ $diskname = chop($aline[1]);
+
+ $disklist[$diskname]=array();
+
+ $disklist[$diskname]['type'] = "Software RAID - gvinum";
+
+ $disklist[$diskname]['size'] = "$aline[7] $aline[8]" ;
+
+ $disklist[$diskname]['desc'] = $aline[3];
+
+ }
+
+
+ return $disklist;
+}
+
+function get_gmirror_disks_list()
+{
+ /* Get information about gmirror volume */
+ global $g;
+
+
+ //[volumename] => Array
+ // (
+ // [type] => Software RAID - gmirror
+ // [desc] => COMPLETE
+ // [size] => 6149M
+ // )
+
+
+ /* Display all configured gmirror volume*/
+ exec("/sbin/gmirror list",$rawdata);
+
+ $foundname = 0 ;
+ $founddesc = 0 ;
+ $goodname = 0 ;
+
+ foreach ($rawdata as $line) {
+
+
+ /* Use space for break the line */
+ $aline = preg_split("/\s+/", $line);
+
+ // First Step: Getting the array name
+ // look for this output:
+ // Geom name: pouet
+
+ if ( (strcmp($aline[0],"Geom") == 0) && (strcmp($aline[1],"name:") == 0) ) {
+ $diskname = $aline[2];
+ $disklist[$diskname]=array();
+ $foundname = 1 ;
+ continue ;
+ }
+
+ // Second Step: Getting the array status
+ // look for this output:
+ // State: COMPLETE
+
+ if ( (strcmp($aline[0],"State:") == 0) && $foundname) {
+
+ $desc = $aline[1];
+ $disklist[$diskname]['desc'] = $desc;
+ $founddesc=1;
+ continue ;
+ }
+
+ // Third Step: Getting the array Size
+ // look for this output:
+ // Name: mirror/pouet
+ // Mediasize: 107373568 (102M)
+
+ if (preg_match("/Name: mirror\/(.*)$/", $line, $matches)) {
+ if ($matches[1]=$diskname) {
+ $goodname=1;
+ continue ;
+ }
+
+ }
+
+ if (($aline[0] = "Mediasize:") && $goodname) {
+ // extract the size between the ( )
+ preg_match("/.*\\(([^\)]*)\).*/",$aline[3],$match);
+ $disklist[$diskname]['size'] = $match[1];
+ $disklist[$diskname]['type'] = "Software RAID - gmirror";
+
+ // init the check variable for the next RAID volume
+ $foundname = 0 ;
+ $founddesc = 0 ;
+ $goodname = 0 ;
+
+ continue ;
+
+ }
+
+ }
+
+ return $disklist;
+
+}
+
+
+
+function get_ata_disks_list()
+{
+ /* Return list of ATA disk */
+
+ //[ad0] => Array
+ // (
+ // [type] => IDE
+ // [desc] => QUANTUM FIREBALL EX6.4A/A0A.0D00
+ // [size] => 6149MB
+ // )
+
+
+ global $g;
+
+ /* Recupere le dmesg */
+ exec("/sbin/dmesg",$rawdmesg);
+
+ $disklist = array();
+
+ /******* Getting IDE disk informations *******/
+
+ exec("/sbin/atacontrol list",$rawdata);
+
+ foreach ($rawdata as $line) {
+
+ /* Separe la ligne par les espace */
+ $aline = preg_split("/\s+/", $line);
+
+ /* Si ATA alors NEXT */
+ if ($aline[0] == "ATA")
+ continue ;
+
+ $diskname = chop($aline[2]);
+
+ /* Exlude CDROM (acdX) and Empty (no) */
+ if (!preg_match("/^(acd)/", $diskname ) & $diskname != "no") {
+
+ $disklist[$diskname]=array();
+
+ $disklist[$diskname]['type'] = "IDE";
+
+ /* Match the description witch is include between < and > */
+
+ preg_match("/.*\<([^>]*)>.*/",$line,$match);
+
+ $disklist[$diskname]['desc'] = $match[1];
+
+ /* Looking for the disk size */
+ foreach ($rawdmesg as $dmesgline) {
+
+ /* Take only the first dmesg line */
+ if (!$disklist[$diskname]['size']) {
+
+ /* Separe la ligne par les espace */
+ $dmesgtab = explode(" ", $dmesgline);
+ $dmesgtab[0] = rtrim($dmesgtab[0],":");
+ if ($dmesgtab[0]!="" &&(strcasecmp($dmesgtab[0],$diskname) == 0))
+ $disklist[$diskname]['size'] = $dmesgtab[1];
+ }
+ }
+
+ }
+
+ }
+ return $disklist;
+}
+
+
+function get_scsi_disks_list()
+{
+ /* Recupere la liste des disques SCSI */
+
+ //[ad0] => Array
+ // (
+ // [type] => IDE
+ // [desc] => QUANTUM FIREBALL EX6.4A/A0A.0D00
+ // [size] => 6149MB
+ // )
+
+
+ global $g;
+
+ /* Recupere le dmesg */
+ exec("/sbin/dmesg",$rawdmesg);
+
+ /* on envoie la commande d'affichage de la liste des disques*/
+ exec("/sbin/camcontrol devlist",$rawdata);
+
+ foreach ($rawdata as $line) {
+
+ /* Get information include between parenthese: (pass0,da0) or (da0,pass0)*/
+
+ preg_match("/.*\(([^>]*)\).*/",$line,$match);
+
+ /* Sépare le resultat par la virgule */
+ $temp = preg_split("/,/", $match[1]);
+
+ // Check if diskname is the first (da0,pass0) or the second (pass0,da0) arguement
+ $diskname = $temp[1];
+ if ($diskname[0] == "p")
+ $diskname = $temp[0];
+
+ /* On exlus les lecteurs cd */
+ if (!preg_match("/^(cd)/", $diskname )) {
+ $disklist[$diskname]=array();
+ $disklist[$diskname]['type'] = "SCSI";
+ /* Recupčre la description: ce qu'il y a entre < et > */
+
+ preg_match("/.*\<([^>]*)>.*/",$line,$match);
+
+ $disklist[$diskname]['desc'] = $match[1];
+
+ /* Looking for the disk size */
+ foreach ($rawdmesg as $dmesgline) {
+ /* Separe la ligne par les espace */
+ $dmesgtab = explode(" ", $dmesgline);
+ $dmesgtab[0] = rtrim($dmesgtab[0],":");
+ if ($dmesgtab[0]!="" &&(strcasecmp($dmesgtab[0],$diskname) == 0))
+ $disklist[$diskname]['size'] = $dmesgtab[1];
+
+ }
+
+ }
+ }
+ return $disklist;
+
+}
+
+function get_hraid_disks_list()
+{
+ /* Recupere la liste des disques RAID */
+
+ $kerneldisks = explode(" ", trim(preg_replace("/kern.disks: /", "", exec("/sbin/sysctl kern.disks"))));
+
+ /* Recupere la liste des disques ATA et SCSI */
+
+ $diskdetected = array_merge((array)get_ata_disks_list(),(array)get_scsi_disks_list());
+
+ /* Recupere le dmesg */
+ exec("/sbin/dmesg",$rawdmesg);
+
+
+ foreach ($kerneldisks as $diskname) {
+ $allready=1;
+
+ // Check of this entry is IDE or SCSI (allready detected)
+ foreach ($diskdetected as $diskfoundk => $diskfoundv) {
+
+ if (strcasecmp($diskfoundk,$diskname) == 0)
+ $allready=0;
+ }
+
+ if ($allready) {
+
+ /* If not an IDE and SCSI disk */
+ $disklist[$diskname]=array();
+
+ $disklist[$diskname]['type'] = "RAID";
+
+ /* Looking for the disk size in the dmesg */
+ foreach ($rawdmesg as $dmesgline) {
+ /* Separe la ligne par les espace */
+ $dmesgtab = explode(" ", $dmesgline);
+ $dmesgtab[0] = rtrim($dmesgtab[0],":");
+ // si la ligne commence par le nom du disque: attention il y a 2 lignes
+ if ($dmesgtab[0]!="" &&(strcasecmp($dmesgtab[0],$diskname) == 0)) {
+ // the first line as this example "aacd0: <RAID 5> on aac0"
+
+ if (strcasecmp(substr($dmesgtab[1], 0, 1),"<") == 0) {
+ /* Match the description witch is include between < and > */
+ preg_match("/.*\<([^>]*)>.*/",$dmesgline,$match);
+ $disklist[$diskname]['desc'] = $match[1];
+ }
+ else {
+ // si c'est la deuxieme ligne, elle ressemble a "aacd0: 138850MB (284365824 sectors)"
+ $disklist[$diskname]['size'] = $dmesgtab[1];
+ }
+
+ }
+ }
+ }
+
+ }
+
+ return $disklist;
+}
+
+function get_physical_disks_list()
+{
+ /* Return list of ALL disk: physical, hardware RAID and Software RAID disk */
+ $disklist = array_merge((array)get_ata_disks_list(),(array)get_scsi_disks_list(),(array)get_hraid_disks_list());
+ return $disklist;
+
+}
+
+function get_all_disks_list()
+{
+ /* Return list of ALL disk: physical, hardware RAID and Software RAID disk */
+ $disklist = array_merge((array)get_ata_disks_list(),(array)get_scsi_disks_list(),(array)get_hraid_disks_list(), (array)get_sraid_disks_list());
+ return $disklist;
+
+}
+
+function get_disks_size($diskname)
+{
+ /* Return size of the disk */
+ $disklist=get_physical_disks_list();
+
+ $disksize=0;
+
+ foreach ($disklist as $diskk => $diskv) {
+ if (strcmp($diskk,$diskname)==0)
+ $disksize=$diskv['size'];
+ }
+ return $disksize;
+
+}
+
+function get_cdrom_list()
+{
+ /* Return list of IDE AND SCSI CDROM */
+ // exemple: Array
+ // [acd0] => Array
+ // (
+ // [type] => IDE
+ // [desc] => TDK CDRW241040B/57S2
+ // )
+
+
+
+ global $g;
+
+ /* Recupere la liste des disques IDE */
+ exec("/sbin/atacontrol list",$rawdata);
+
+ /* Recupere le dmesg */
+ exec("/sbin/dmesg",$rawdmesg);
+
+ $disklist = array();
+
+ /* Variable $i utilisé pour l'index du tableau */
+ $i=0;
+ foreach ($rawdata as $line) {
+
+
+ /* Separe la ligne par les espace */
+ $aline = preg_split("/\s+/", $line);
+
+ /* Si ATA alors NEXT */
+ if ($aline[0] == "ATA")
+ continue ;
+
+ $diskname = chop($aline[2]);
+
+ /* Exlude disk (adX) and Empty (no) */
+ if (!preg_match("/^(ad)/", $diskname ) & $diskname != "no") {
+
+ $disklist[$diskname]=array();
+
+ // $disklist[$i]['name'] = chop($aline[2]);
+
+
+ $disklist[$diskname]['type'] = "IDE";
+
+ /* Match the description witch is include between < and > */
+
+ preg_match("/.*\<([^>]*)>.*/",$line,$match);
+
+ $disklist[$diskname]['desc'] = $match[1];
+
+
+ $i++;
+
+ }
+
+ }
+
+ /* Get the SCSI disk list */
+
+ /* Cleaning used variable and initialize array */
+ unset($rawdata);
+ unset($dmesgtab);
+ reset($rawdmesg);
+
+ /* Get the result of the command camcontrol*/
+ exec("/sbin/camcontrol devlist",$rawdata);
+
+ foreach ($rawdata as $line) {
+
+ /* Get information include between parenthese: (pass0,da0) or (da0,pass0)*/
+
+ preg_match("/.*\(([^>]*)\).*/",$line,$match);
+
+ /* Sépare le resultat par la virgule */
+ $temp = preg_split("/,/", $match[1]);
+
+ // Check if diskname is the first (da0,pass0) or the second (pass0,da0) arguement
+ $diskname = $temp[1];
+ if ($diskname[0] == "p")
+ $diskname = $temp[0];
+
+ /* On exlus les lecteurs disque dur da */
+ if (!preg_match("/^(da)/", $diskname )) {
+ $disklist[$diskname]=array();
+ $disklist[$diskname]['type'] = "SCSI";
+ /* Recupčre la description: ce qu'il y a entre < et > */
+
+ preg_match("/.*\<([^>]*)>.*/",$line,$match);
+
+ $disklist[$diskname]['desc'] = $match[1];
+
+ $i++;
+
+ }
+
+ }
+
+ return $disklist;
+}
+
+function freenas_install($src,$dst)
+{
+
+ // Creating source directory
+ passthru("/bin/mkdir /mnt/src");
+
+ // Mount the source function is_cdrom must BE CREATED!!!!
+
+ if (is_cdrom($src))
+ {
+ echo "Mount CDROM:\n";
+ passthru("/sbin/mount_cd9660 /dev/$src /mnt/src");
+ }
+ else
+ {
+ echo "Mount disk:\n";
+ passthru("/sbin/mount -t ufs /dev/$src /mnt/src");
+ }
+
+
+ echo "Erasing primary partitions:\n";
+ passthru("/bin/dd if=/dev/zero of=/dev/$dst bs=1k count=20");
+
+ echo "Creation 1 booting primary parition:\n";
+ passthru("/sbin/fdisk -BI -b /boot/boot0 $dst");
+
+ /* echo "Installing bootloader:\n";
+ passthru("/usr/sbin/boot0cfg -B -b /boot/boot0 $dst"); */
+
+ echo "Erasing FreeBSD partition on the primary:\n";
+ passthru("/bin/dd if=/dev/zero of=/dev/" . escapeshellarg($dst) . "s1 bs=32k count=16");
+
+ echo "Creating FreeBSD partition:\n";
+ passthru("/sbin/bsdlabel -B -w -b /boot/boot " . escapeshellarg($dst) ."s1 auto");
+
+ echo "Modify partition information:\n";
+
+ /* Generation de la table des partitions dans un fichier temp */
+
+ passthru("/sbin/bsdlabel " . escapeshellarg($dst) ."s1 > label.tmp");
+
+ /* copie de ce fichier dans un tableau*/
+ $tableau = file("label.tmp");
+
+ // Ouverture du fichier en mode ajout
+ $handle = fopen("label.tmp", 'a');
+
+ while(list(,$val) = each($tableau))
+ {
+ // Si la ligne contient le mot "unused"
+
+ if (ereg ("unused",$val))
+ {
+ // On remplace c: par a:
+ $val = ereg_replace ("c:","a:", $val);
+ // On remplace unused par 4.2BSD
+ $val = ereg_replace ("unused","4.2BSD", $val);
+ // On ajoute cette ligne ŕ la fin du fichier
+ fwrite($handle, $val);
+ }
+ }
+ // Fermeture du fichier
+ fclose($handle);
+
+ // On injecte la nouvelle table des paritions
+ passthru("/sbin/bsdlabel -R -B " . escapeshellarg($dst) ."s1 label.tmp");
+
+ echo "Creating filesystem:\n";
+ passthru("/sbin/newfs /dev/" . escapeshellarg($dst) . "s1");
+
+ echo "Creation temp mouting point:\n";
+ passthru("/bin/mkdir /mnt/src");
+
+ echo "Mount disk:\n";
+ passthru("/sbin/mount /dev/" . escapeshellarg($dst) . "s1 /mnt/dst");
+
+ echo "Installation:\n";
+
+ passthru("/bin/cp -pr /mnt/src/boot /mnt/dst");
+ passthru("/bin/cp /mnt/src/cf.gz /mnt/dst/mfsroot.gz");
+
+ if ($src == CDROM)
+ passthru("/bin/rm -f /mnt/dst/boot/cdloader");
+
+ passthru("mkdir /mnt/dst/conf");
+ passthru("/bin/cp /conf/config.xml /mnt/dst/conf/");
+
+
+ /* demontage des disques */
+ passthru("/sbin/umount /mnt/dst");
+ passthru("/sbin/umount /mnt/src");
+ passthru("/bin/rm -rf /mnt/src");
+ passthru("/bin/rm -rf /mnt/dst");
+
+}
+?> \ No newline at end of file
diff --git a/packages/freenas/www/diag_ad_infos.php b/packages/freenas/www/diag_ad_infos.php
new file mode 100644
index 00000000..b877c514
--- /dev/null
+++ b/packages/freenas/www/diag_ad_infos.php
@@ -0,0 +1,156 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("Active Directory Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_ad_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), true, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ if (! isset($freenas_config['ad']['enable'])) {
+ echo "<strong>AD Authentication disable</strong><br />";
+ } else {
+ echo "<pre style=\"font-size: medium;\">";
+ echo "<strong>Accessiblity test to MS domain:</strong><br />";
+ echo htmlspecialchars("Results for net rpc testjoin:") . "<br />";
+
+ exec("/usr/local/bin/net rpc testjoin",$rawdata);
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($rawdata);
+
+ echo "<br />";
+ echo htmlspecialchars("Ping winbindd to see if it is alive:") . "<br />";
+
+ exec("/usr/local/bin/wbinfo -p",$rawdata);
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($rawdata);
+
+ echo "<br />";
+ echo htmlspecialchars("Check shared secret:") . "<br />";
+
+ exec("/usr/local/bin/wbinfo -t",$rawdata);
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($rawdata);
+
+ echo "<br>";
+ echo "</pre>";
+ }
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_ataidle_infos.php b/packages/freenas/www/diag_ataidle_infos.php
new file mode 100644
index 00000000..cffccc8f
--- /dev/null
+++ b/packages/freenas/www/diag_ataidle_infos.php
@@ -0,0 +1,145 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("ATAidle Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_ataidle_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), true, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ echo "<pre style=\"font-size: medium;\">";
+ $disklist=get_ata_disks_list();
+
+ echo "<strong>List of Advanced ATA capabilities on all ATA disk:</strong><br />";
+ foreach ($disklist as $disknamek => $disknamev)
+ {
+
+ /* Found the channel and device number from the /dev name */
+ /* Divise the number by 2, the interger is the channel number, the rest is the device */
+
+ echo htmlspecialchars("Results for $disknamek:") . "<br />";
+ $value=trim($disknamek,'ad');
+
+ $value=intval($value);
+ $channel = $value/2;
+ $device=$value % 2;
+ $channel=intval($channel);
+
+ exec("/usr/local/sbin/ataidle $channel $device",$rawdata);
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($rawdata);
+ }
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_disk_infos.php b/packages/freenas/www/diag_disk_infos.php
new file mode 100644
index 00000000..7cf1d71a
--- /dev/null
+++ b/packages/freenas/www/diag_disk_infos.php
@@ -0,0 +1,141 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("Disk Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_disk_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), true, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ exec("/sbin/atacontrol list",$iderawdata);
+
+ echo "<pre style=\"font-size: medium;\">";
+
+ echo "<strong>List of detected ATA disks:</strong><br />";
+ foreach ($iderawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+
+ unset ($line);
+
+ exec("/sbin/camcontrol devlist",$scsirawdata);
+
+ echo "<strong>List of detected SCSI disks:</strong><br />";
+ foreach ($scsirawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+
+ }
+
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_daemon.php b/packages/freenas/www/diag_fn_logs_daemon.php
new file mode 100644
index 00000000..d320caa9
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_daemon.php
@@ -0,0 +1,109 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("Daemon"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear'])
+{
+ exec("/usr/sbin/clog -i -s 262144 /var/log/daemon.log");
+ /* redirect to avoid reposting form data on refresh */
+ pfSenseHeader("diag_logs_daemon.php");
+ exit;
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_daemon.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), true, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> Daemon log entries
+ </td>
+ </tr>
+ <?php dump_clog("/var/log/daemon.log", $nentries); ?>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <input name="clear" type="submit" class="formbtn" value="Clear log" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_ftp.php b/packages/freenas/www/diag_fn_logs_ftp.php
new file mode 100644
index 00000000..6f29e986
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_ftp.php
@@ -0,0 +1,109 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("FTP"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear'])
+{
+ exec("/usr/sbin/clog -i -s 262144 /var/log/ftp.log");
+ /* redirect to avoid reposting form data on refresh */
+ pfSenseHeader("diag_fn_logs_ftp.php");
+ exit;
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_ftp.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), true, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> FTP log entries
+ </td>
+ </tr>
+ <?php dump_clog("/var/log/ftp.log", $nentries); ?>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <input name="clear" type="submit" class="formbtn" value="Clear log" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_rsyncd.php b/packages/freenas/www/diag_fn_logs_rsyncd.php
new file mode 100644
index 00000000..ac3b458a
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_rsyncd.php
@@ -0,0 +1,108 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("RSYNCD"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 262144 /var/log/rsyncd.log");
+ /* redirect to avoid reposting form data on refresh */
+ pfSenseHeader("diag_fn_logs_rsyncd.php");
+ exit;
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_rsyncd.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), true, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> RSYNCD log entries
+ </td>
+ </tr>
+ <?php dump_clog("/var/log/rsyncd.log", $nentries); ?>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <input name="clear" type="submit" class="formbtn" value="Clear log" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_samba.php b/packages/freenas/www/diag_fn_logs_samba.php
new file mode 100644
index 00000000..679c8826
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_samba.php
@@ -0,0 +1,165 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("Samba"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/bin/cp /dev/null /var/log/samba/log.nmbd");
+ exec("/bin/cp /dev/null /var/log/samba/log.smbd");
+ exec("/bin/cp /dev/null /var/log/samba/log.winbindd");
+ /* redirect to avoid reposting form data on refresh */
+ pfSenseHeader("diag_fn_logs_samba.php");
+ exit;
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_samba.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), true, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> nmbd service log entries
+ </td>
+ </tr>
+ <?php
+ if (file_exists("/var/log/samba/log.nmbd")) {
+ exec("cat /var/log/samba/log.nmbd", $rawlog);
+ } else {
+ $rawlog=array("No logs");
+ }
+ ?>
+ <?php foreach ($rawlog as $log) { ?>
+ <tr>
+ <td class="listr" nowrap>
+ <pre><?php echo htmlspecialchars($log); } ?></pre>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <?php unset ($rawlog); ?>
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> smbd service log entries
+ </td>
+ </tr>
+ <?php
+ if (file_exists("/var/log/samba/log.smbd")) {
+ exec("cat /var/log/samba/log.smbd", $rawlog);
+ } else {
+ $rawlog=array("No logs");
+ }
+ ?>
+ <?php foreach ($rawlog as $log) { ?>
+ <tr>
+ <td class="listr" nowrap>
+ <pre><?php echo htmlspecialchars($log); } ?></pre>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> winbindd service log entries
+ </td>
+ </tr>
+ <?php
+ if (file_exists("/var/log/samba/log.winbindd")) {
+ exec("cat /var/log/samba/log.winbindd", $rawlog);
+ } else {
+ $rawlog=array("No logs");
+ }
+ ?>
+ <?php foreach ($rawlog as $log) { ?>
+ <tr>
+ <td class="listr" nowrap>
+ <pre><?php echo htmlspecialchars($log); } ?></pre>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <input name="clear" type="submit" class="formbtn" value="Clear log" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_settings.php b/packages/freenas/www/diag_fn_logs_settings.php
new file mode 100644
index 00000000..1f4ada67
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_settings.php
@@ -0,0 +1,296 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("Settings"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$pconfig['reverse'] = isset($config['syslog']['reverse']);
+$pconfig['nentries'] = $config['syslog']['nentries'];
+$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
+$pconfig['filter'] = isset($config['syslog']['filter']);
+$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
+$pconfig['portalauth'] = isset($config['syslog']['portalauth']);
+$pconfig['vpn'] = isset($config['syslog']['vpn']);
+$pconfig['system'] = isset($config['syslog']['system']);
+$pconfig['enable'] = isset($config['syslog']['enable']);
+$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']);
+$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']);
+$pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']);
+$pconfig['webservlogs'] = isset($config['syslog']['webservlogs']);
+
+$pconfig['sshd'] = isset($config['syslog']['sshd']);
+$pconfig['ftp'] = isset($config['syslog']['ftp']);
+$pconfig['rsyncd'] = isset($config['syslog']['rsyncd']);
+$pconfig['smartd'] = isset($config['syslog']['smartd']);
+$pconfig['daemon'] = isset($config['syslog']['daemon']);
+
+if (!$pconfig['nentries'])
+ $pconfig['nentries'] = 50;
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) {
+ $input_errors[] = gettext("A valid IP address must be specified.");
+ }
+ if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 2000)) {
+ $input_errors[] = gettext("Number of log entries to show must be between 5 and 2000.");
+ }
+
+ if (!$input_errors) {
+ $config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
+ $config['syslog']['nentries'] = (int)$_POST['nentries'];
+ $config['syslog']['remoteserver'] = $_POST['remoteserver'];
+ $config['syslog']['filter'] = $_POST['filter'] ? true : false;
+ $config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
+ $config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
+ $config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
+ $config['syslog']['system'] = $_POST['system'] ? true : false;
+ $config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false;
+ $config['syslog']['enable'] = $_POST['enable'] ? true : false;
+ $oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
+ $config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
+ $config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
+ $config['syslog']['webservlogs'] = $_POST['webservlogs'] ? true : false;
+ $config['syslog']['sshd'] = $_POST['sshd'] ? true : false;
+ $config['syslog']['ftp'] = $_POST['ftp'] ? true : false;
+ $config['syslog']['rsyncd'] = $_POST['rsyncd'] ? true : false;
+ $config['syslog']['smartd'] = $_POST['smartd'] ? true : false;
+ $config['syslog']['daemon'] = $_POST['daemon'] ? true : false;
+ if($config['syslog']['enable'] == false)
+ unset($config['syslog']['remoteserver']);
+
+ write_config();
+
+ $retval = 0;
+ config_lock();
+ $retval = system_syslogd_start();
+ if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
+ $retval |= filter_configure();
+ config_unlock();
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script language="JavaScript" type="text/javascript">
+<!--
+function enable_change(enable_over) {
+ endis = !(document.iform.enable.checked || enable_over);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ if (document.iform.enable.checked || enable_over) {
+ document.iform.remoteserver.disabled = 0;
+ document.iform.filter.disabled = 0;
+ document.iform.dhcp.disabled = 0;
+ document.iform.portalauth.disabled = 0;
+ document.iform.vpn.disabled = 0;
+ document.iform.system.disabled = 0;
+ document.iform.webservlogs.disabled = 0;
+ document.iform.sshd.disabled = 0;
+ document.iform.ftp.disabled = 0;
+ document.iform.rsyncd.disabled = 0;
+ document.iform.smartd.disabled = 0;
+ document.iform.daemon.disabled = 0;
+
+ } else {
+ document.iform.remoteserver.disabled = 1;
+ document.iform.filter.disabled = 1;
+ document.iform.dhcp.disabled = 1;
+ document.iform.portalauth.disabled = 1;
+ document.iform.vpn.disabled = 1;
+ document.iform.system.disabled = 1;
+ document.iform.webservlogs.disabled = 1;
+ document.iform.sshd.disabled = 1;
+ document.iform.ftp.disabled = 1;
+ document.iform.rsyncd.disabled = 1;
+ document.iform.smartd.disabled = 1;
+ document.iform.daemon.disabled = 1;
+ }
+
+ /* color adjustments */
+ document.iform.remoteserver.style.backgrounColor = color;
+ document.iform.filter.style.backgrounColor = color;
+ document.iform.dhcp.style.backgrounColor = color;
+ document.iform.portalauth.style.backgrounColor = color;
+ document.iform.vpn.style.backgrounColor = color;
+ document.iform.system.style.backgrounColor = color;
+ document.iform.webservlogs.style.backgrounColor = color;
+ document.iform.sshd.style.backgrounColor = color;
+ document.iform.ftp.style.backgrounColor = color;
+ document.iform.rsyncd.style.backgrounColor = color;
+ document.iform.smartd.style.backgrounColor = color;
+ document.iform.daemon.style.backgrounColor = color;
+}
+// -->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_settings.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), true, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable"> <input name="reverse" class="formfld" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?> />
+ <strong><?=gettext("Show log entries in reverse order (newest entries on top)");?></strong></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable"><?=gettext("Number of log entries to show");?>:
+ <input name="nentries" id="nentries" type="text" class="formfld unknown" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>" /></td>
+ </tr>
+ <tr>
+ <td valign="top" class="vtable">&nbsp;</td>
+ <td class="vtable"> <input name="logdefaultblock" class="formfld" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?> />
+ <strong><?=gettext("Log packets blocked by the default rule");?></strong><br />
+ <?=gettext("Hint: packets that are blocked by the
+ implicit default block rule will not be logged anymore
+ if you uncheck this option. Per-rule logging options are not affected.");?></td>
+ </tr>
+ <tr>
+ <td valign="top" class="vtable">&nbsp;</td>
+ <td class="vtable"> <input name="rawfilter" class="formfld" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?> />
+ <strong><?=gettext("Show raw filter logs");?></strong><br />
+ <?=gettext("Hint: If this is checked, filter logs are shown as generated by the packet filter, without any formatting. This will reveal more detailed information.");?> </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable"> <input name="disablelocallogging" class="formfld" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked"; ?> onclick="enable_change(false)" />
+ <strong><?=gettext("Disable writing log files to the local disk");?></strong></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable"> <input name="enable" class="formfld" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onclick="enable_change(false)" />
+ <strong><?=gettext("Enable syslog'ing to remote syslog server");?></strong></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Remote syslog
+ server</td>
+ <td width="78%" class="vtable">
+ <input name="remoteserver" id="remoteserver" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>" />
+ <br /><?=gettext("IP address of remote syslog server");?>
+ <br /><br />
+ <input name="system" id="system" class="formfld" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked=\"checked\""; ?> />
+ <?=gettext("system events");?><br />
+ <input name="filter" id="filter" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked=\"checked\""; ?> />
+ <?=gettext("firewall events");?><br />
+ <input name="dhcp" id="dhcp" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked=\"checked\""; ?> />
+ <?=gettext("DHCP service events");?><br />
+ <input name="portalauth" id="portalauth" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['portalauth']) echo "checked=\"checked\""; ?> />
+ <?=gettext("Portal Auth");?><br />
+ <input name="vpn" id="vpn" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked=\"checked\""; ?> />
+ <?=gettext("PPTP VPN events");?><br />
+ <input name="webservlogs" id="webservlogs" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['webservlogs']) echo "checked=\"checked\""; ?> />
+ <?=gettext("webConfigurator Logs");?><br />
+ <input name="sshd" id="sshd" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['sshd']) echo "checked=\"checked\""; ?> />
+ <?=gettext("SSHD events");?><br />
+ <input name="ftp" id="ftp" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['ftp']) echo "checked=\"checked\""; ?> />
+ <?=gettext("FTP events");?><br />
+ <input name="rsyncd" id="rsyncd" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['rsyncd']) echo "checked=\"checked\""; ?> />
+ <?=gettext("RSYNCD events");?><br />
+ <input name="smartd" id="smartd" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['smartd']) echo "checked=\"checked\""; ?> />
+ <?=gettext("SMARTD events");?><br />
+ <input name="daemon" id="daemon" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['daemon']) echo "checked=\"checked\""; ?> />
+ <?=gettext("Daemon events");?><br />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%"> <input id="submit" name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" height="53" valign="top">&nbsp;</td>
+ <td width="78%"><strong><span class="red"><?=gettext("Note");?>:</span></strong><br />
+ <?=gettext("
+ syslog sends UDP datagrams to port 514 on the specified
+ remote syslog server. Be sure to set syslogd on the
+ remote server to accept syslog messages from {$g['product_name']}.
+ ");?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<script language="JavaScript" type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_smartd.php b/packages/freenas/www/diag_fn_logs_smartd.php
new file mode 100644
index 00000000..c5e9cb88
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_smartd.php
@@ -0,0 +1,109 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("SMARTD"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear'])
+{
+ exec("/usr/sbin/clog -i -s 262144 /var/log/smartd.log");
+ /* redirect to avoid reposting form data on refresh */
+ pfSenseHeader("diag_fn_logs_smartd.php");
+ exit;
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_smartd.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), true, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> SmartD log entries
+ </td>
+ </tr>
+ <?php dump_clog("/var/log/smartd.log", $nentries); ?>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <input name="clear" type="submit" class="formbtn" value="Clear log" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_fn_logs_sshd.php b/packages/freenas/www/diag_fn_logs_sshd.php
new file mode 100644
index 00000000..56c6147a
--- /dev/null
+++ b/packages/freenas/www/diag_fn_logs_sshd.php
@@ -0,0 +1,108 @@
+<?php
+/* $Id$ */
+/*
+ diag_logs_settings.php
+ Copyright (C) 2004 Scott Ullrich
+ All rights reserved.
+
+ originially part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("System logs"),
+ gettext("SSHD"));
+
+require("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 262144 /var/log/sshd.log");
+ /* redirect to avoid reposting form data on refresh */
+ pfSenseHeader("diag_logs_sshd.php");
+ exit;
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="diag_fn_logs_sshd.php" method="post" name="iform" id="iform">
+<div id="inputerrors"></div>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php");
+ $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php");
+ $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php");
+ $tab_array[] = array(gettext("SSHD"), true, "diag_fn_logs_sshd.php");
+ $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php");
+ $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php");
+ $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php");
+ display_top_tabs($tab_array);?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic">
+ Last <?=$nentries;?> SSHD log entries
+ </td>
+ </tr>
+ <?php dump_clog("/var/log/sshd.log", $nentries); ?>
+ <tr>
+ <td align="left" valign="top" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <input name="clear" type="submit" class="formbtn" value="Clear log" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_iscsi_infos.php b/packages/freenas/www/diag_iscsi_infos.php
new file mode 100644
index 00000000..e90bf8ed
--- /dev/null
+++ b/packages/freenas/www/diag_iscsi_infos.php
@@ -0,0 +1,133 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("iSCSI Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_iscsi_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), true, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ if (! isset($freenas_config['iscsi']['enable'])) {
+ echo "<strong>iSCSI initiator disabled</strong><br />";
+ } else {
+ echo "<pre style=\"font-size: medium;\">";
+ echo "<strong>Show the list of available target Name on the iSCSI target</strong><br>";
+
+ exec("/usr/local/sbin/iscontrol -d targetaddress={$freenas_config['iscsi']['targetaddress']}",$rawdata);
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br>";
+ }
+ unset ($rawdata);
+ echo "</pre>";
+ }
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_mounts_infos.php b/packages/freenas/www/diag_mounts_infos.php
new file mode 100644
index 00000000..36bbec52
--- /dev/null
+++ b/packages/freenas/www/diag_mounts_infos.php
@@ -0,0 +1,128 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("Mount Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_mounts_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), true, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ echo "<pre style=\"font-size: medium;\">";
+ echo "<strong>List of mounted point:</strong><br />";
+ exec("/sbin/mount",$mountrawdata);
+ foreach ($mountrawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($line);
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_part_infos.php b/packages/freenas/www/diag_part_infos.php
new file mode 100644
index 00000000..7201f11c
--- /dev/null
+++ b/packages/freenas/www/diag_part_infos.php
@@ -0,0 +1,134 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("Partition Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_part_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), true, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ echo "<pre style=\"font-size: medium;\">";
+
+ $disklist = get_physical_disks_list();
+
+ echo "<strong>List of partition on all detected disk:</strong><br />";
+ foreach ($disklist as $disknamek => $disknamev)
+ {
+ exec("/sbin/fdisk $disknamek",$fdiskrawdata);
+ foreach ($fdiskrawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($fdiskrawdata);
+ }
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_raid_infos.php b/packages/freenas/www/diag_raid_infos.php
new file mode 100644
index 00000000..b469aa52
--- /dev/null
+++ b/packages/freenas/www/diag_raid_infos.php
@@ -0,0 +1,135 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("RAID Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_raid_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), true, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ echo "<pre style=\"font-size: medium;\">";
+ echo "<strong>Software RAID - gmirror status:</strong><br />";
+ exec("/sbin/gmirror list",$rawdata);
+ foreach ($rawdata as $line) {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($line);
+ unset ($rawdata);
+
+ echo "<strong>Software RAID - gvinum status:</strong><br />";
+ exec("/sbin/gvinum list",$rawdata);
+ foreach ($rawdata as $line) {
+ echo htmlspecialchars($line) . "<br>";
+ }
+ unset ($line);
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_smart_infos.php b/packages/freenas/www/diag_smart_infos.php
new file mode 100644
index 00000000..9a43e210
--- /dev/null
+++ b/packages/freenas/www/diag_smart_infos.php
@@ -0,0 +1,133 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("SMART Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_smart_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), true, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ echo "<pre style=\"font-size: medium;\">";
+ $disklist = get_physical_disks_list();
+
+ echo "<strong>List of SMART capabilities on all detected disk:</strong><br />";
+ foreach ($disklist as $disknamek => $disknamev)
+ {
+ exec("/usr/local/sbin/smartctl -a /dev/$disknamek",$fdiskrawdata);
+ foreach ($fdiskrawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ unset ($fdiskrawdata);
+ }
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/diag_space_infos.php b/packages/freenas/www/diag_space_infos.php
new file mode 100644
index 00000000..f30688e1
--- /dev/null
+++ b/packages/freenas/www/diag_space_infos.php
@@ -0,0 +1,128 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Diagnostics"),
+ gettext("Space Infos"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="diag_space_infos.php" method="post" name="iform" id="iform">
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php");
+ $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php");
+ $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php");
+ $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php");
+ $tab_array[4] = array(gettext("Space used"), true, "diag_space_infos.php");
+ $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php");
+ $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php");
+ $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="top">
+ <?php
+ echo "<pre style=\"font-size: medium;\">";
+ exec("/bin/df -h",$rawdata);
+
+ echo "<strong>Free Space:</strong><br />";
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br />";
+ }
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_manage.php b/packages/freenas/www/disks_manage.php
new file mode 100644
index 00000000..ee2e6dc0
--- /dev/null
+++ b/packages/freenas/www/disks_manage.php
@@ -0,0 +1,203 @@
+#!/usr/local/bin/php
+<?php
+/* $Id$ */
+/*
+ disks_manage.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("Management"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['disks']['disk']))
+ $freenas_config['disks']['disk'] = array();
+
+disks_sort();
+
+$a_disk_conf = &$freenas_config['disks']['disk'];
+
+if ($_POST) {
+
+ unset($input_errors);
+
+ /* input validation */
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (! file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ /* reload all components that mount disk */
+ // disks_mount_all();
+ /* Is formated?: If not create FS */
+ /* $retval = disk_disks_create_ufs(); */
+
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_diskdirty_path)) {
+ unlink($d_diskdirty_path);
+ }
+ }
+ }
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($input_errors)) {
+ input_errors2Ajax($input_errors);
+ exit;
+ }
+
+ if (!$input_errors) {
+ /* No errors detected, so update the config */
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_disk_conf[$_GET['id']]) {
+ unset($a_disk_conf[$_GET['id']]);
+ write_config();
+ touch($d_diskdirty_path);
+ pfSenseHeader("disks_manage.php");
+ exit;
+ }
+}
+
+/* if ajax is calling, give them an update message */
+if(isAjax())
+ print_info_box_np($savemsg);
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="disks_manage.php" method="post" name="iform" id="iform">
+<?php if (file_exists($d_diskdirty_path)): ?>
+<?php print_info_box_np(gettext("The disk list has been changed.") . "<br />" .
+ gettext("You must apply the changes in order for them to take effect."));?>
+<?php endif; ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage"), true, "disks_manage.php");
+ $tab_array[1] = array(gettext("Format"), false, "disks_manage_init.php");
+ $tab_array[2] = array(gettext("iSCSI Initiator"), false, "disks_manage_iscsi.php");
+ display_top_tabs($tab_array);
+?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="listhdrr"><?=gettext("Disk");?></td>
+ <td class="listhdrr"><?=gettext("Size");?></td>
+ <td class="listhdrr"><?=gettext("Description");?></td>
+ <td class="listhdrr"><?=gettext("Standby time");?></td>
+ <td class="listhdrr"><?=gettext("File system");?></td>
+ <td class="listhdrr"><?=gettext("Status");?></td>
+ <td class="list">&nbsp;</td>
+ </tr>
+ <?php $i = 0; foreach ($a_disk_conf as $disk): ?>
+ <tr>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($disk['name']);?>
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($disk['size']);?>
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($disk['desc']);?>&nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?php
+ if ($disk['harddiskstandby']) {
+ $value = $disk['harddiskstandby'];
+ //htmlspecialchars($value);
+ echo $value;
+ } else {
+ echo "Always on";
+ }
+ ?>
+ </td>
+ <td valign="middle" class="listr">
+ <?= ($disk['fstype']) ? $disk['fstype']: gettext("unknown or unformatted"); ?>
+ </td>
+ <td valign="middle" class="listr">
+ <?php
+ $stat = disks_status($disk);
+ echo $stat;
+ ?>
+ </td>
+ <td valign="middle" class="list">
+ <a href="disks_manage_edit.php?id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit disk");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ <a href="disks_manage.php?act=del&id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete disk");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="6"></td>
+ <td class="list" nowrap>
+ <a href="disks_manage_edit.php">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+</table>
+</div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_manage_edit.php b/packages/freenas/www/disks_manage_edit.php
new file mode 100644
index 00000000..416d9bc6
--- /dev/null
+++ b/packages/freenas/www/disks_manage_edit.php
@@ -0,0 +1,276 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("Management"),
+ gettext("Edit"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+
+/* get disk list (without CDROM) */
+$disklist = get_physical_disks_list();
+
+if (!is_array($freenas_config['disks']['disk']))
+ $freenas_config['disks']['disk'] = array();
+
+disks_sort();
+
+$a_disk = &$freenas_config['disks']['disk'];
+
+if (isset($id) && $a_disk[$id])
+{
+ $pconfig['name'] = $a_disk[$id]['name'];
+ $pconfig['harddiskstandby'] = $a_disk[$id]['harddiskstandby'];
+ $pconfig['acoustic'] = $a_disk[$id]['acoustic'];
+ $pconfig['fstype'] = $a_disk[$id]['fstype'];
+ $pconfig['apm'] = $a_disk[$id]['apm'];
+ $pconfig['udma'] = $a_disk[$id]['udma'];
+
+}
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = split(" ", "name");
+ $reqdfieldsn = split(",", "Name");
+
+ do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket);
+ $pconfig = $_POST;
+
+ /* check for name conflicts */
+ foreach ($a_disk as $disk)
+ {
+ if (isset($id) && ($a_disk[$id]) && ($a_disk[$id] === $disk))
+ continue;
+
+ if ($disk['name'] == $_POST['name'])
+ {
+ $error_bucket[] = array("error" => gettext("This disk already exists in the disk list."),
+ "field" => "name");
+ break;
+ }
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $disks = array();
+
+ $devname = $_POST['name'];
+ $devharddiskstandby = $_POST['harddiskstandby'];
+ $harddiskacoustic = $_POST['acoustic'];
+ $harddiskapm = $_POST['apm'];
+ $harddiskudma = $_POST['udma'];
+ $harddiskfstype = $_POST['fstype'];
+
+ $disks['name'] = $devname;
+ $disks['harddiskstandby'] = $devharddiskstandby ;
+ $disks['acoustic'] = $harddiskacoustic ;
+ if ($harddiskfstype) $disks['fstype'] = $harddiskfstype ;
+ $disks['apm'] = $harddiskapm ;
+ $disks['udma'] = $harddiskudma ;
+ $disks['type'] = $disklist[$devname]['type'];
+ $disks['desc'] = $disklist[$devname]['desc'];
+ $disks['size'] = $disklist[$devname]['size'];
+
+ if (isset($id) && $a_disk[$id])
+ $a_disk[$id] = $disks;
+ else
+ $a_disk[] = $disks;
+
+ touch($d_diskdirty_path);
+
+ disks_set_ataidle();
+ write_config();
+
+ pfSenseHeader("disks_manage.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="disks_manage_edit.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td>
+ <td width="78%" class="vtable">
+ <select name="name" class="formselect" id="name">
+ <?php foreach ($disklist as $diski => $diskv): ?>
+ <option value="<?=$diski;?>" <?php if ($diski == $pconfig['name']) echo "selected=\"selected\"";?>>
+ <?php echo htmlspecialchars($diski . ": " .$diskv['size'] . " (" . $diskv['desc'] . ")");?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("UDMA mode");?></td>
+ <td width="78%" class="vtable">
+ <select name="udma" class="formselect" id="udma">
+ <?php
+ $types = explode(",", "Auto,UDMA-33,UDMA-66,UDMA-100,UDMA-133");
+ $vals = explode(" ", "auto UDMA2 UDMA4 UDMA5 UDMA6");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['udma']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ <br />
+ <?= gettext("You can force UDMA mode if you have \"UDMA_ERROR.... LBA\" message with your hard drive."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Hard disk standby time");?></td>
+ <td width="78%" class="vtable">
+ <select name="harddiskstandby" class="formselect">
+ <?php
+ $sbvals = array(0=>"Always on",5=>"5 minutes",10=>"10 minutes",20=>"20 minutes",30=>"30 minutes",60=>"60 minutes");
+ ?>
+ <?php foreach ($sbvals as $sbval => $sbname): ?>
+ <option value="<?=$sbval;?>" <?php if($pconfig['harddiskstandby'] == $sbval) echo 'selected="selected"';?>><?=htmlspecialchars($sbname);?></option>
+ <?php endforeach; ?>
+ </select>
+ <br />
+ <?= gettext("Puts the hard disk into standby mode when the selected amount of time after the last
+ access has elapsed. <em>Do not set this for CF cards.</em>"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Advanced Power Management");?></td>
+ <td width="78%" class="vtable">
+ <select name="apm" class="formselect">
+ <?php
+ $apmvals = array(0=>"Disabled",1=>"Minimum power usage with Standby",64=>"Medium power usage with Standby",128=>"Minimum power usage without Standby",192=>"Medium power usage without Standby",254=>"Maximum performance, maximum power usage");
+ ?>
+ <?php foreach ($apmvals as $apmval => $apmname): ?>
+ <option value="<?=$apmval;?>" <?php if($pconfig['apm'] == $apmval) echo 'selected="selected"';?>><?=htmlspecialchars($apmname);?></option>
+ <?php endforeach; ?>
+ </select>
+ <br />
+ <?= gettext("This allows you to lower the power consumption of the drive, at the expense of performance.<em>Do not set this for CF cards.</em>"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("acoustic level");?></td>
+ <td width="78%" class="vtable">
+ <select name="acoustic" class="formselect">
+ <?php
+ $acvals = array(0=>"Disabled",1=>"Minimum performance, Minimum acoustic output",64=>"Medium acoustic output",127=>"Maximum performance, maximum acoustic output");
+ ?>
+ <?php foreach ($acvals as $acval => $acname): ?>
+ <option value="<?=$acval;?>" <?php if($pconfig['acoustic'] == $acval) echo 'selected';?>><?=htmlspecialchars($acname);?></option>
+ <?php endforeach; ?>
+ </select>
+ <br />
+ <?= gettext("This allows you to set how loud the drive is while it\'s operating.<em>Do not set this for CF cards.</em>"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("preformated FS");?></td>
+ <td width="78%" class="vtable">
+ <select name="fstype" class="formselect">
+ <?php
+ $fstvals = array(
+ ""=>"unformated",
+ "ufs"=>"UFS with Soft Updates (use 8% space disk)",
+ "ufs_no_su"=>"UFS",
+ "ufsgpt"=>"UFS (EFI/GPT) with Soft Updates (use 8% space disk)",
+ "ufsgpt_no_su"=>"UFS (EFI/GPT)",
+ "msdos"=>"FAT32",
+ "ntfs"=>"NTFS",
+ "raid"=>"Software RAID: gmirror",
+ "raid"=>"Software RAID: gvinum");
+ ?>
+ <?php foreach ($fstvals as $fstval => $fstname): ?>
+ <option value="<?=$fstval;?>" <?php if($pconfig['fstype'] == $fstval) echo 'selected';?>><?=htmlspecialchars($fstname);?></option>
+ <?php endforeach; ?>
+ </select>
+ <br />
+ <?= gettext("This allows you to set FS type for preformated disk with data.<br />
+ <em>Leave \"unformated\" for unformated disk and then use Format menu.</em>"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ <?php if (isset($id) && $a_disk[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_manage_init.php b/packages/freenas/www/disks_manage_init.php
new file mode 100644
index 00000000..b6fce877
--- /dev/null
+++ b/packages/freenas/www/disks_manage_init.php
@@ -0,0 +1,294 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("Initialize"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['disks']['disk']))
+ $freenas_config['disks']['disk'] = array();
+
+disks_sort();
+
+$a_disk = &$freenas_config['disks']['disk'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ unset($do_format);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = explode(" ", "disk type");
+ $reqdfieldsn = explode(",", "Disk,Type");
+
+ do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $do_format = true;
+ $disk = $_POST['disk'];
+ $type = $_POST['type'];
+ $diskid = $_POST['id'];
+ $notinitmbr= $_POST['notinitmbr'];
+
+ /* found the name in the config: Must be a better way for did that */
+
+ $id=0;
+ $i=0;
+ foreach ($a_disk as $disks)
+ {
+ $diskname=$disks['name'];
+ if (strcmp($diskname,$disk)==0)
+ $id=$i;
+ $i++;
+ }
+
+ if ($type == "ufs" || $type == "ufsgpt" || $type == "ufs_no_su" || $type == "ufsgpt_no_su")
+ $a_disk[$id]['fstype'] = "ufs";
+ else
+ $a_disk[$id]['fstype'] = $type;
+ write_config();
+ }
+}
+
+if (!isset($do_format))
+{
+ $do_format = false;
+ $disk = '';
+ $type = '';
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage"), false, "disks_manage.php");
+ $tab_array[1] = array(gettext("Format"), true, "disks_manage_init.php");
+ $tab_array[2] = array(gettext("iSCSI Initiator"), false, "disks_manage_iscsi.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form id="iform" name="iform" action="disks_manage_init.php" method="post">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td>
+ <td width="78%" class="vtable">
+ <select name="disk" class="formselect" id="disk">
+ <?php foreach ($a_disk as $diskn): ?>
+ <option value="<?=$diskn['name'];?>"<?php if ($diskn['name'] == $disk) echo "selected=\"selected\"";?>>
+ <?php echo htmlspecialchars($diskn['name'] . ": " .$diskn['size'] . " (" . $diskn['desc'] . ")");?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("File system");?></td>
+ <td width="78%" class="vtable">
+ <select name="type" class="formselect" id="type">
+ <option value="ufs" <?php if ($type == "ufs") echo "selected=\"selected\""; ?>>UFS with Soft Updates (use 8% space disk)</option>
+ <option value="ufs_no_su" <?php if ($type == "ufs_no_su") echo "selected=\"selected\""; ?>>UFS</option>
+ <option value="ufsgpt" <?php if ($type == "ufsgpt") echo "selected=\"selected\""; ?>>UFS (EFI/GPT) with Soft Updates (use 8% space disk)</option>
+ <option value="ufsgpt_no_su" <?php if ($type == "ufsgpt_no_su") echo "selected=\"selected\""; ?>>UFS (EFI/GPT)</option>
+ <option value="msdos" <?php if ($type == "msdos") echo "selected=\"selected\""; ?>>FAT32</option>
+ <option value="gmirror" <?php if ($type == "gmirror") echo "selected=\"selected\""; ?>>Software RAID: Geom mirror</option>
+ <option value="raid" <?php if ($type == "raid") echo "selected=\"selected\""; ?>>Software RAID: Geom Vinum</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("File system");?></td>
+ <td width="78%" class="vtable">
+ <input name="notinitmbr" id="notinitmbr" type="checkbox" value="yes" /><br />
+ <?= gettext("don't erase the MBR (useful for some RAID controller cards)"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Format disk!");?>" />
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" colspan="2">
+ <? if ($do_format)
+ {
+ echo(_DISKSMANAGEINITPHP_INITTEXT);
+ echo('<pre>');
+ ob_end_flush();
+
+ /* Erase MBR if not checked*/
+
+ if (!$notinitmbr) {
+ echo "Erasing MBR\n";
+ system("dd if=/dev/zero of=/dev/" . escapeshellarg($disk) . " bs=32k count=640");
+
+ }
+ else
+ echo "Keeping the MBR\n";
+
+ switch ($type)
+ {
+ case "ufs":
+ /* Initialize disk */
+ system("/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk));
+ echo "\"fdisk: Geom not found\"is not an error message!\n";
+ /* Initialise the partition (optional) */
+ system("/bin/dd if=/dev/zero of=/dev/" . escapeshellarg($disk) . "s1 bs=32k count=16");
+ /* Create s1 label */
+ system("/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto");
+ // Create filesystem
+ system("/sbin/newfs -U /dev/" . escapeshellarg($disk) . "s1");
+ break;
+ case "ufs_no_su":
+ /* Initialize disk */
+ system("/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk));
+ /* Initialise the partition (optional) */
+ system("/bin/dd if=/dev/zero of=/dev/" . escapeshellarg($disk) . "s1 bs=32k count=16");
+ /* Create s1 label */
+ system("/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto");
+ // Create filesystem
+ system("/sbin/newfs -m 0 /dev/" . escapeshellarg($disk) . "s1");
+ break;
+ case "ufsgpt":
+ /* Create GPT partition table */
+ system("/sbin/gpt destroy " . escapeshellarg($disk));
+ system("/sbin/gpt create -f " . escapeshellarg($disk));
+ system("/sbin/gpt add -t ufs " . escapeshellarg($disk));
+ // Create filesystem
+ system("/sbin/newfs -U /dev/" . escapeshellarg($disk) . "p1");
+ break;
+ case "ufsgpt_no_su":
+ /* Create GPT partition table */
+ system("/sbin/gpt destroy " . escapeshellarg($disk));
+ system("/sbin/gpt create -f " . escapeshellarg($disk));
+ system("/sbin/gpt add -t ufs " . escapeshellarg($disk));
+ // Create filesystem
+ system("/sbin/newfs -m 0 /dev/" . escapeshellarg($disk) . "p1");
+ break;
+ case "gmirror":
+ /* Initialize disk */
+ system("/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk));
+ /* Initialise the partition (optional) */
+ system("/bin/dd if=/dev/zero of=/dev/" . escapeshellarg($disk) . "s1 bs=32k count=16");
+ /* Create s1 label */
+ //system("/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto");
+ /* Delete old gmirror information */
+ system("/sbin/gmirror clear /dev/" . escapeshellarg($disk));
+ break;
+ case "raid":
+ /* Initialize disk */
+ system("/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk));
+ echo "\"fdisk: Geom not found\"is not an error message!\n";
+ /* Initialise the partition (optional) */
+ system("/bin/dd if=/dev/zero of=/dev/" . escapeshellarg($disk) . "s1 bs=32k count=16");
+ /* Create s1 label */
+ system("/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto");
+ break;
+ case "msdos":
+ /* Initialize disk */
+ system("/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk));
+ echo "\"fdisk: Geom not found\"is not an error message!\n";
+ /* Initialise the partition (optional) */
+ system("/bin/dd if=/dev/zero of=/dev/" . escapeshellarg($disk) . "s1 bs=32k count=16");
+ /* Create s1 label */
+ system("/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto");
+ // Create filesystem
+ system("/sbin/newfs_msdos -F 32 /dev/" . escapeshellarg($disk) . "s1");
+ break;
+ }
+
+ echo('</pre>');
+ }
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="2">
+ <span class="red">
+ <strong>WARNING:</strong>
+ </span>
+ <br />
+ <span class="vexpl">
+ <?= gettext("This step will erase all your partition, create partition number 1 and format the hard drive with the file system specified."); ?>
+ </span>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_manage_iscsi.php b/packages/freenas/www/disks_manage_iscsi.php
new file mode 100644
index 00000000..4a156ee7
--- /dev/null
+++ b/packages/freenas/www/disks_manage_iscsi.php
@@ -0,0 +1,199 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("iSCSI Initiator"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! is_array($freenas_config['iscsi']))
+{
+ $freenas_config['iscsi'] = array();
+}
+
+$pconfig['enable'] = isset($freenas_config['iscsi']['enable']);
+$pconfig['targetaddress'] = $freenas_config['iscsi']['targetaddress'];
+$pconfig['targetname'] = $freenas_config['iscsi']['targetname'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ unset($do_format);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable'])
+ {
+ $reqdfields = array_merge($reqdfields, explode(" ", "targetaddress targetname"));
+ $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "targetaddress,targetname"));
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if ($_POST['enable'] && !is_ipaddr($_POST['targetaddress'])){
+ $error_bucket[] = array("error" => gettext("A valid IP address must be specified."),
+ "field" => "targetaddress");
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['iscsi']['enable'] = $_POST['enable'] ? true : false;
+ $freenas_config['iscsi']['targetaddress'] = $_POST['targetaddress'];
+ $freenas_config['iscsi']['targetname'] = $_POST['targetname'];
+
+ write_config();
+
+ $retval = 0;
+ if (! file_exists($d_sysrebootreqd_path))
+ {
+ /* nuke the cache file */
+ config_lock();
+ services_iscsi_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ document.iform.targetname.disabled = endis;
+ document.iform.targetaddress.disabled = endis;
+ /* adjust colors */
+ document.iform.targetname.style.backgroundColor = color;
+ document.iform.targetaddress.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage"), false, "disks_manage.php");
+ $tab_array[1] = array(gettext("Format"), false, "disks_manage_init.php");
+ $tab_array[2] = array(gettext("iSCSI Initiator"), true, "disks_manage_iscsi.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form id="iform" name="iform" action="disks_manage_iscsi.php" method="post">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("iSCSI Initiator");?></span>
+ <span style="vertical-align: middle; position: relative; left: 81%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Target IP address"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="targetaddress" type="text" class="formfld unknown" id="targetaddress" size="20" value="<?=htmlspecialchars($pconfig['targetaddress']);?>" />
+ <br /><?= gettext("Target IP address"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("targetname"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="targetname" type="text" class="formfld unknown" id="targetname" size="20" value="<?=htmlspecialchars($pconfig['targetname']);?>" />
+ <br /><?= gettext("targetname"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_mount.php b/packages/freenas/www/disks_mount.php
new file mode 100644
index 00000000..c5bd6f2b
--- /dev/null
+++ b/packages/freenas/www/disks_mount.php
@@ -0,0 +1,208 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("Mount Point"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['mounts']['mount']))
+ $freenas_config['mounts']['mount'] = array();
+
+mount_sort();
+
+$a_mount = &$freenas_config['mounts']['mount'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if ($_POST['apply']) {
+ $retval = 0;
+
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ /* reload all components that mount disk */
+ disks_mount_all();
+ /* reload all components that use mount */
+ services_samba_configure();
+ services_nfs_configure();
+ services_rsyncd_configure();
+ services_afpd_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_mountdirty_path))
+ unlink($d_mountdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del")
+{
+ if ($a_mount[$_GET['id']]) {
+ disks_umount_adv($a_mount[$_GET['id']]);
+ unset($a_mount[$_GET['id']]);
+ write_config();
+ touch($d_mountdirty_path);
+ pfSenseHeader("disks_mount.php");
+ exit;
+ }
+}
+
+if ($_GET['act'] == "ret")
+{
+ if ($a_mount[$_GET['id']]) {
+ disks_mount($a_mount[$_GET['id']]);
+ pfSenseHeader("disks_mount.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form id="iform" name="iform" action="disks_mount.php" method="post">
+<?php if (file_exists($d_diskdirty_path)): ?>
+<?php print_info_box_np(gettext("The mount point list has been changed.") . "<br />" .
+ gettext("You must apply the changes in order for them to take effect."));?>
+<?php endif; ?>
+ <div id="inputerrors"></div>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listhdrr"><?=gettext("Disk");?></td>
+ <td class="listhdrr"><?=gettext("Partition");?></td>
+ <td class="listhdrr"><?=gettext("File system");?></td>
+ <td class="listhdrr"><?=gettext("Share name");?></td>
+ <td class="listhdrr"><?=gettext("Description");?></td>
+ <td class="listhdrr"><?=gettext("Status");?></td>
+ <td class="list">&nbsp;</td>
+ </tr>
+ <?php $i = 0; foreach ($a_mount as $mount): ?>
+ <tr>
+ <td valign="middle" class="listlr">
+ <?=htmlspecialchars($mount['mdisk']);?> &nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($mount['partition']);?>&nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($mount['fstype']);?>&nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($mount['sharename']);?>&nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($mount['desc']);?>&nbsp;
+ </td>
+ </td>
+ <td valign="middle" class="listbg">
+ <?php
+ if (file_exists($d_mountdirty_path))
+ $stat=_CONFIGURING;
+ else {
+ $stat=disks_mount_status($mount);
+ if ($stat == "ERROR")
+ echo "ERROR - <a href=\"disks_mount.php?act=ret&id=$i\">retry</a>";
+ else
+ echo $stat;
+ }
+ ?>&nbsp;
+ </td>
+ <td valign="middle" class="list">
+ <a href="disks_mount_edit.php?id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit mount");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ <a href="disks_mount.php?act=del&id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" onclick="return confirm('<? gettext("Do you really want to delete this mount point? All elements that still use it will become invalid (e.g. share)!"); ?>');" title="<?=gettext("delete mount");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="6"></td>
+ <td class="list" nowrap>
+ <a href="disks_mount_edit.php">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add mount");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="7">
+ <span class="red">
+ <strong>Note:</strong>
+ </span>
+ <br />
+ <span class="vexpl">
+ <?= gettext("Second configuration step: Declaring the filesystem used by your"); ?>
+ </span>
+ <br />
+ <span class="vexpl">
+ <a href="disk_manage.php">previously configured disk</a>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_mount_edit.php b/packages/freenas/www/disks_mount_edit.php
new file mode 100644
index 00000000..31221570
--- /dev/null
+++ b/packages/freenas/www/disks_mount_edit.php
@@ -0,0 +1,279 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("Mount Point"),
+ gettext("Edit"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['mounts']['mount']))
+ $freenas_config['mounts']['mount'] = array();
+
+mount_sort();
+
+if (!is_array($freenas_config['disks']['disk']))
+ $freenas_config['disks']['disk'] = array();
+
+disks_sort();
+
+if (!is_array($freenas_config['raid']['vdisk']))
+ $freenas_config['raid']['vdisk'] = array();
+
+gvinum_sort();
+
+if (!is_array($freenas_config['gmirror']['vdisk']))
+ $freenas_config['gmirror']['vdisk'] = array();
+
+gmirror_sort();
+
+$a_mount = &$freenas_config['mounts']['mount'];
+
+$a_disk = array_merge($freenas_config['disks']['disk'],$freenas_config['raid']['vdisk'],$freenas_config['gmirror']['vdisk']);
+
+/* Load the cfdevice file*/
+$filename=$g['varetc_path']."/cfdevice";
+if (file_exists($filename))
+ $cfdevice = trim(file_get_contents("$filename"));
+
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+
+if (isset($id) && $a_mount[$id]) {
+ $pconfig['mdisk'] = $a_mount[$id]['mdisk'];
+ $pconfig['partition'] = $a_mount[$id]['partition'];
+ $pconfig['fstype'] = $a_mount[$id]['fstype'];
+ $pconfig['sharename'] = $a_mount[$id]['sharename'];
+ $pconfig['desc'] = $a_mount[$id]['desc'];
+}
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = split(" ", "partition mdisk fstype");
+ $reqdfieldsn = split(",", "Partition,Mdisk,Fstype");
+
+ do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket);
+
+ if (($_POST['sharename'] && !is_validsharename($_POST['sharename'])))
+ {
+ $error_bucket[] = array("error" => gettext("The share name may only consist of the characters a-z, A-Z, 0-9, _ , -."),
+ "field" => "sharename");
+ }
+
+
+ if (($_POST['desc'] && !is_validdesc($_POST['desc'])))
+ {
+ $error_bucket[] = array("error" => gettext("The description name contain invalid characters."),
+ "field" => "desc");
+
+ }
+ $device=$_POST['mdisk'].$_POST['partition'];
+
+ if ($device == $cfdevice )
+ {
+ $error_bucket[] = array("error" => gettext("Can't mount the system partition 1, the DATA partition is the 2."),
+ "field" => "mdisk");
+
+ }
+
+ /* check for name conflicts */
+ foreach ($a_mount as $mount)
+ {
+ if (isset($id) && ($a_mount[$id]) && ($a_mount[$id] === $mount))
+ continue;
+
+ /* Remove the duplicate disk use
+ if ($mount['mdisk'] == $_POST['mdisk'])
+ {
+ $input_errors[] = "This device already exists in the mount point list.";
+ break;
+ }
+ */
+
+ if (($_POST['sharename']) && ($mount['sharename'] == $_POST['sharename']))
+ {
+ $error_bucket[] = array("error" => gettext("Duplicate Share Name."),
+ "field" => "sharename");
+ break;
+ }
+
+
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $mount = array();
+ $mount['mdisk'] = $_POST['mdisk'];
+ $mount['partition'] = $_POST['partition'];
+ $mount['fstype'] = $_POST['fstype'];
+ $mount['desc'] = $_POST['desc'];
+ /* if not sharename given, create one */
+ if (!$_POST['sharename'])
+ $mount['sharename'] = "disk_{$_POST['mdisk']}_part_{$_POST['partition']}";
+ else
+ $mount['sharename'] = $_POST['sharename'];
+ if (isset($id) && $a_mount[$id])
+ $a_mount[$id] = $mount;
+ else
+ $a_mount[] = $mount;
+
+ touch($d_mountdirty_path);
+
+ write_config();
+
+ pfSenseHeader("disks_mount.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="disks_mount_edit.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td>
+ <td width="78%" class="vtable">
+ <select name="mdisk" class="formselect" id="mdisk">
+ <?php foreach ($a_disk as $disk): ?>
+ <?php if ((strcmp($disk['fstype'],"raid")!=0) | (strcmp($disk['fstype'],"gmirror")!=0)): ?>
+ <option value="<?=$disk['name'];?>" <?php if ($pconfig['mdisk'] == $disk['name']) echo "selected";?>>
+ <?php echo htmlspecialchars($disk['name'] . ": " .$disk['size'] . " (" . $disk['desc'] . ")"); ?>
+ </option>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Partition");?></td>
+ <td width="78%" class="vtable">
+ <select name="partition" class="formselect" id="partition number">
+ <option value="s1" <?php if ($pconfig['partition'] == "s1") echo "selected=\"selected\""; ?>>1</option>
+ <option value="s2" <?php if ($pconfig['partition'] == "s2") echo "selected\"selected\""; ?>>2</option>
+ <option value="s3" <?php if ($pconfig['partition'] == "s3") echo "selected\"selected\""; ?>>3</option>
+ <option value="s4" <?php if ($pconfig['partition'] == "s4") echo "selected\"selected\""; ?>>4</option>
+ <option value="gmirror" <?php if ($pconfig['partition'] == "gmirror") echo "selected\"selected\""; ?>><?=_SOFTRAID ;?> - gmirror</option>
+ <option value="gvinum" <?php if ($pconfig['partition'] == "gvinum") echo "selected\"selected\""; ?>><?=_SOFTRAID ;?> - gvinum</option>
+ <option value="p1" <?php if ($pconfig['partition'] == "gpt") echo "selected\"selected\""; ?>>GPT</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("File system");?></td>
+ <td width="78%" class="vtable">
+ <select name="fstype" class="formselect" id="fstype">
+ <option value="ufs" <?php if ($pconfig['fstype'] == "ufs") echo "selected=\"selected\""; ?>>UFS</option>
+ <option value="msdosfs" <?php if ($pconfig['fstype'] == "msdosfs") echo "selected\"selected\""; ?>>FAT</option>
+ <option value="ntfs" <?php if ($pconfig['fstype'] == "ntfs") echo "selected\"selected\""; ?>>NTFS (read-only)</option>
+ <option value="ext2fs" <?php if ($pconfig['fstype'] == "ext2fs") echo "selected\"selected\""; ?>>EXT2 FS</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Share name");?></td>
+ <td width="78%" class="vtable">
+ <input name="sharename" type="text" class="formfld unknown" id="sharename" size="20" value="<?=htmlspecialchars($pconfig['sharename']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
+ <td width="78%" class="vtable">
+ <input name="desc" type="text" class="formfld unknown" id="desc" size="20" value="<?=htmlspecialchars($pconfig['desc']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ <?php if (isset($id) && $a_mount[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="100%" align="left" valign="top" colspan="2">
+ <span class="red">
+ <strong><?= gettext("WARNING"); ?>:</strong>
+ </span>
+ <ol>
+ <li>
+ <span class="vexpl">
+ <?= gettext("You can't mount the partition '"); ?>
+ <?php echo htmlspecialchars($cfdevice);?>
+ <?= gettext("' where the config file is stored"); ?>
+ </span>
+ </li>
+ <li><span class="vexpl"><?= gettext("FreeBSD NTFS has lots of bugs."); ?></span></li>
+ </ol>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gmirror.php b/packages/freenas/www/disks_raid_gmirror.php
new file mode 100644
index 00000000..4d51ba0f
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gmirror.php
@@ -0,0 +1,223 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Mirror"),
+ gettext("RAID"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['gmirror']['vdisk']))
+ $freenas_config['gmirror']['vdisk'] = array();
+
+gmirror_sort();
+
+$raidstatus=get_sraid_disks_list();
+
+$a_raid = &$freenas_config['gmirror']['vdisk'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $pconfig = $_POST;
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path))
+ {
+ config_lock();
+ /* reload all components that create raid device */
+ disks_raid_gmirror_configure();
+ config_unlock();
+ write_config();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_raidconfdirty_path))
+ unlink($d_raidconfdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_raid[$_GET['id']]) {
+ $raidname=$a_raid[$_GET['id']]['name'];
+ disks_raid_gmirror_delete($raidname);
+ unset($a_raid[$_GET['id']]);
+ write_config();
+ pfSenseHeader("disks_raid_gmirror.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="disks_raid_gmirror.php" method="post" name="iform" id="iform">
+<?php if (file_exists($d_diskdirty_path)): ?>
+<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" .
+ gettext("You must apply the changes in order for them to take effect."));?>
+<?php endif; ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), false, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="listhdrr"><?=gettext("Volume name");?></td>
+ <td class="listhdrr"><?=gettext("Type");?></td>
+ <td class="listhdrr"><?=gettext("Size");?></td>
+ <td class="listhdrr"><?=gettext("Status");?></td>
+ <td class="list">&nbsp;</td>
+ </tr>
+ <?php $i = 0; foreach ($a_raid as $raid): ?>
+ <tr>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($raid['name']);?>
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($raid['type']);?>
+ </td>
+ <td valign="middle" class="listr">
+ <?php
+ $raidconfiguring = file_exists($d_raidconfdirty_path) &&
+ in_array($raid['name']."\n",file($d_raidconfdirty_path));
+ if ($raidconfiguring)
+ echo gettext("configuring");
+ else {
+ $tempo=$raid['name'];
+ echo "{$raidstatus[$tempo]['size']}";
+ }
+ ?>&nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?php
+ if ($raidconfiguring)
+ echo gettext("configuring");
+ else {
+ echo "{$raidstatus[$tempo]['desc']}";
+ }
+ ?>&nbsp;
+ </td>
+ <td valign="middle" class="list">
+ <a href="disks_raid_gmirror_edit.php?id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ <a href="disks_raid_gmirror.php?act=del&id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list" nowrap>
+ <a href="disks_raid_gmirror_edit.php">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="5">
+ <span class="red">
+ <strong><?= gettext("Note:"); ?></strong>
+ </span>
+ <br />
+ <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span>
+ <br />
+ <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span>
+ <br />
+ <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gmirror_edit.php b/packages/freenas/www/disks_raid_gmirror_edit.php
new file mode 100644
index 00000000..4fba1242
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gmirror_edit.php
@@ -0,0 +1,267 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Mirror"),
+ gettext("RAID"),
+ gettext("Edit"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['gmirror']['vdisk']))
+ $freenas_config['gmirror']['vdisk'] = array();
+
+gmirror_sort();
+
+if (!is_array($freenas_config['disks']['disk']))
+ $nodisk_errors[] = _DISKSRAIDEDITPHP_MSGADDDISKFIRST;
+else
+ disks_sort();
+
+$a_raid = &$freenas_config['gmirror']['vdisk'];
+
+$a_disk = &$freenas_config['disks']['disk'];
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+
+if (isset($id) && $a_raid[$id]) {
+ $pconfig['name'] = $a_raid[$id]['name'];
+ $pconfig['type'] = $a_raid[$id]['type'];
+ $pconfig['balance'] = $a_raid[$id]['balance'];
+ $pconfig['diskr'] = $a_raid[$id]['diskr'];
+}
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $reqdfields = explode(" ", "name");
+ $reqdfieldsn = explode(",", "Name");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['name'] && !is_validaliasname($_POST['name'])))
+ {
+ $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."),
+ "field" => "name");
+ }
+
+
+ /* check for name conflicts */
+ foreach ($a_raid as $raid)
+ {
+ if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid))
+ continue;
+
+ if ($raid['name'] == $_POST['name'])
+ {
+ $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."),
+ "field" => "name");
+ break;
+ }
+ }
+
+ /* check the number of RAID disk for volume */
+
+ if (count($_POST['diskr']) != 2)
+ $error_bucket[] = array("error" => gettext("There must be 2 disks in a RAID 1 volume."),
+ "field" => "diskr");
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors) {
+ $raid = array();
+ $raid['name'] = $_POST['name'];
+ $raid['balance'] = $_POST['balance'];
+ $raid['type'] = 1;
+ $raid['diskr'] = $_POST['diskr'];
+ $raid['desc'] = "Software RAID {$_POST['type']}";
+
+ if (isset($id) && $a_raid[$id])
+ $a_raid[$id] = $raid;
+ else
+ $a_raid[] = $raid;
+
+ $fd = @fopen("$d_raidconfdirty_path", "a");
+ if (!$fd) {
+ echo "ERR Could not save RAID configuration.\n";
+ exit(0);
+ }
+ fwrite($fd, "$raid[name]\n");
+ fclose($fd);
+
+ write_config();
+
+ pfSenseHeader("disks_raid_gmirror.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), false, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gmirror_edit.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Volume name");?></td>
+ <td width="78%" class="vtable">
+ <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td>
+ <td class="vtable">
+ RAID 1 (<?= gettext("mirroring"); ?>)
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Balance algorithm"); ?></td>
+ <td width="78%" class="vtable">
+ <select name="balance" class="formselect">
+ <?php $balvals = array(
+ "split"=>"Split request",
+ "load"=>"Read from lowest load",
+ "round-robin"=>"Round-robin read");
+ ?>
+ <?php foreach ($balvals as $balval => $balname): ?>
+ <option value="<?=$balval;?>" <?php if($pconfig['balance'] == $balval) echo 'selected';?>><?=htmlspecialchars($balname);?></option>
+ <?php endforeach; ?>
+ </select>
+ <br />
+ <?= gettext("Select your read balance algorithm."); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td>
+ <td width="78%" class="vtable">
+ <?
+ $i=0;
+ $disable_script="";
+
+ foreach ($a_disk as $diskv) {
+ $r_name="";
+
+ if (strcmp($diskv['fstype'],"gmirror")==0) {
+ foreach($a_raid as $raid) {
+ if (in_array($diskv['name'],$raid['diskr'])) {
+ $r_name=$raid['name'];
+
+ if ($r_name!=$pconfig['name'])
+ $disable_script.="document.getElementById($i).disabled=1;\n";
+ break;
+ }
+ }
+
+ echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[name]'".
+ ((is_array($pconfig['diskr']) && in_array($diskv['name'], $pconfig['diskr'])) ? " checked=\"checked\"":"").
+ " />$diskv[name] ($diskv[size], $diskv[desc])" . (($r_name) ? " - assigned to $r_name" : "") . "<br />\n";
+ }
+
+ $i++;
+ }
+
+ if ($disable_script)
+ echo "<script type='text/javascript'><!--\n$disable_script--></script>\n";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save" />
+ <?php if (isset($id) && $a_raid[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gmirror_infos.php b/packages/freenas/www/disks_raid_gmirror_infos.php
new file mode 100644
index 00000000..e6b208e7
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gmirror_infos.php
@@ -0,0 +1,132 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Mirror"),
+ gettext("Information"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors) {
+ }
+}
+if (!isset($do_action)) {
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), false, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gvinum_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php");
+ $tab_array[3] = array(gettext("Information"), true, "disks_raid_gvinum_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gmirror_infos.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" class="vtable">
+ <?php
+ echo "<pre>";
+ echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />";
+
+ exec("/sbin/gmirror list",$rawdata);
+ foreach ($rawdata as $line){
+ echo htmlspecialchars($line) . "<br>";
+ }
+
+ unset ($line);
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gmirror_init.php b/packages/freenas/www/disks_raid_gmirror_init.php
new file mode 100644
index 00000000..c849be52
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gmirror_init.php
@@ -0,0 +1,167 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Mirror"),
+ gettext("Initialize"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $reqdfields = explode(" ", "disk");
+ $reqdfieldsn = explode(",", "Disk");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (! $input_errors) {
+ $do_format = true;
+ $disk = $_POST['disk'];
+ }
+}
+
+if (! isset($do_format)) {
+ $do_format = false;
+ $disk = '';
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), false, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Format RAID"), true, "disks_raid_gmirror_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gmirror_init.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Volume name");?></td>
+ <td width="78%" class="vtable">
+ <input name="disk" type="text" class="formfld" id="disk" size="20" value="<?=htmlspecialchars($disk);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save" />
+ <?php if (isset($id) && $a_raid[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" colspan="2">
+ <?
+ if ($do_format) {
+ echo("<strong>" . gettext("Disk format UFS output:") . "</strong><br />");
+ echo('<pre>');
+ ob_end_flush();
+
+ /* Create filesystem */
+ system("/sbin/newfs -U /dev/mirror/" . escapeshellarg($disk));
+
+ echo('</pre>');
+ }
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="2">
+ <span class="red">
+ <strong>WARNING:</strong><br />
+ </span>
+ <span class="vexpl">
+ <?= gettext("This step will format the RAID volume in Unix FileSystem (UFS)."); ?>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gmirror_tools.php b/packages/freenas/www/disks_raid_gmirror_tools.php
new file mode 100644
index 00000000..714dea7f
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gmirror_tools.php
@@ -0,0 +1,184 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Mirror"),
+ gettext("Tools"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $reqdfields = explode(" ", "action object");
+ $reqdfieldsn = explode(",", "Action,Object");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors) {
+ $do_action = true;
+ $action = $_POST['action'];
+ $object = $_POST['object'];
+ }
+}
+if (!isset($do_action)) {
+ $do_action = false;
+ $action = '';
+ $object = '';
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), false, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php");
+ $tab_array[2] = array(gettext("Tools"), true, "disks_raid_gmirror_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gmirror_tools.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td>
+ <td width="78%" class="vtable">
+ <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td>
+ <td width="78%" class="vtable">
+ <select name="action" class="formselect" id="action">
+ <option value="rebuild" <?php if ($action == "rebuild") echo "selected=\"selected\""; ?>>rebuild</option>
+ <option value="list" <?php if ($action == "list") echo "selected=\"selected\""; ?>>list</option>
+ <option value="status" <?php if ($action == "status") echo "selected=\"selected\""; ?>>status</option>
+ <option value="remove" <?php if ($action == "remove") echo "selected=\"selected\""; ?>>remove</option>
+ <option value="activate" <?php if ($action == "activate") echo "selected=\"selected\""; ?>>activate</option>
+ <option value="deactivate" <?php if ($action == "deactivate") echo "selected=\"selected\""; ?>>deactivate</option>
+ <option value="forget" <?php if ($action == "forget") echo "selected=\"selected\""; ?>>forget</option>
+ <option value="clear" <?php if ($action == "clear") echo "selected=\"selected\""; ?>>clear</option>
+ <option value="stop" <?php if ($action == "stop") echo "selected=\"selected\""; ?>>stop</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Send Command!" />
+ <?php if (isset($id) && $a_raid[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" colspan="2">
+ <?
+ if ($do_action) {
+ echo("<strong>" . gettext("GMIRROR command output:") . "</strong><br />");
+ echo('<pre>');
+ ob_end_flush();
+
+ system("/sbin/gmirror $action " . escapeshellarg($object));
+
+ echo('</pre>');
+ }
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="2">
+ <span class="red">
+ <strong>WARNING:</strong><br />
+ </span>
+ <ol>
+ <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li>
+ <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li>
+ </ol>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gvinum.php b/packages/freenas/www/disks_raid_gvinum.php
new file mode 100644
index 00000000..260fae14
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gvinum.php
@@ -0,0 +1,222 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Vinum"),
+ gettext("RAID"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['raid']['vdisk']))
+ $freenas_config['raid']['vdisk'] = array();
+
+gvinum_sort();
+
+$raidstatus=get_sraid_disks_list();
+
+$a_raid = &$freenas_config['raid']['vdisk'];
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $pconfig = $_POST;
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path))
+ {
+ config_lock();
+ /* reload all components that create raid device */
+ disks_raid_configure();
+ config_unlock();
+ write_config();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_raidconfdirty_path))
+ unlink($d_raidconfdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_raid[$_GET['id']]) {
+ $raidname=$a_raid[$_GET['id']]['name'];
+ disks_raid_gvinum_delete($raidname);
+ unset($a_raid[$_GET['id']]);
+ write_config();
+ pfSenseHeader("disks_raid_gvinum.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="disks_raid_gvinum.php" method="post" name="iform" id="iform">
+<?php if (file_exists($d_diskdirty_path)): ?>
+<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" .
+ gettext("You must apply the changes in order for them to take effect."));?>
+<?php endif; ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), true, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gvinum.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gvinum_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="listhdrr"><?=gettext("Volume name");?></td>
+ <td class="listhdrr"><?=gettext("Type");?></td>
+ <td class="listhdrr"><?=gettext("Size");?></td>
+ <td class="listhdrr"><?=gettext("Status");?></td>
+ <td class="list">&nbsp;</td>
+ </tr>
+ <?php $i = 0; foreach ($a_raid as $raid): ?>
+ <tr>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($raid['name']);?>
+ </td>
+ <td valign="middle" class="listr">
+ <?=htmlspecialchars($raid['type']);?>
+ </td>
+ <td valign="middle" class="listr">
+ <?php
+ $raidconfiguring = file_exists($d_raidconfdirty_path) &&
+ in_array($raid['name']."\n",file($d_raidconfdirty_path));
+ if ($raidconfiguring)
+ echo gettext("configuring");
+ else {
+ $tempo=$raid['name'];
+ echo "{$raidstatus[$tempo]['size']}";
+ }
+ ?>&nbsp;
+ </td>
+ <td valign="middle" class="listr">
+ <?php
+ if ($raidconfiguring)
+ echo "_CONFIGURING";
+ else {
+ echo "{$raidstatus[$tempo]['desc']}";
+ }
+ ?>&nbsp;
+ </td>
+ <td valign="middle" class="list">
+ <a href="disks_raid_gvinum_edit.php?id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ <a href="disks_raid_gvinum.php?act=del&id=<?=$i;?>">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list" nowrap>
+ <a href="disks_raid_gvinum_edit.php">
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="5">
+ <span class="red">
+ <strong><?= gettext("Note:"); ?></strong>
+ </span>
+ <br />
+ <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span>
+ <br />
+ <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span>
+ <br />
+ <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gvinum_edit.php b/packages/freenas/www/disks_raid_gvinum_edit.php
new file mode 100644
index 00000000..45cbac88
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gvinum_edit.php
@@ -0,0 +1,266 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Vinum"),
+ gettext("RAID"),
+ gettext("Edit"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['raid']['vdisk']))
+ $freenas_config['raid']['vdisk'] = array();
+
+gvinum_sort();
+
+if (!is_array($freenas_config['disks']['disk']))
+ $nodisk_errors[] = _DISKSRAIDEDITPHP_MSGADDDISKFIRST;
+else
+ disks_sort();
+
+$a_raid = &$freenas_config['raid']['vdisk'];
+
+$a_disk = &$freenas_config['disks']['disk'];
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+
+if (isset($id) && $a_raid[$id]) {
+ $pconfig['name'] = $a_raid[$id]['name'];
+ $pconfig['type'] = $a_raid[$id]['type'];
+ $pconfig['diskr'] = $a_raid[$id]['diskr'];
+}
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $reqdfields = explode(" ", "name type");
+ $reqdfieldsn = explode(",", "Name,Type");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['name'] && !is_validaliasname($_POST['name'])))
+ {
+ $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."),
+ "field" => "name");
+ }
+
+ /* check for name conflicts */
+ foreach ($a_raid as $raid)
+ {
+ if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid))
+ continue;
+
+ if ($raid['name'] == $_POST['name'])
+ {
+ $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."),
+ "field" => "name");
+ break;
+ }
+ }
+
+ /* check the number of RAID disk for volume */
+
+ /* check the number of RAID disk for volume */
+
+ switch ($_POST['type'])
+ {
+ case 0:
+ if (count($_POST['diskr']) < 2)
+ $error_bucket[] = array("error" => gettext("There must be a minimum of 2 disks in a RAID 0 volume."),
+ "field" => "diskr");
+ break;
+ case 1:
+ if (count($_POST['diskr']) != 2)
+ $error_bucket[] = array("error" => gettext("There must be 2 disks in a RAID 1 volume."),
+ "field" => "diskr");
+ break;
+ case 5:
+ if (count($_POST['diskr']) < 3)
+ $error_bucket[] = array("error" => gettext("There must be a minimum of 3 disks in a RAID 5 volume."),
+ "field" => "diskr");
+ break;
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors) {
+ $raid = array();
+ $raid['name'] = $_POST['name'];
+ $raid['type'] = $_POST['type'];
+ $raid['diskr'] = $_POST['diskr'];
+ $raid['desc'] = "Software RAID {$_POST['type']}";
+
+ if (isset($id) && $a_raid[$id])
+ $a_raid[$id] = $raid;
+ else
+ $a_raid[] = $raid;
+
+ $fd = @fopen("$d_raidconfdirty_path", "a");
+ if (!$fd) {
+ echo "_DISKSRAIDEDITPHP_MSGERROR";
+ exit(0);
+ }
+ fwrite($fd, "$raid[name]\n");
+ fclose($fd);
+
+ write_config();
+
+ pfSenseHeader("disks_raid_gvinum.php");
+ exit;
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), true, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gvinum.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gvinum_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gvinum_edit.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Volume name");?></td>
+ <td width="78%" class="vtable">
+ <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td>
+ <td class="vtable">
+ <select name="type" class="formselect" id="type">
+ <option value="0" <?php if ($pconfig['type'] == 0) echo "selected=\"selected\""; ?>>RAID 0 (<?= gettext("striping"); ?>)</option>
+ <option value="1" <?php if ($pconfig['type'] == 1) echo "selected=\"selected\""; ?>>RAID 1 (<?= gettext("mirroring"); ?>)</option>
+ <option value="5" <?php if ($pconfig['type'] == 5) echo "selected=\"selected\""; ?>>RAID 5 (<?= gettext("rotated block-interleaved parity"); ?>)</option>
+
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td>
+ <td width="78%" class="vtable">
+ <?
+ $i=0;
+ $disable_script="";
+
+ foreach ($a_disk as $diskv) {
+ $r_name="";
+
+ if (strcmp($diskv['fstype'],"raid")==0) {
+ foreach($a_raid as $raid) {
+ if (in_array($diskv['name'],$raid['diskr'])) {
+ $r_name=$raid['name'];
+
+ if ($r_name!=$pconfig['name'])
+ $disable_script.="document.getElementById($i).disabled=1;\n";
+ break;
+ }
+ }
+ echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[name]'".
+ ((is_array($pconfig['diskr']) && in_array($diskv['name'], $pconfig['diskr'])) ? " checked=\"checked\"" : "").
+ " />$diskv[name] ($diskv[size], $diskv[desc])" . (($r_name) ? " - assigned to $r_name" : "") . "<br>\n";
+ }
+ $i++;
+ }
+ if ($disable_script) echo "<script type='text/javascript'><!--\n$disable_script--></script>\n";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save" />
+ <?php if (isset($id) && $a_raid[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gvinum_infos.php b/packages/freenas/www/disks_raid_gvinum_infos.php
new file mode 100644
index 00000000..7b9cfcb2
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gvinum_infos.php
@@ -0,0 +1,132 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Vinum"),
+ gettext("Information"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors) {
+ }
+}
+if (!isset($do_action)) {
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), true, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gvinum_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php");
+ $tab_array[3] = array(gettext("Information"), true, "disks_raid_gvinum_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gvinum_infos.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" class="vtable">
+ <?php
+ echo "<pre>";
+ echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />";
+
+ exec("/sbin/gvinum list",$rawdata);
+ foreach ($rawdata as $line)
+ {
+ echo htmlspecialchars($line) . "<br>";
+ }
+ unset ($line);
+ echo "</pre>";
+ ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gvinum_init.php b/packages/freenas/www/disks_raid_gvinum_init.php
new file mode 100644
index 00000000..2befcaa0
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gvinum_init.php
@@ -0,0 +1,169 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Vinum"),
+ gettext("Initialize"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $reqdfields = explode(" ", "disk");
+ $reqdfieldsn = explode(",", "Disk");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (! $input_errors) {
+ $do_format = true;
+ $disk = $_POST['disk'];
+ }
+}
+
+if (! isset($do_format)) {
+ $do_format = false;
+ $disk = '';
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), true, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php");
+ $tab_array[1] = array(gettext("Format RAID"), true, "disks_raid_gvinum_init.php");
+ $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gvinum_init.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Volume name");?></td>
+ <td width="78%" class="vtable">
+ <input name="disk" type="text" class="formfld" id="disk" size="20" value="<?=htmlspecialchars($disk);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save" />
+ <?php if (isset($id) && $a_raid[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" colspan="2">
+ <?
+ if ($do_format) {
+ echo("<strong>_DISKSRAIDINITPHP_INFO</strong><br />");
+ echo('<pre>');
+ ob_end_flush();
+
+ /* Create filesystem */
+ system("/sbin/newfs -U /dev/gvinum/" . escapeshellarg($disk));
+ /* Do it twice for test the RAID5 bug at reboot*/
+ system("/sbin/newfs -U /dev/gvinum/" . escapeshellarg($disk));
+
+ echo('</pre>');
+ }
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="2">
+ <span class="red">
+ <strong>WARNING:</strong><br />
+ </span>
+ <span class="vexpl">
+ <?= gettext("This step will format the RAID volume in Unix FileSystem (UFS)."); ?>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/disks_raid_gvinum_tools.php b/packages/freenas/www/disks_raid_gvinum_tools.php
new file mode 100644
index 00000000..97853e29
--- /dev/null
+++ b/packages/freenas/www/disks_raid_gvinum_tools.php
@@ -0,0 +1,207 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("System"),
+ gettext("Disks"),
+ gettext("GEOM Vinum"),
+ gettext("Tools"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+
+ $reqdfields = explode(" ", "action object");
+ $reqdfieldsn = explode(",", "Action,Object");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors) {
+ $do_action = true;
+ $action = $_POST['action'];
+ $object = $_POST['object'];
+ }
+}
+if (!isset($do_action)) {
+ $do_action = false;
+ $action = '';
+ $object = '';
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php");
+ $tab_array[1] = array(gettext("Geom Vinum (unstable)"), true, "disks_raid_gvinum.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabnavtbl">
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php");
+ $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gvinum_init.php");
+ $tab_array[2] = array(gettext("Tools"), true, "disks_raid_gvinum_tools.php");
+ $tab_array[3] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form action="disks_raid_gvinum_tools.php" method="post" name="iform" id="iform">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td>
+ <td width="78%" class="vtable">
+ <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td>
+ <td width="78%" class="vtable">
+ <select name="action" class="formselect" id="action">
+ <option value="start" <?php if ($action == "start") echo "selected=\"selected\""; ?>>start</option>
+ <option value="rebuild" <?php if ($action == "rebuild") echo "selected=\"selected\""; ?>>rebuild parity</option>
+ <option value="list" <?php if ($action == "list") echo "selected=\"selected\""; ?>>list</option>
+ <option value="remove" <?php if ($action == "remove") echo "selected=\"selected\""; ?>>remove</option>
+ <option value="forceup" <?php if ($action == "forceup") echo "selected=\"selected\""; ?>>Force State to UP</option>
+ <option value="saveconfig" <?php if ($action == "saveconfig") echo "selected=\"selected\""; ?>>saveconfig</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Send Command!" />
+ <?php if (isset($id) && $a_raid[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" colspan="2">
+ <?
+ if ($do_action) {
+ echo("<strong>" . gettext("GVINUM command output:") . "</strong><br />");
+ echo('<pre>');
+ ob_end_flush();
+
+ switch ($action)
+ {
+ case "remove":
+ /* Remove recursivly object */
+ system("/sbin/gvinum rm -r " . escapeshellarg($object));
+ break;
+ case "start":
+ /* Start object */
+ system("/sbin/gvinum start " . escapeshellarg($object));
+ break;
+ case "rebuild":
+ /* Rebuild RAID 5 parity */
+ system("/sbin/gvinum rebuildparity " . escapeshellarg($object));
+ break;
+ case "list":
+ /* Disaply a detailed list of object */
+ system("/sbin/gvinum list " . escapeshellarg($object));
+ break;
+ case "forceup":
+ /* Force object state up */
+ system("/sbin/gvinum setstate -f up " . escapeshellarg($object));
+ break;
+ case "saveconfig":
+ /* Save config */
+ system("/sbin/gvinum saveconfig");
+ break;
+ }
+
+ echo('</pre>');
+ }
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" colspan="2">
+ <span class="red">
+ <strong>WARNING:</strong><br />
+ </span>
+ <ol>
+ <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li>
+ <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li>
+ </ol>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/freenas/www/services_afp.php b/packages/freenas/www/services_afp.php
new file mode 100644
index 00000000..c3648b9f
--- /dev/null
+++ b/packages/freenas/www/services_afp.php
@@ -0,0 +1,190 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Services"),
+ gettext("AFP"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['afp'])) {
+ $freenas_config['afp'] = array();
+}
+
+
+$pconfig['enable'] = isset($freenas_config['afp']['enable']);
+$pconfig['afpname'] = $freenas_config['afp']['afpname'];
+$pconfig['guest'] = isset($freenas_config['afp']['guest']);
+$pconfig['local'] = isset($freenas_config['afp']['local']);
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = split(" ", "afpname");
+ $reqdfieldsn = split(",", "Afpname");
+
+ do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket);
+
+ if ($_POST['enable'] && !$_POST['guest'])
+ {
+ if (!$_POST['local'])
+ $error_bucket[] = array("error" => gettext("You must select at least one authentication method."),
+ "field" => "local");
+ }
+ if ($_POST['enable'] && !$_POST['local'])
+ {
+ if (!$_POST['guest'])
+ $error_bucket[] = array("error" => gettext("You must select at least one authentication method."),
+ "field" => "name");
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['afp']['enable'] = $_POST['enable'] ? true : false;
+ $freenas_config['afp']['guest'] = $_POST['guest'] ? true : false;
+ $freenas_config['afp']['local'] = $_POST['local'] ? true : false;
+ $freenas_config['afp']['afpname'] = $_POST['afpname'];
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path))
+ {
+ /* nuke the cache file */
+ config_lock();
+ services_afpd_configure();
+ services_mdnsresponder_configure();
+ config_unlock();
+ }
+
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ document.iform.guest.disabled = endis;
+ document.iform.local.disabled = endis;
+ document.iform.afpname.disabled = endis;
+ /* color adjustments */
+ document.iform.guest.style.backgroundColor = color;
+ document.iform.local.style.backgroundColor = color;
+ document.iform.afpname.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="services_afp.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("AFP Server");?></span>
+ <span style="vertical-align: middle; position: relative; left: 84%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Server Name");?></td>
+ <td width="78%" class="vtable">
+ <input name="afpname" type="text" class="formfld" id="afpname" size="20" value="<?=htmlspecialchars($pconfig['afpname']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Authentication");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="guest" id="guest" type="checkbox" value="yes" <?php if ($pconfig['guest']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Enable guest access."); ?><br />
+ <input name="local" id="local" type="checkbox" value="yes" <?php if ($pconfig['local']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Enable local user authentication."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/services_ftp.php b/packages/freenas/www/services_ftp.php
new file mode 100644
index 00000000..da144349
--- /dev/null
+++ b/packages/freenas/www/services_ftp.php
@@ -0,0 +1,347 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Services"),
+ gettext("FTP"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['ftp']))
+{
+ $freenas_config['ftp'] = array();
+
+}
+
+$pconfig['enable'] = isset($freenas_config['ftp']['enable']);
+$pconfig['port'] = $freenas_config['ftp']['port'];
+$pconfig['numberclients'] = $freenas_config['ftp']['numberclients'];
+$pconfig['maxconperip'] = $freenas_config['ftp']['maxconperip'];
+$pconfig['timeout'] = $freenas_config['ftp']['timeout'];
+$pconfig['anonymous'] = isset($freenas_config['ftp']['anonymous']);
+$pconfig['localuser'] = isset($freenas_config['ftp']['localuser']);
+$pconfig['pasv_max_port'] = $freenas_config['ftp']['pasv_max_port'];
+$pconfig['pasv_min_port'] = $freenas_config['ftp']['pasv_min_port'];
+$pconfig['pasv_address'] = $freenas_config['ftp']['pasv_address'];
+$pconfig['banner'] = $freenas_config['ftp']['banner'];
+$pconfig['natmode'] = isset($freenas_config['ftp']['natmode']);
+$pconfig['passiveip'] = $freenas_config['ftp']['passiveip'];
+$pconfig['fxp'] = isset($freenas_config['ftp']['fxp']);
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable']) {
+ $reqdfields = array_merge($reqdfields, explode(" ", "numberclients maxconperip timeout port"));
+ $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Numberclients,Maxconperip,Timeout,Port"));
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if ($_POST['enable'] && !is_port($_POST['port']))
+ {
+ $error_bucket[] = array("error" => gettext("The TCP port must be a valid port number."),
+ "field" => "port");
+ }
+ if ($_POST['enable'] && !is_numericint($_POST['numberclients'])) {
+ $error_bucket[] = array("error" => gettext("The maximum Number of client must be a number."),
+ "field" => "numberclients");
+ }
+
+ if ($_POST['enable'] && !is_numericint($_POST['maxconperip'])) {
+ $error_bucket[] = array("error" => gettext("The max con per ip must be a number."),
+ "field" => "maxconperip");
+ }
+ if ($_POST['enable'] && !is_numericint($_POST['timeout'])) {
+ $error_bucket[] = array("error" => gettext("The maximum idle time be a number."),
+ "field" => "timeout");
+ }
+
+ if ($_POST['enable'] && ($_POST['pasv_address']))
+ {
+ if (!is_ipaddr($_POST['pasv_address']))
+ $error_bucket[] = array("error" => gettext("The pasv address must be a public IP address."),
+ "field" => "pasv_address");
+
+ }
+
+ if ($_POST['enable'] && ($_POST['pasv_max_port']))
+ {
+ if (!is_port($_POST['pasv_max_port']))
+ $error_bucket[] = array("error" => gettext("The pasv_max_port port must be a valid port number."),
+ "field" => "pasv_max_port");
+ }
+
+ if ($_POST['enable'] && ($_POST['pasv_min_port']))
+ {
+ if (!is_port($_POST['pasv_min_port']))
+ $error_bucket[] = array("error" => gettext("The pasv_min_port port must be a valid port number."),
+ "field" => "pasv_min_port");
+
+ }
+
+ if (($_POST['passiveip'] && !is_ipaddr($_POST['passiveip']))) {
+ $error_bucket[] = array("error" => gettext("A valid IP address must be specified."),
+ "field" => "passiveip");
+
+ }
+
+ if (!($_POST['anonymous']) && !($_POST['localuser'])) {
+ $input_errors[] = _SRVFTP_MSGVALIDAUTH;
+ $error_bucket[] = array("error" => gettext("You must select at minium anonymous or/and local user authentication."),
+ "field" => "localuser");
+
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['ftp']['numberclients'] = $_POST['numberclients'];
+ $freenas_config['ftp']['maxconperip'] = $_POST['maxconperip'];
+ $freenas_config['ftp']['timeout'] = $_POST['timeout'];
+ $freenas_config['ftp']['port'] = $_POST['port'];
+ $freenas_config['ftp']['anonymous'] = $_POST['anonymous'] ? true : false;
+ $freenas_config['ftp']['localuser'] = $_POST['localuser'] ? true : false;
+ $freenas_config['ftp']['pasv_max_port'] = $_POST['pasv_max_port'];
+ $freenas_config['ftp']['pasv_min_port'] = $_POST['pasv_min_port'];
+ $freenas_config['ftp']['pasv_address'] = $_POST['pasv_address'];
+ $freenas_config['ftp']['banner'] = $_POST['banner'];
+ $freenas_config['ftp']['passiveip'] = $_POST['passiveip'];
+ $freenas_config['ftp']['fxp'] = $_POST['fxp'] ? true : false;
+ $freenas_config['ftp']['natmode'] = $_POST['natmode'] ? true : false;
+ $freenas_config['ftp']['enable'] = $_POST['enable'] ? true : false;
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ /* nuke the cache file */
+ config_lock();
+ services_ftpd_configure();
+ services_mdnsresponder_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ document.iform.port.disabled = endis;
+ document.iform.timeout.disabled = endis;
+ document.iform.numberclients.disabled = endis;
+ document.iform.maxconperip.disabled = endis;
+ document.iform.anonymous.disabled = endis;
+ document.iform.localuser.disabled = endis;
+ document.iform.banner.disabled = endis;
+ document.iform.fxp.disabled = endis;
+ document.iform.natmode.disabled = endis;
+ document.iform.passiveip.disabled = endis;
+ document.iform.pasv_max_port.disabled = endis;
+ document.iform.pasv_min_port.disabled = endis;
+ /* color adjustments */
+ document.iform.port.style.backgroundColor = color;
+ document.iform.timeout.style.backgroundColor = color;
+ document.iform.numberclients.style.backgroundColor = color;
+ document.iform.maxconperip.style.backgroundColor = color;
+ document.iform.anonymous.style.backgroundColor = color;
+ document.iform.localuser.style.backgroundColor = color;
+ document.iform.banner.style.backgroundColor = color;
+ document.iform.fxp.style.backgroundColor = color;
+ document.iform.natmode.style.backgroundColor = color;
+ document.iform.passiveip.style.backgroundColor = color;
+ document.iform.pasv_max_port.style.backgroundColor = color;
+ document.iform.pasv_min_port.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="services_ftp.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("FTP Server");?></span>
+ <span style="vertical-align: middle; position: relative; left: 84%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("TCP port");?></td>
+ <td width="78%" class="vtable">
+ <input name="port" type="text" class="formfld unknown" id="port" size="20" value="<?=htmlspecialchars($pconfig['port']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Number of clients");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="numberclients" type="text" class="formfld unknown" id="numberclients" size="20" value="<?=htmlspecialchars($pconfig['numberclients']);?>" />
+ <br />
+ <?= gettext("Maximum number of simultaneous clients."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Max conn per ip");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="maxconperip" type="text" class="formfld unknown" id="maxconperip" size="20" value="<?=htmlspecialchars($pconfig['maxconperip']);?>" />
+ <br />
+ <?= gettext("Maximum connection per IP address."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Timeout");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="timeout" type="text" class="formfld unknown" id="timeout" size="20" value="<?=htmlspecialchars($pconfig['timeout']);?>" />
+ <br />
+ <?= gettext("Maximum idle time in seconds."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Anonymous login");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="anonymous" type="checkbox" id="anonymous" value="yes" <?php if ($pconfig['anonymous']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Enable Anonymous login"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Local User");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="localuser" type="checkbox" id="localuser" value="yes" <?php if ($pconfig['localuser']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Enable local User login"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Banner");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <textarea name="banner" cols="65" rows="7" id="banner" class="formpre"><?=htmlspecialchars($pconfig['banner']);?></textarea>
+ <br />
+ <?= gettext("Greeting banner displayed by FTP when a connection first comes in."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("FXP");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="fxp" type="checkbox" id="fxp" value="yes" <?php if ($pconfig['fxp']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Enable FXP protocol."); ?>
+ <br />
+ <?= gettext("FXP allows transfers between two remote servers without any file data going to the client asking for the transfer (insecure!)."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("NAT mode");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="natmode" type="checkbox" id="natmode" value="yes" <?php if ($pconfig['natmode']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Force NAT mode"); ?>
+ <br />
+ <?= gettext("Enable it if your FTP server is behind a NAT box that doesn't support applicative FTP proxying"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Passive IP address");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="passiveip" type="text" class="formfld unknown" id="passiveip" size="30" value="<?=htmlspecialchars($pconfig['passiveip']);?>" />
+ <?= gettext("Use this option to override the IP address that FTP daemon will advertise in response to the PASV command."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("pasv_min_port");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="pasv_min_port" type="text" class="formfld unknown" id="pasv_min_port" size="20" value="<?=htmlspecialchars($pconfig['pasv_min_port']);?>" />
+ <?= gettext("The minimum port to allocate for PASV style data connections."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("pasv_max_port");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="pasv_max_port" type="text" class="formfld unknown" id="pasv_max_port" size="20" value="<?=htmlspecialchars($pconfig['pasv_max_port']);?>" />
+ <?= gettext("The maximum port to allocate for PASV style data connections."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/services_nfs.php b/packages/freenas/www/services_nfs.php
new file mode 100644
index 00000000..403ea17c
--- /dev/null
+++ b/packages/freenas/www/services_nfs.php
@@ -0,0 +1,219 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Services"),
+ gettext("NFS"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['nfs']))
+{
+ $freenas_config['nfs'] = array();
+}
+
+$pconfig['enable'] = isset($freenas_config['nfs']['enable']);
+$pconfig['mapall'] = $freenas_config['nfs']['mapall'];
+
+list($pconfig['network'],$pconfig['network_subnet']) =
+ explode('/', $freenas_config['nfs']['nfsnetwork']);
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = explode(" ", "network network_subnet");
+ $reqdfieldsn = explode(",", "Destination network,Destination network bit count");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['network'] && !is_ipaddr($_POST['network']))) {
+ $error_bucket[] = array("error" => gettext("A valid network must be specified."),
+ "field" => "network");
+ }
+
+ if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) {
+ $error_bucket[] = array("error" => gettext("A valid network bit count must be specified."),
+ "field" => "network_subnet");
+
+ }
+
+ $osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['nfs']['enable'] = $_POST['enable'] ? true : false;
+ $freenas_config['nfs']['mapall'] = $_POST['mapall'];
+ $freenas_config['nfs']['nfsnetwork'] = $osn;
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path))
+ {
+ /* nuke the cache file */
+ config_lock();
+ services_nfs_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ document.iform.mapall.disabled = endis;
+ document.iform.network.disabled = endis;
+ document.iform.network_subnet.disabled = endis;
+ /* color adjustments */
+ document.iform.mapall.style.backgroundColor = color;
+ document.iform.network.style.backgroundColor = color;
+ document.iform.network_subnet.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="services_nfs.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("NFS Server");?></span>
+ <span style="vertical-align: middle; position: relative; left: 84%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("map all user to root");?></td>
+ <td width="78%" class="vtable">
+ <select name="mapall" class="formselect" id="mapall">
+ <?php
+ $types = explode(",", "Yes,No");
+ $vals = explode(" ", "yes no");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['mapall']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ <br />
+ <?= gettext("All users will have the root privilege."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Authorised network");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="network" type="text" class="formfld host" id="network" size="20" value="<?=htmlspecialchars($pconfig['network']);?>" />
+ /
+ <select name="network_subnet" class="formselect" id="network_subnet">
+ <?php for ($i = 32; $i >= 1; $i--): ?>
+ <option value="<?=$i;?>" <?php if ($i == $pconfig['network_subnet']) echo "selected=\"selected\""; ?>>
+ <?=$i;?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ <br />
+ <?= gettext("Network that is authorised to access to NFS share"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <span class="red">
+ <strong><?= gettext("WARNING"); ?></strong>
+ </span>
+ <span class="vexpl">
+ <?= gettext("The name of the exported directories are : /mnt/sharename"); ?>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/services_rsyncd.php b/packages/freenas/www/services_rsyncd.php
new file mode 100644
index 00000000..b28bca34
--- /dev/null
+++ b/packages/freenas/www/services_rsyncd.php
@@ -0,0 +1,263 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Services"),
+ gettext("RSYNCD"),
+ gettext("Server"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+/* TODO: use pfSense users/groups. */
+if (!is_array($freenas_config['access']['user']))
+ $freenas_config['access']['user'] = array();
+
+users_sort();
+
+$a_user = &$freenas_config['access']['user'];
+
+if (!is_array($freenas_config['rsync']))
+{
+ $freenas_config['rsync'] = array();
+}
+
+$pconfig['readonly'] = $freenas_config['rsyncd']['readonly'];
+$pconfig['port'] = $freenas_config['rsyncd']['port'];
+$pconfig['motd'] = $freenas_config['rsyncd']['motd'];
+$pconfig['maxcon'] = $freenas_config['rsyncd']['maxcon'];
+$pconfig['rsyncd_user'] = $freenas_config['rsyncd']['rsyncd_user'];
+$pconfig['enable'] = isset($freenas_config['rsyncd']['enable']);
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ unset($do_format);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable'])
+ {
+ $reqdfields = array_merge($reqdfields, explode(" ", "readonly port"));
+ $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Readonly,Port"));
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if ($_POST['enable']) {
+ if (!is_port($_POST['port']))
+ $error_bucket[] = array("error" => gettext("The TCP port must be a valid port number."),
+ "field" => "port");
+ else if (!is_numericint($_POST['maxcon']))
+ $error_bucket[] = array("error" => gettext("The value provided by the maximum connections field is not a number"),
+ "field" => "maxcon");
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['rsyncd']['readonly'] = $_POST['readonly'];
+ $freenas_config['rsyncd']['port'] = $_POST['port'];
+ $freenas_config['rsyncd']['motd'] = $_POST['motd'];
+ $freenas_config['rsyncd']['maxcon'] = $_POST['maxcon'];
+ $freenas_config['rsyncd']['enable'] = $_POST['enable'] ? true : false;
+ $freenas_config['rsyncd']['rsyncd_user'] = $_POST['rsyncd_user'];
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path))
+ {
+ /* nuke the cache file */
+ config_lock();
+ services_rsyncd_configure();
+ services_mdnsresponder_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ document.iform.readonly.disabled = endis;
+ document.iform.port.disabled = endis;
+ document.iform.motd.disabled = endis;
+ document.iform.maxcon.disabled = endis;
+ document.iform.rsyncd_user.disabled = endis;
+ /* adjust colors */
+ document.iform.readonly.style.backgroundColor = color;
+ document.iform.port.style.backgroundColor = color;
+ document.iform.motd.style.backgroundColor = color;
+ document.iform.maxcon.style.backgroundColor = color;
+ document.iform.rsyncd_user.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Server"), true, "services_rsyncd.php");
+ $tab_array[1] = array(gettext("Client"), false, "services_rsyncd_client.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form id="iform" name="iform" action="services_rsyncd.php" method="post">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("Rsync Daemon");?></span>
+ <span style="vertical-align: middle; position: relative; left: 81%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Read only"); ?></td>
+ <td width="78%" class="vtable">
+ <select name="readonly" class="formselect" id="readonly">
+ <?php
+ $types = explode(",", "Yes,No");
+ $vals = explode(" ", "yes no");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['readonly']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Map to user"); ?></td>
+ <td width="78%" class="vtable">
+ <select name="rsyncd_user" class="formselect" id="rsyncd_user">
+ <option value="ftp"<?php if ($pconfig['rsyncd_user'] == "ftp") echo "selected";?>>
+ <?php echo htmlspecialchars("guest"); ?>
+ <?php foreach ($a_user as $user): ?>
+ <option value="<?=$user['login'];?>"<?php if ($user['login'] == $pconfig['rsyncd_user']) echo "selected";?>>
+ <?php echo htmlspecialchars($user['login']); ?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("TCP port"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="port" type="text" class="formfld" id="port" size="20" value="<?=htmlspecialchars($pconfig['port']);?>" />
+ <br /><?= gettext("Alternate TCP port."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?= gettext("Maximum connections"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="maxcon" type="text" class="formfld" id="maxcon" size="20" value="<?=htmlspecialchars($pconfig['maxcon']);?>" />
+ <br /><?= gettext("Maximum number of simultaneous connections. Default is 0 (unlimited)"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?= gettext("MOTD"); ?></td>
+ <td width="78%" class="vtable">
+ <textarea name="motd" cols="65" rows="7" id="motd" class="formpre"><?=htmlspecialchars($pconfig['motd']);?></textarea>
+ <br />
+ <?= gettext("message of the day");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/services_rsyncd_client.php b/packages/freenas/www/services_rsyncd_client.php
new file mode 100644
index 00000000..f5e86e07
--- /dev/null
+++ b/packages/freenas/www/services_rsyncd_client.php
@@ -0,0 +1,565 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Services"),
+ gettext("RSYNCD"),
+ gettext("Client"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+/* TODO: use pfSense users/groups. */
+if (!is_array($freenas_config['access']['user']))
+ $freenas_config['access']['user'] = array();
+
+users_sort();
+
+$a_user = &$freenas_config['access']['user'];
+
+if (!is_array($freenas_config['rsync']))
+{
+ $freenas_config['rsync'] = array();
+}
+
+$a_months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
+$a_weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
+
+$pconfig['readonly'] = $freenas_config['rsyncd']['readonly'];
+$pconfig['port'] = $freenas_config['rsyncd']['port'];
+$pconfig['motd'] = $freenas_config['rsyncd']['motd'];
+$pconfig['maxcon'] = $freenas_config['rsyncd']['maxcon'];
+$pconfig['rsyncd_user'] = $freenas_config['rsyncd']['rsyncd_user'];
+$pconfig['enable'] = isset($freenas_config['rsyncd']['enable']);
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ unset($do_format);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable']){
+ $reqdfields = array_merge($reqdfields, explode(" ", "rsyncserverip sharetosync"));
+ $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Rsyncserverip,Sharetosync"));
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if ($_POST['enable']) {
+ if (!is_port($_POST['port']))
+ $error_bucket[] = array("error" => gettext("The TCP port must be a valid port number."),
+ "field" => "port");
+ else if (!is_numericint($_POST['maxcon']))
+ $error_bucket[] = array("error" => gettext("The value provided by the maximum connections field is not a number"),
+ "field" => "maxcon");
+ }
+
+ if (!is_array($freenas_config['mounts']['mount'])) {
+ $error_bucket[] = array("error" => gettext("You must configure mount point first."),
+ "field" => "none");
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['rsyncclient']['opt_delete'] = $_POST['opt_delete'] ? true : false;;
+ $freenas_config['rsyncclient']['rsyncserverip'] = $_POST['rsyncserverip'];
+ $freenas_config['rsyncclient']['minute'] = $_POST['minutes'];
+ $freenas_config['rsyncclient']['hour'] = $_POST['hours'];
+ $freenas_config['rsyncclient']['day'] = $_POST['days'];
+ $freenas_config['rsyncclient']['month'] = $_POST['months'];
+ $freenas_config['rsyncclient']['weekday'] = $_POST['weekdays'];
+ $freenas_config['rsyncclient']['rsyncshare'] = $_POST['rsyncshare'];
+ $freenas_config['rsyncclient']['enable'] = $_POST['enable'] ? true : false;
+ $freenas_config['rsyncclient']['sharetosync'] = $_POST['sharetosync'];
+ $freenas_config['rsyncclient']['all_mins'] = $_POST['all_mins'];
+ $freenas_config['rsyncclient']['all_hours'] = $_POST['all_hours'];
+ $freenas_config['rsyncclient']['all_days'] = $_POST['all_days'];
+ $freenas_config['rsyncclient']['all_months'] = $_POST['all_months'];
+ $freenas_config['rsyncclient']['all_weekdays'] = $_POST['all_weekdays'];
+
+ write_config();
+
+ $retval = 0;
+
+ if (!file_exists($d_sysrebootreqd_path)){
+ /* nuke the cache file */
+ config_lock();
+ services_rsyncclient_configure();
+ services_cron_configure();
+ config_unlock();
+ }
+
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+if (is_array($freenas_config['mounts']['mount'])) {
+ mount_sort();
+ $a_mount = &$freenas_config['mounts']['mount'];
+
+ $pconfig['opt_delete'] = isset($freenas_config['rsyncclient']['opt_delete']);
+ $pconfig['enable'] = isset($freenas_config['rsyncclient']['enable']);
+ $pconfig['rsyncserverip'] = $freenas_config['rsyncclient']['rsyncserverip'];
+ $pconfig['rsyncshare'] = $freenas_config['rsyncclient']['rsyncshare'];
+ $pconfig['minute'] = $freenas_config['rsyncclient']['minute'];
+ $pconfig['hour'] = $freenas_config['rsyncclient']['hour'];
+ $pconfig['day'] = $freenas_config['rsyncclient']['day'];
+ $pconfig['month'] = $freenas_config['rsyncclient']['month'];
+ $pconfig['weekday'] = $freenas_config['rsyncclient']['weekday'];
+ $pconfig['sharetosync'] = $freenas_config['rsyncclient']['sharetosync'];
+ $pconfig['all_mins'] = $freenas_config['rsyncclient']['all_mins'];
+ $pconfig['all_hours'] = $freenas_config['rsyncclient']['all_hours'];
+ $pconfig['all_days'] = $freenas_config['rsyncclient']['all_days'];
+ $pconfig['all_months'] = $freenas_config['rsyncclient']['all_months'];
+ $pconfig['all_weekdays'] = $freenas_config['rsyncclient']['all_weekdays'];
+
+ if ($pconfig['all_mins'] == 1){
+ $all_mins_all = " checked";
+ } else {
+ $all_mins_selected = " checked";
+ }
+
+ if ($pconfig['all_hours'] == 1){
+ $all_hours_all = " checked";
+ } else {
+ $all_hours_selected = " checked";
+ }
+
+ if ($pconfig['all_days'] == 1){
+ $all_days_all = " checked";
+ } else {
+ $all_days_selected = " checked";
+ }
+
+ if ($pconfig['all_months'] == 1){
+ $all_months_all = " checked";
+ } else {
+ $all_months_selected = " checked";
+ }
+
+ if ($pconfig['all_weekdays'] == 1){
+ $all_weekdays_all = " checked";
+ } else {
+ $all_weekdays_selected = " checked";
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+EOD;
+
+$i = 0;
+
+if (is_array($a_mount)) {
+ foreach ($a_mount as $mountv) {
+ $jscriptstr .= " document.iform.share_" . $i . ".disabled = endis;\n";
+ $i++;
+ }
+}
+
+$jscriptstr .= <<<EOD
+
+ document.iform.rsyncserverip.disabled = endis;
+ document.iform.minutes1.disabled = endis;
+ document.iform.minutes2.disabled = endis;
+ document.iform.minutes3.disabled = endis;
+ document.iform.hours1.disabled = endis;
+ document.iform.days1.disabled = endis;
+ document.iform.days2.disabled = endis;
+ document.iform.months.disabled = endis;
+ document.iform.weekdays.disabled = endis;
+ document.iform.all_mins1.disabled = endis;
+ document.iform.all_mins2.disabled = endis;
+ document.iform.all_hours1.disabled = endis;
+ document.iform.all_hours2.disabled = endis;
+ document.iform.all_days1.disabled = endis;
+ document.iform.all_days2.disabled = endis;
+ document.iform.all_months1.disabled = endis;
+ document.iform.all_months2.disabled = endis;
+ document.iform.all_weekdays1.disabled = endis;
+ document.iform.all_weekdays2.disabled = endis;
+ document.iform.opt_delete.disabled = endis;
+ /* color adjustments */
+ document.iform.rsyncserverip.style.backgroundColor = color;
+ document.iform.minutes1.style.backgroundColor = color;
+ document.iform.minutes2.style.backgroundColor = color;
+ document.iform.minutes3.style.backgroundColor = color;
+ document.iform.hours1.style.backgroundColor = color;
+ document.iform.days1.style.backgroundColor = color;
+ document.iform.days2.style.backgroundColor = color;
+ document.iform.months.style.backgroundColor = color;
+ document.iform.weekdays.style.backgroundColor = color;
+ document.iform.all_mins1.style.backgroundColor = color;
+ document.iform.all_mins2.style.backgroundColor = color;
+ document.iform.all_hours1.style.backgroundColor = color;
+ document.iform.all_hours2.style.backgroundColor = color;
+ document.iform.all_days1.style.backgroundColor = color;
+ document.iform.all_days2.style.backgroundColor = color;
+ document.iform.all_months1.style.backgroundColor = color;
+ document.iform.all_months2.style.backgroundColor = color;
+ document.iform.all_weekdays1.style.backgroundColor = color;
+ document.iform.all_weekdays2.style.backgroundColor = color;
+ document.iform.opt_delete.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<div id="inputerrors"></div>
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Server"), false, "services_rsyncd.php");
+ $tab_array[1] = array(gettext("Client"), true, "services_rsyncd_client.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <form id="iform" name="iform" action="services_rsyncd_client.php" method="post">
+ <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("Rsync Client Synchronization");?></span>
+ <span style="vertical-align: middle; position: relative; left: 70%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="16%" valign="top" class="vncellreq"><?= gettext("Remote RSYNC Server"); ?></td>
+ <td width="84%" class="vtable">
+ <input name="rsyncserverip" id="rsyncserverip" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['rsyncserverip']);?>" />
+ <br />
+ <?= gettext("IP address of remote RSYNC server"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="16%" valign="top" class="vncellreq"><?= gettext("RSYNC Options"); ?></td>
+ <td width="84%" class="vtable">
+ <input name="opt_delete" id="opt_delete" type="checkbox" value="yes" <?php if ($pconfig['opt_delete']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Delete files that don't exist on sender."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="16%" valign="top" class="vncellreq"><?= gettext("Shares to be synchronized"); ?></td>
+ <td width="84%" class="vtable">
+ <?php
+ $i=0;
+ if (is_array($freenas_config['mounts']['mount'])) {
+ foreach ($a_mount as $mountv) {
+ echo "<input name=\"sharetosync[]\" id=\"share_" . $i . "\" type=\"checkbox\" value=\"" . $mountv['sharename'] . "\"";
+
+ if (in_array($mountv['sharename'], $pconfig['sharetosync']))
+ echo " checked=\"checked\"";
+ echo" />";
+ echo $mountv['sharename'] . " (" . $mountv['desc'] . ")<br />\n";
+ $i++;
+ }
+ }
+ else
+ echo "You must configure mount point before!";
+ ?>
+ <br />
+ <?= gettext("This same local share must be present on the Remote Server."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="16%" valign="top" class="vncellreq"><?= gettext("Synchronization Time"); ?></td>
+ <td width="84%" class="vtable">
+ <table width="100%" border="1" cellpadding="4" cellspacing="0">
+ <tr>
+ <td align="left" valign="top" class="listtopic"><?= gettext("minutes"); ?></td>
+ <td align="left" valign="top" class="listtopic"><?= gettext("hours"); ?></td>
+ <td align="left" valign="top" class="listtopic"><?= gettext("days"); ?></td>
+ <td align="left" valign="top" class="listtopic"><?= gettext("months"); ?></td>
+ <td align="left" valign="top" class="listtopic"><?= gettext("week days"); ?></td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" class="vncell" nowrap="nowrap">
+ <div id="all_min_rdbtns" style="padding-bottom: 10px;" >
+ <input type="radio" name="all_mins" id="all_mins1" value="1"<?php echo $all_mins_all;?> />
+ <label for="all_mins1">All</label><br />
+ <input type="radio" name="all_mins" id="all_mins2" value="0"<?php echo $all_mins_selected;?> />
+ <label for="all_mins2">Selected ...</label>
+ </div>
+ <div id="all_min_select" style="vertical-align: top;">
+ <select multiple="multible" class="formselect" size="24" name="minutes[]" id="minutes1" style="vertical-align: top;">
+ <?php
+ $i = 0;
+ while ($i <= 23){
+ if (isset($pconfig['minute'])) {
+ if (in_array($i, $pconfig['minute'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ <select multiple="multible" class="formselect" size="24" name="minutes[]" id="minutes2" style="vertical-align: top;">
+ <?php
+ $i = 24;
+ while ($i <= 47) {
+ if (isset($pconfig['minute'])) {
+ if (in_array($i, $pconfig['minute'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ <select multiple="multible" class="formselect" size="12" name="minutes[]" id="minutes3" style="vertical-align: top;">
+ <?php
+ $i = 48;
+ while ($i <= 59) {
+ if (isset($pconfig['minute'])) {
+ if (in_array($i, $pconfig['minute'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ </div>
+ </td>
+ <td align="left" valign="top" class="vncell" nowrap="nowrap">
+ <div id="all_hours_rdbtns" style="padding-bottom: 10px;" >
+ <input type="radio" name="all_hours" id="all_hours1" value="1"<?php echo $all_hours_all;?> />
+ <label for="all_hours1">All</label><br />
+ <input type="radio" name="all_hours" id="all_hours2" value="0"<?php echo $all_hours_selected;?> />
+ <label for="all_hours2">Selected ...</label>
+ </div>
+ <div id="all_hours_select" style="vertical-align: top;">
+ <select multiple size="24" name="hours[]" id="hours1" style="vertical-align: top;">
+ <?php
+ $i = 0;
+ while ($i <= 23) {
+ if (isset($pconfig['hour'])) {
+ if (in_array($i, $pconfig['hour'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ </div>
+ </td>
+ <td align="left" valign="top" class="vncell" nowrap="nowrap">
+ <div id="all_days_rdbtns" style="padding-bottom: 10px;" >
+ <input type="radio" name="all_days" id="all_days1" value="1" <?php echo $all_days_all;?> />
+ <label for="all_days1">All</label><br />
+ <input type="radio" name="all_days" id="all_days2" value="0"<?php echo $all_days_selected;?> />
+ <label for="all_days2">Selected ...</label>
+ </div>
+ <div id="all_days_select" style="vertical-align: top;">
+ <select multiple size="24" name="days[]" id="days1" style="vertical-align: top;">
+ <?php
+ $i = 1;
+ while ($i <= 24) {
+ if (isset($pconfig['day'])) {
+ if (in_array($i, $pconfig['day'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ <select multiple size="7" name="days[]" id="days2" style="vertical-align: top;">
+ <?php
+ $i = 25;
+ while ($i <= 31) {
+ if (isset($pconfig['day'])) {
+ if (in_array($i, $pconfig['day'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ </div>
+ </td>
+ <td align="left" valign="top" class="vncell">
+ <div id="all_months_rdbtns" style="padding-bottom: 10px;" >
+ <input type="radio" name="all_months" id="all_months1" value="1"<?php echo $all_months_all;?> />
+ <label for="all_months1">All</label><br />
+ <input type="radio" name="all_months" id="all_months2" value="0"<?php echo $all_months_selected;?> />
+ <label for="all_months2">Selected ...</label>
+ </div>
+ <div id="all_months_select" style="vertical-align: top;">
+ <select multiple size="12" name="months[]" id="months" style="vertical-align: top;">
+ <?php
+ $i=1;
+ foreach ($a_months as $monthv) {
+ if (isset($pconfig['month'])) {
+ if (in_array($i, $pconfig['month'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $monthv . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ </div>
+ </td>
+ <td align="left" valign="top" class="vncell">
+ <div id="all_weekdays_rdbtns" style="padding-bottom: 10px;" >
+ <input type="radio" name="all_weekdays" id="all_weekdays1" value="1"<?php echo $all_weekdays_all;?> />
+ <label for="all_weekdays1">All</label><br />
+ <input type="radio" name="all_weekdays" id="all_weekdays2" value="0"<?php echo $all_weekdays_selected;?> />
+ <label for="all_weekdays2">Selected ...</label>
+ </div>
+ <div id="all_weekdays_select" style="vertical-align: top;">
+ <select multiple size="7" name="weekdays[]" id="weekdays" style="vertical-align: top;">
+ <?php
+ $i=0;
+ foreach ($a_weekdays as $weekdayv) {
+ if (isset($pconfig['weekday'])){
+ if (in_array($i, $pconfig['weekday'])) {
+ $is_selected = " selected";
+ } else {
+ $is_selected = "";
+ }
+ }
+
+ echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $weekdayv . "\n";
+ $i++;
+ }
+ ?>
+ </select>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top" class="vncell" colspan="5">
+ <?= gettext("Note: Ctrl-click (or command-click on the Mac) to select and de-select minutes, hours, days and months."); ?>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td width="16%" valign="top">&nbsp;</td>
+ <td width="84%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/services_samba.php b/packages/freenas/www/services_samba.php
new file mode 100644
index 00000000..1703b645
--- /dev/null
+++ b/packages/freenas/www/services_samba.php
@@ -0,0 +1,416 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Services"),
+ gettext("CIFS"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['samba']))
+{
+ $freenas_config['samba'] = array();
+}
+
+if (!is_array($freenas_config['mounts']['mount']))
+ $freenas_config['mounts']['mount'] = array();
+
+mount_sort();
+
+$a_mount = &$freenas_config['mounts']['mount'];
+
+$pconfig['netbiosname'] = $freenas_config['samba']['netbiosname'];
+$pconfig['workgroup'] = $freenas_config['samba']['workgroup'];
+$pconfig['serverdesc'] = $freenas_config['samba']['serverdesc'];
+$pconfig['security'] = $freenas_config['samba']['security'];
+$pconfig['localmaster'] = $freenas_config['samba']['localmaster'];
+$pconfig['winssrv'] = $freenas_config['samba']['winssrv'];
+$pconfig['hidemount'] = $freenas_config['samba']['hidemount'];
+$pconfig['timesrv'] = $freenas_config['samba']['timesrv'];
+$pconfig['unixcharset'] = $freenas_config['samba']['unixcharset'];
+$pconfig['doscharset'] = $freenas_config['samba']['doscharset'];
+$pconfig['loglevel'] = $freenas_config['samba']['loglevel'];
+$pconfig['sndbuf'] = $freenas_config['samba']['sndbuf'];
+$pconfig['rcvbuf'] = $freenas_config['samba']['rcvbuf'];
+$pconfig['enable'] = isset($freenas_config['samba']['enable']);
+$pconfig['recyclebin'] = isset($freenas_config['samba']['recyclebin']);
+
+if (! empty($_POST))
+{
+ /* hash */
+ unset($error_bucket);
+ /* simple error list */
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable']) {
+ $reqdfields = array_merge($reqdfields, explode(" ", "netbiosname workgroup security localmaster"));
+ $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Netbiosname,Workgroup,Security, Localmaster"));
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['netbiosname'] && !is_domain($_POST['netbiosname']))) {
+ $error_bucket[] = array("error" => gettext("The Netbios name contains invalid characters."),
+ "field" => "netbiosname");
+ }
+ if (($_POST['workgroup'] && !is_domain($_POST['workgroup']))) {
+ $error_bucket[] = array("error" => gettext("The Workgroup name contains invalid characters."),
+ "field" => "workgroup");
+ }
+ if (($_POST['winssrv'] && !is_ipaddr($_POST['winssrv']))) {
+ $error_bucket[] = array("error" => gettext("The WINS server must be an IP address."),
+ "field" => "winssrv");
+ }
+
+ if (!is_numericint($_POST['sndbuf'])) {
+ $error_bucket[] = array("error" => gettext("PediaXThe SND Buffer value must be a number."),
+ "field" => "sndbuf");
+ }
+
+ if (!is_numericint($_POST['rcvbuf'])) {
+ $error_bucket[] = array("error" => gettext("The RCV Buffer value must be a number."),
+ "field" => "rcvbuf");
+ }
+
+ if (is_array($error_bucket))
+ foreach($error_bucket as $elem)
+ $input_errors[] =& $elem["error"];
+
+ /* if this is an AJAX caller then handle via JSON */
+ if(isAjax() && is_array($error_bucket)) {
+ input_errors2Ajax(NULL, $error_bucket);
+ exit;
+ }
+
+ if (!$input_errors)
+ {
+ $freenas_config['samba']['netbiosname'] = $_POST['netbiosname'];
+ $freenas_config['samba']['workgroup'] = $_POST['workgroup'];
+ $freenas_config['samba']['serverdesc'] = $_POST['serverdesc'];
+ $freenas_config['samba']['security'] = $_POST['security'];
+ $freenas_config['samba']['localmaster'] = $_POST['localmaster'];
+ $freenas_config['samba']['winssrv'] = $_POST['winssrv'];
+ $freenas_config['samba']['hidemount'] = $_POST['hidemount'];
+ $freenas_config['samba']['timesrv'] = $_POST['timesrv'];
+ $freenas_config['samba']['doscharset'] = $_POST['doscharset'];
+ $freenas_config['samba']['unixcharset'] = $_POST['unixcharset'];
+ $freenas_config['samba']['loglevel'] = $_POST['loglevel'];
+ $freenas_config['samba']['sndbuf'] = $_POST['sndbuf'];
+ $freenas_config['samba']['rcvbuf'] = $_POST['rcvbuf'];
+ $freenas_config['samba']['recyclebin'] = $_POST['recyclebin'] ? true : false;
+ $freenas_config['samba']['enable'] = $_POST['enable'] ? true : false;
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ /* nuke the cache file */
+ config_lock();
+ services_samba_configure();
+ services_mdnsresponder_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+
+$jscriptstr = <<<EOD
+<script type="text/javascript">
+<!--
+function enable_change(enable_change) {
+ var endis;
+
+ endis = !(document.iform.enable.checked || enable_change);
+ endis ? color = '#D4D0C8' : color = '#FFFFFF';
+
+ document.iform.netbiosname.disabled = endis;
+ document.iform.workgroup.disabled = endis;
+ document.iform.localmaster.disabled = endis;
+ document.iform.winssrv.disabled = endis;
+ document.iform.timesrv.disabled = endis;
+ document.iform.serverdesc.disabled = endis;
+ document.iform.doscharset.disabled = endis;
+ document.iform.unixcharset.disabled = endis;
+ document.iform.loglevel.disabled = endis;
+ document.iform.sndbuf.disabled = endis;
+ document.iform.rcvbuf.disabled = endis;
+ document.iform.recyclebin.disabled = endis;
+ document.iform.security.disabled = endis;
+ /* color adjustments */
+ document.iform.netbiosname.style.backgroundColor = color;
+ document.iform.workgroup.style.backgroundColor = color;
+ document.iform.localmaster.style.backgroundColor = color;
+ document.iform.winssrv.style.backgroundColor = color;
+ document.iform.timesrv.style.backgroundColor = color;
+ document.iform.serverdesc.style.backgroundColor = color;
+ document.iform.doscharset.style.backgroundColor = color;
+ document.iform.unixcharset.style.backgroundColor = color;
+ document.iform.loglevel.style.backgroundColor = color;
+ document.iform.sndbuf.style.backgroundColor = color;
+ document.iform.rcvbuf.style.backgroundColor = color;
+ document.iform.recyclebin.style.backgroundColor = color;
+ document.iform.security.style.backgroundColor = color;
+}
+//-->
+</script>
+
+EOD;
+
+$pfSenseHead->addScript($jscriptstr);
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="services_samba.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="100%" valign="middle" class="listtopic" colspan="2">
+ <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("CIFS share");?></span>
+ <span style="vertical-align: middle; position: relative; left: 84%;">
+ <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" />&nbsp;<?= gettext("Enable"); ?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication");?></td>
+ <td width="78%" class="vtable">
+ <select name="security" class="formselect" id="security">
+ <?php
+ $types = explode(",", "Anonymous,Local User,Domain");
+ $vals = explode(" ", "share user domain");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['security']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("NetBios name");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="netbiosname" type="text" class="formfld unknown" id="netbiosname" size="20" value="<?=htmlspecialchars($pconfig['netbiosname']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Workgroup");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="workgroup" type="text" class="formfld unknown" id="workgroup" size="20" value="<?=htmlspecialchars($pconfig['workgroup']);?>" />
+ <br />
+ <?= gettext("Workgroup to be member of.");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="serverdesc" type="text" class="formfld unknown" id="serverdesc" size="30" value="<?=htmlspecialchars($pconfig['serverdesc']);?>" />
+ <br />
+ <?= gettext("Server description. This can usually be left blank.");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Dos charset");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <select name="doscharset" class="formselect" id="doscharset">
+ <?php
+ $types = explode(",", "CP850,CP852,CP437,ASCII");
+ $vals = explode(" ", "CP850 CP852 CP437 ASCII");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['doscharset']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Unix charset");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <select name="unixcharset" class="formselect" id="unixcharset">
+ <?php
+ $types = explode(",", "UTF-8,iso-8859-1,iso-8859-15,gb2312,ASCII");
+ $vals = explode(" ", "UTF-8 iso-8859-1 iso-8859-15 gb2312 ASCII");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['unixcharset']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Log level");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <select name="loglevel" class="formselect" id="loglevel">
+ <?php
+ $types = explode(",", "Minimum,Normal,Full,Debug");
+ $vals = explode(" ", "1 2 3 10");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['loglevel']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Local Master Browser");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <select name="localmaster" class="formselect" id="localmaster">
+ <?php
+ $types = explode(",", "Yes,No");
+ $vals = explode(" ", "yes no");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['localmaster']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ <br />
+ <?= gettext("Allows FreeNAS to try and become a local master browser."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Time Server");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <select name="timesrv" class="formselect" id="timesrv">
+ <?php
+ $types = explode(",", "Yes,No");
+ $vals = explode(" ", "yes no");
+ $j = 0;
+
+ for ($j = 0; $j < count($vals); $j++):
+ ?>
+ <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['timesrv']) echo "selected=\"selected\"";?>>
+ <?=htmlspecialchars($types[$j]);?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ <br />
+ <?= gettext("FreeNAS advertises itself as a time server to Windows clients."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("WINS server");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="winssrv" type="text" class="formfld host" id="winssrv" size="30" value="<?=htmlspecialchars($pconfig['winssrv']);?>" />
+ <br />
+ <?= gettext("WINS Server IP address."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Recycle Bin");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="recyclebin" type="checkbox" id="recyclebin" value="yes" <?php if ($pconfig['recyclebin']) echo "checked=\"checked\""; ?> />
+ <?= gettext("Enable Recycle bin"); ?><br />
+ <?= gettext("This will create a recycle bin on the CIFS shares"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Share to hide.");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <?
+ $i=0;
+ foreach ($a_mount as $mountv) {
+ echo "<input name='hidemount[]' id='$i' type='checkbox' value='$mountv[sharename]'".
+ ((is_array($pconfig['hidemount']) && in_array($mountv['sharename'],$pconfig['hidemount'])) ? " checked=\"checked\"" : "") .
+ " />$mountv[sharename] <br />\n";
+ $i++;
+ }
+ ?>
+ <br />
+ <?= gettext("Select the CIFS share to hide from browsing."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Send Buffer Size");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="sndbuf" type="text" class="formfld unknown" id="sndbuf" size="30" value="<?=htmlspecialchars($pconfig['sndbuf']);?>" />
+ <br />
+ <?= gettext("Size of send buffer (16384 by default)."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Receive Buffer Size");?></td>
+ <td width="78%" class="vtable" align="left" valign="middle">
+ <input name="rcvbuf" type="text" class="formfld unknown" id="rcvbuf" size="30" value="<?=htmlspecialchars($pconfig['rcvbuf']);?>" />
+ <br />
+ <?= gettext("Size of receive buffer (16384 by default)."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>
diff --git a/packages/freenas/www/status_disks.php b/packages/freenas/www/status_disks.php
new file mode 100644
index 00000000..478d2e89
--- /dev/null
+++ b/packages/freenas/www/status_disks.php
@@ -0,0 +1,119 @@
+<?php
+/* $Id$ */
+/*
+ disks_manage_edit.php
+ part of FreeNAS (http://www.freenas.org)
+ Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>.
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array(gettext("Status"),
+ gettext("Disks"));
+
+require_once("guiconfig.inc");
+require_once("freenas_guiconfig.inc");
+require_once("freenas_functions.inc");
+
+if (!is_array($freenas_config['disks']['disk']))
+ $freenas_config['disks']['disk'] = array();
+
+disks_sort();
+
+$raidstatus=get_sraid_disks_list();
+
+$a_disk_conf = &$freenas_config['disks']['disk'];
+
+include("head.inc");
+/* put your custom HTML head content here */
+/* using some of the $pfSenseHead function calls */
+echo $pfSenseHead->getHTML();
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+ <div id="inputerrors"></div>
+ <form id="iform" name="iform" action="status_disks.php" method="post">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="5%" class="listhdrr">Disk</td>
+ <td width="5%" class="listhdrr">Size</td>
+ <td width="60%" class="listhdrr">Description</td>
+ <td width="10%" class="listhdr">Status</td>
+ </tr>
+ <?php foreach ($a_disk_conf as $disk): ?>
+ <tr>
+ <td class="listr">
+ <?=htmlspecialchars($disk['name']);?>
+ </td>
+ <td class="listr">
+ <?=htmlspecialchars($disk['size']);?>
+ </td>
+ <td class="listr">
+ <?=htmlspecialchars($disk['desc']);?>&nbsp;
+ </td>
+ <td class="listr">
+ <?php
+ $stat=disks_status($disk);
+ echo $stat;?>&nbsp;
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ <?php if (isset($raidstatus)): ?>
+ <?php foreach ($raidstatus as $diskk => $diskv): ?>
+ <tr>
+ <td class="listr">
+ <?=htmlspecialchars($diskk);?>
+ </td>
+ <td class="listr">
+ <?=htmlspecialchars($diskv['size']);?>
+ </td>
+ <td class="listr">
+
+ <?=htmlspecialchars("Software RAID volume");?>&nbsp;
+ </td>
+ <td class="listr">
+ <?=htmlspecialchars($diskv['desc']);?>&nbsp;
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ <?php endif; ?>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+<?= checkForInputErrors(); ?>
+<script type="text/javascript">
+<!--
+enable_change(false);
+//-->
+</script>
+</body>
+</html>