From 94be140cc8597228b2b7e07fbb85027fd0993b92 Mon Sep 17 00:00:00 2001 From: Daniel Stefan Haischt Date: Tue, 15 Aug 2006 15:06:54 +0000 Subject: initial version of a FreeNAS package --- packages/freenas/conf.default/config.xml | 179 +++ packages/freenas/conf.kernel/pfSense.6.freenas | 433 ++++++ .../diffs/netatalk-2.0.3-afpd-zeroconf.patch | 1386 +++++++++++++++++ packages/freenas/doc/README.txt | 46 + packages/freenas/pkg/freenas.xml | 345 +++++ packages/freenas/pkg/freenas_disks.inc | 899 +++++++++++ packages/freenas/pkg/freenas_functions.inc | 38 + packages/freenas/pkg/freenas_guiconfig.inc | 104 ++ packages/freenas/pkg/freenas_services.inc | 1600 ++++++++++++++++++++ packages/freenas/pkg/freenas_utils.inc | 675 +++++++++ packages/freenas/www/diag_ad_infos.php | 156 ++ packages/freenas/www/diag_ataidle_infos.php | 145 ++ packages/freenas/www/diag_disk_infos.php | 141 ++ packages/freenas/www/diag_fn_logs_daemon.php | 109 ++ packages/freenas/www/diag_fn_logs_ftp.php | 109 ++ packages/freenas/www/diag_fn_logs_rsyncd.php | 108 ++ packages/freenas/www/diag_fn_logs_samba.php | 165 ++ packages/freenas/www/diag_fn_logs_settings.php | 296 ++++ packages/freenas/www/diag_fn_logs_smartd.php | 109 ++ packages/freenas/www/diag_fn_logs_sshd.php | 108 ++ packages/freenas/www/diag_iscsi_infos.php | 133 ++ packages/freenas/www/diag_mounts_infos.php | 128 ++ packages/freenas/www/diag_part_infos.php | 134 ++ packages/freenas/www/diag_raid_infos.php | 135 ++ packages/freenas/www/diag_smart_infos.php | 133 ++ packages/freenas/www/diag_space_infos.php | 128 ++ packages/freenas/www/disks_manage.php | 203 +++ packages/freenas/www/disks_manage_edit.php | 276 ++++ packages/freenas/www/disks_manage_init.php | 294 ++++ packages/freenas/www/disks_manage_iscsi.php | 199 +++ packages/freenas/www/disks_mount.php | 208 +++ packages/freenas/www/disks_mount_edit.php | 279 ++++ packages/freenas/www/disks_raid_gmirror.php | 223 +++ packages/freenas/www/disks_raid_gmirror_edit.php | 267 ++++ packages/freenas/www/disks_raid_gmirror_infos.php | 132 ++ packages/freenas/www/disks_raid_gmirror_init.php | 167 ++ packages/freenas/www/disks_raid_gmirror_tools.php | 184 +++ packages/freenas/www/disks_raid_gvinum.php | 222 +++ packages/freenas/www/disks_raid_gvinum_edit.php | 266 ++++ packages/freenas/www/disks_raid_gvinum_infos.php | 132 ++ packages/freenas/www/disks_raid_gvinum_init.php | 169 +++ packages/freenas/www/disks_raid_gvinum_tools.php | 207 +++ packages/freenas/www/services_afp.php | 190 +++ packages/freenas/www/services_ftp.php | 347 +++++ packages/freenas/www/services_nfs.php | 219 +++ packages/freenas/www/services_rsyncd.php | 263 ++++ packages/freenas/www/services_rsyncd_client.php | 565 +++++++ packages/freenas/www/services_samba.php | 416 +++++ packages/freenas/www/status_disks.php | 119 ++ 49 files changed, 13489 insertions(+) create mode 100644 packages/freenas/conf.default/config.xml create mode 100644 packages/freenas/conf.kernel/pfSense.6.freenas create mode 100644 packages/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch create mode 100644 packages/freenas/doc/README.txt create mode 100644 packages/freenas/pkg/freenas.xml create mode 100644 packages/freenas/pkg/freenas_disks.inc create mode 100644 packages/freenas/pkg/freenas_functions.inc create mode 100644 packages/freenas/pkg/freenas_guiconfig.inc create mode 100644 packages/freenas/pkg/freenas_services.inc create mode 100644 packages/freenas/pkg/freenas_utils.inc create mode 100644 packages/freenas/www/diag_ad_infos.php create mode 100644 packages/freenas/www/diag_ataidle_infos.php create mode 100644 packages/freenas/www/diag_disk_infos.php create mode 100644 packages/freenas/www/diag_fn_logs_daemon.php create mode 100644 packages/freenas/www/diag_fn_logs_ftp.php create mode 100644 packages/freenas/www/diag_fn_logs_rsyncd.php create mode 100644 packages/freenas/www/diag_fn_logs_samba.php create mode 100644 packages/freenas/www/diag_fn_logs_settings.php create mode 100644 packages/freenas/www/diag_fn_logs_smartd.php create mode 100644 packages/freenas/www/diag_fn_logs_sshd.php create mode 100644 packages/freenas/www/diag_iscsi_infos.php create mode 100644 packages/freenas/www/diag_mounts_infos.php create mode 100644 packages/freenas/www/diag_part_infos.php create mode 100644 packages/freenas/www/diag_raid_infos.php create mode 100644 packages/freenas/www/diag_smart_infos.php create mode 100644 packages/freenas/www/diag_space_infos.php create mode 100644 packages/freenas/www/disks_manage.php create mode 100644 packages/freenas/www/disks_manage_edit.php create mode 100644 packages/freenas/www/disks_manage_init.php create mode 100644 packages/freenas/www/disks_manage_iscsi.php create mode 100644 packages/freenas/www/disks_mount.php create mode 100644 packages/freenas/www/disks_mount_edit.php create mode 100644 packages/freenas/www/disks_raid_gmirror.php create mode 100644 packages/freenas/www/disks_raid_gmirror_edit.php create mode 100644 packages/freenas/www/disks_raid_gmirror_infos.php create mode 100644 packages/freenas/www/disks_raid_gmirror_init.php create mode 100644 packages/freenas/www/disks_raid_gmirror_tools.php create mode 100644 packages/freenas/www/disks_raid_gvinum.php create mode 100644 packages/freenas/www/disks_raid_gvinum_edit.php create mode 100644 packages/freenas/www/disks_raid_gvinum_infos.php create mode 100644 packages/freenas/www/disks_raid_gvinum_init.php create mode 100644 packages/freenas/www/disks_raid_gvinum_tools.php create mode 100644 packages/freenas/www/services_afp.php create mode 100644 packages/freenas/www/services_ftp.php create mode 100644 packages/freenas/www/services_nfs.php create mode 100644 packages/freenas/www/services_rsyncd.php create mode 100644 packages/freenas/www/services_rsyncd_client.php create mode 100644 packages/freenas/www/services_samba.php create mode 100644 packages/freenas/www/status_disks.php 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 @@ + + + + 1.1 + + + freenas + local + + + admin + $1$KLfrklGE$9mMLCl/tNeqZJzdCJw6Gb0 + Etc/UTC + 300 + pool.ntp.org + + http + + + + + + + + + + + + sis0 + 192.168.1.250 + 24 + + + + + + + + + + + + + + + + + + + + freenas + WORKGROUP + FreeNAS Server + share + yes + + + + 5 + 2 + 300 + 21 + yes + yes + 0 + 0 + + + + + + + no + 873 + + + + 22 + + + + + + + + + + public + + + + + + + + + + + + + + + + 1002 + 1002 + + + \ 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 + #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 ++ * Purpose: Avahi based Zeroconf support ++ * Docs: http://avahi.org/download/doxygen/ ++ * ++ */ ++ ++#ifdef HAVE_CONFIG_H ++#include ++#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 ++ * Purpose: Avahi based Zeroconf support ++ * Docs: http://avahi.org/download/doxygen/ ++ * ++ */ ++ ++#ifndef AFPD_AVAHI_H ++#define AFPD_AVAHI_H ++ ++#include ++#include ++#include ++ ++#include ++#include ++ ++#include ++ ++#ifndef HAVE_AVAHI_THREADED_POLL ++#include ++#include /* SIG_BLOCK */ ++#else ++#include ++#endif ++ ++#include ++#include ++ ++#include ++ ++#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 ++ * 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 ++#include ++#include ++ ++#include /* DNSServiceRegister(), DNSServiceDiscoveryDeallocate() */ ++ ++#include ++ ++#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 ++ * Purpose: Bonjour based Zeroconf support ++ * Docs: http://developer.apple.com/documentation/Networking/Reference/DNSServiceDiscovery_CRef/dns_sd/ ++ * ++ */ ++ ++#ifdef HAVE_CONFIG_H ++#include ++#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 ++ * Purpose: Howl based Zeroconf support ++ * Doc: http://www.porchdogsoft.com/products/howl/docs/ ++ * ++ */ ++ ++#ifdef HAVE_CONFIG_H ++#include ++#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 ++ * Purpose: Howl based Zeroconf support ++ * Doc: http://www.porchdogsoft.com/products/howl/docs/ ++ * ++ */ ++ ++#ifndef AFPD_HOWL_H ++#define AFPD_HOWL_H ++ ++#include ++#include ++#include ++ ++#include ++ ++#include ++ ++#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 ++ * 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 /* htons() */ ++#include ++ ++# 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 ++ * Purpose: Zeroconf facade, that abstracts access to a ++ * particular Zeroconf implementation ++ * Doc: http://www.dns-sd.org/ ++ * ++ */ ++ ++#ifdef HAVE_CONFIG_H ++#include ++#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 + +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 @@ + + + freenas + 1.0 + System: Disks: Management + /usr/local/pkg/freenas.inc + + + FreeNAS Disks +
System
+ freenas.xml + /disk_manage.php +
+ + FreeNAS RAID +
System
+ /disks_raid_gmirror.php +
+ + FreeNAS Mounts +
System
+ /disks_mount.php +
+ + FreeNAS Infos +
Diagnostics
+ /diag_disk_infos.php +
+ + FreeNAS Logs +
Diagnostics
+ /diag_fn_logs_samba.php +
+ + Disk Status +
Status
+ /status_disks.php +
+ + dspam + /usr/local/etc/rc.d/dspam.sh + + + + ['installedpackages']['freenas']['config'] + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_manage.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_manage_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_manage_init.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_manage_iscsi.php + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_init.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gmirror_tools.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_init.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gvinum_tools.php + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_mount.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_mount_edit.php + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_ad_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_ataidle_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_disk_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_iscsi_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_mounts_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_part_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_raid_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_smart_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_space_infos.php + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_daemon.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_ftp.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_rsyncd.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_samba.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_settings.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_smartd.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/diag_fn_logs_sshd.php + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_afp.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_ftp.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_nfs.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_rsyncd.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_rsyncd_client.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_samba.php + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/status_disks.php + + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/pkg/freenas_disks.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/pkg/freenas_functions.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/pkg/freenas_guiconfig.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/pkg/freenas_services.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/pkg/freenas_utils.inc + + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/iscsi_initiator.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/ext2fs.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/geom_concat.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/geom_gpt.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/geom_mirror.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/geom_stripe.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/geom_vinum.ko + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/kernel.gz + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/ntfs.ko + + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/iscontrol + + + + + sync_package_freenas(); + + + custom_php_install_command(); + + + custom_php_deinstall_command(); + +
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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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
"; + + foreach ($detmount as $detmountk => $detmountv) + { + + //echo "debug, display detmountv[mdisk]: {$detmountv['mdisk']}
"; + + 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']}
"; + + 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 .= << $diskrv) + { + /* Get the disksize */ + $disksize=get_disks_size($diskrv); + /* Remove the ending 'B' in 'MB' */ + $disksize=rtrim($disksize, 'B'); + /* $raidconf .= << $diskrv) + { + $raidconf .= << $diskrv) + { + /* Get the disksize */ + $disksize=get_disks_size($diskrv); + /* Remove the ending 'B' in 'MB' */ + $disksize=rtrim($disksize, 'B'); + /* $raidconf .= <<=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 .= << {$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 @@ +. + 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 @@ +. + All rights reserved. + + Modified for FreeNAS (http://freenas.org) by Olivier Cochard + + 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 @@ +. + All rights reserved. + + Modified for FreeNAS (http://freenas.org) by Olivier Cochard + + 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 = << 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 .= << 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 .= << 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 .= << $sharev) + { + $syncscript .= << + + + + @SERVICE_DESC@ on %h + + + @TYPE@ + @PORT@ + @TXT_RECORDS@ + + + + +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 = << \ 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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: 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ AD Authentication disable
"; + } else { + echo "
";
+            	echo "Accessiblity test to MS domain:
"; + echo htmlspecialchars("Results for net rpc testjoin:") . "
"; + + exec("/usr/local/bin/net rpc testjoin",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($rawdata); + + echo "
"; + echo htmlspecialchars("Ping winbindd to see if it is alive:") . "
"; + + exec("/usr/local/bin/wbinfo -p",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($rawdata); + + echo "
"; + echo htmlspecialchars("Check shared secret:") . "
"; + + exec("/usr/local/bin/wbinfo -t",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($rawdata); + + echo "
"; + echo "
"; + } + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + $disklist=get_ata_disks_list(); + + echo "List of Advanced ATA capabilities on all ATA disk:
"; + 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:") . "
"; + $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) . "
"; + } + unset ($rawdata); + } + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + + echo "List of detected ATA disks:
"; + foreach ($iderawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + + unset ($line); + + exec("/sbin/camcontrol devlist",$scsirawdata); + + echo "List of detected SCSI disks:
"; + foreach ($scsirawdata as $line) + { + echo htmlspecialchars($line) . "
"; + + } + + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + 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(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + +
+ Last Daemon log entries +
 
+ +
+
+
+
+ + + 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 @@ +. + 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(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + +
+ Last FTP log entries +
 
+ +
+
+
+
+ + + 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 @@ +. + 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(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + +
+ Last RSYNCD log entries +
 
+ +
+
+
+
+ + + 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 @@ +. + 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(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Last nmbd service log entries +
+
+
 
+ Last smbd service log entries +
+
+
 
+ Last winbindd service log entries +
+
+
 
+ +
+
+
+
+ + + 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 @@ +. + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  /> +
 : +
  /> +
+
  /> +
+
  onclick="enable_change(false)" /> +
  onclick="enable_change(false)" /> +
Remote syslog + server + +
+

+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+ /> +
+
  +
 :
+ +
+
+
+
+ + + + 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 @@ +. + 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(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + +
+ Last SmartD log entries +
 
+ +
+
+
+
+ + + 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 @@ +. + 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(); + +?> + + +
+
+ + + + + + + +
+ +
+
+ + + + + + + + + + + +
+ Last SSHD log entries +
 
+ +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ iSCSI initiator disabled
"; + } else { + echo "
";
+            	echo "Show the list of available target Name on the iSCSI target
"; + + exec("/usr/local/sbin/iscontrol -d targetaddress={$freenas_config['iscsi']['targetaddress']}",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($rawdata); + echo "
"; + } + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + echo "List of mounted point:
"; + exec("/sbin/mount",$mountrawdata); + foreach ($mountrawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($line); + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + + $disklist = get_physical_disks_list(); + + echo "List of partition on all detected disk:
"; + foreach ($disklist as $disknamek => $disknamev) + { + exec("/sbin/fdisk $disknamek",$fdiskrawdata); + foreach ($fdiskrawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($fdiskrawdata); + } + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + echo "Software RAID - gmirror status:
"; + exec("/sbin/gmirror list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "
"; + } + unset ($line); + unset ($rawdata); + + echo "Software RAID - gvinum status:
"; + exec("/sbin/gvinum list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "
"; + } + unset ($line); + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + $disklist = get_physical_disks_list(); + + echo "List of SMART capabilities on all detected disk:
"; + foreach ($disklist as $disknamek => $disknamev) + { + exec("/usr/local/sbin/smartctl -a /dev/$disknamek",$fdiskrawdata); + foreach ($fdiskrawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($fdiskrawdata); + } + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + +
+ "; + exec("/bin/df -h",$rawdata); + + echo "Free Space:
"; + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + echo ""; + ?> +
+
+
+
+ + + 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 +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + All rights reserved. + + Copyright (C) 2003-2005 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +" . + gettext("You must apply the changes in order for them to take effect."));?> + + +
+ + + + + +
+ +
+ +
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ Do not set this for CF cards."); ?> +
+ +
+ Do not set this for CF cards."); ?> +
+ +
+ Do not set this for CF cards."); ?> +
+ +
+ + Leave \"unformated\" for unformated disk and then use Format menu."); ?> +
  + " /> + + + +
+
+ + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ +
  + " /> +
+ '); + 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(''); + } + ?> +
+ + WARNING: + +
+ + + + +
+
+
+
+ + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+ + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+
+ +
+
  + " /> +
+
+
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + + +
+ +" . + gettext("You must apply the changes in order for them to take effect."));?> + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
+   + +   + +   + +   + +   + + retry"; + else + echo $stat; + } + ?>  + + + " width="17" height="17" border="0" alt="" /> + + + ');" title="" width="17" height="17" border="0" alt="" /> + +
+ + " width="17" height="17" border="0" alt="" /> + +
+ + Note: + +
+ + + +
+ + previously configured disk + +
+
+ + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
  + " /> + + + +
+ + : + +
    +
  1. + + + + + +
  2. +
  3. +
+
+
+ + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +" . + gettext("You must apply the changes in order for them to take effect."));?> + + +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
 
+ + + + +   + +   + + + " width="17" height="17" border="0" alt="" /> + + + " width="17" height="17" border="0" alt="" /> + +
+ + " width="17" height="17" border="0" alt="" /> + +
+ + + +
+ +
+ +
+ + +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+ RAID 1 () +
+ +
+
+ $diskv[name] ($diskv[size], $diskv[desc])" . (($r_name) ? " - assigned to $r_name" : "") . "
\n"; + } + + $i++; + } + + if ($disable_script) + echo "\n"; + ?> +
  + + + + +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + +
+ "; + echo "" . gettext("Software RAID information and status") . "
"; + + exec("/sbin/gmirror list",$rawdata); + foreach ($rawdata as $line){ + echo htmlspecialchars($line) . "
"; + } + + unset ($line); + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + +
+ +
  + + + + +
+ " . gettext("Disk format UFS output:") . "
"); + echo('
');
+    					ob_end_flush();
+    					
+    					/* Create filesystem */
+    					system("/sbin/newfs -U /dev/mirror/" . escapeshellarg($disk));
+    										
+    					echo('
'); + } + ?> +
+ + WARNING:
+
+ + + +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ +
+ +
  + + + + +
+ " . gettext("GMIRROR command output:") . "
"); + echo('
');
+    					  ob_end_flush();
+    					
+    					  system("/sbin/gmirror $action " . escapeshellarg($object));
+    				
+    					  echo('
'); + } + ?> +
+ + WARNING:
+
+
    +
  1. +
  2. +
+
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ +" . + gettext("You must apply the changes in order for them to take effect."));?> + + +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
 
+ + + + +   + +   + + + " width="17" height="17" border="0" alt="" /> + + + " width="17" height="17" border="0" alt="" /> + +
+ + " width="17" height="17" border="0" alt="" /> + +
+ + + +
+ +
+ +
+ +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + +
+ +
+ +
+ $diskv[name] ($diskv[size], $diskv[desc])" . (($r_name) ? " - assigned to $r_name" : "") . "
\n"; + } + $i++; + } + if ($disable_script) echo "\n"; + ?> +
  + + + + +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + +
+ "; + echo "" . gettext("Software RAID information and status") . "
"; + + exec("/sbin/gvinum list",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "
"; + } + unset ($line); + echo ""; + ?> +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + +
+ +
  + + + + +
+ _DISKSRAIDINITPHP_INFO
"); + echo('
');
+      					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('
'); + } + ?> +
+ + WARNING:
+
+ + + +
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ +
+ +
  + + + + +
+ " . gettext("GVINUM command output:") . "
"); + echo('
');
+      					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('
'); + } + ?> +
+ + WARNING:
+
+
    +
  1. +
  2. +
+
+
+
+
+ + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+ /> +
+ /> + +
  + " /> +
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ /> + +
+ /> + +
+ +
+ +
+ /> + +
+ +
+ /> + +
+ +
+ + +
+ + +
+ + +
  + " /> +
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+ +
+ + / + +
+ +
  + " /> +
  + + + + + + +
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+ + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
  + " /> +
+
+
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+ + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+ +
+ /> + +
+ "; + echo $mountv['sharename'] . " (" . $mountv['desc'] . ")
\n"; + $i++; + } + } + else + echo "You must configure mount point before!"; + ?> +
+ +
+ + + + + + + + + + + + + + + + + + +
+
+ /> +
+ /> + +
+
+ + + +
+
+
+ /> +
+ /> + +
+
+ +
+
+
+ /> +
+ /> + +
+
+ + +
+
+
+ /> +
+ /> + +
+
+ +
+
+
+ /> +
+ /> + +
+
+ +
+
+ +
+
  + " /> +
+
+
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + onClick="enable_change(false)" />  + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ /> +
+ +
+ $mountv[sharename]
\n"; + $i++; + } + ?> +
+ +
+ +
+ +
+ +
+ +
  + " /> +
+
+ + + + + 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 @@ +. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper . + 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(); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + $diskv): ?> + + + + + + + + +
DiskSizeDescriptionStatus
+ + + + +   + +   +
+ + + + + +   + +   +
+
+ + + + + -- cgit v1.2.3