From 55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Fri, 6 Feb 2009 19:18:00 -0600 Subject: mv packages to config dir to match web layout --- config/freenas/bin/ext2fs.ko | Bin 0 -> 61544 bytes config/freenas/bin/geom_concat.ko | Bin 0 -> 20068 bytes config/freenas/bin/geom_gpt.ko | Bin 0 -> 6277 bytes config/freenas/bin/geom_mirror.ko | Bin 0 -> 78213 bytes config/freenas/bin/geom_stripe.ko | Bin 0 -> 24734 bytes config/freenas/bin/geom_vinum.ko | Bin 0 -> 70268 bytes config/freenas/bin/iscontrol | Bin 0 -> 86231 bytes config/freenas/bin/iscsi_initiator.ko | Bin 0 -> 47530 bytes config/freenas/bin/kernel.gz | Bin 0 -> 3798453 bytes config/freenas/bin/mountd | Bin 0 -> 27112 bytes config/freenas/bin/nfsd | Bin 0 -> 14004 bytes config/freenas/bin/ntfs.ko | Bin 0 -> 44199 bytes config/freenas/bin/rpc.lockd | Bin 0 -> 39404 bytes config/freenas/bin/rpc.statd | Bin 0 -> 11724 bytes config/freenas/bin/rpcbind | Bin 0 -> 39540 bytes config/freenas/conf.default/config.xml | 179 ++ config/freenas/conf.kernel/pfSense.6.freenas | 433 +++++ .../diffs/netatalk-2.0.3-afpd-zeroconf.patch | 1386 ++++++++++++++ config/freenas/doc/README.txt | 52 + config/freenas/pkg/freenas.inc | 297 +++ config/freenas/pkg/freenas.xml | 570 ++++++ config/freenas/pkg/freenas_config.inc | 45 + config/freenas/pkg/freenas_disks.inc | 1256 ++++++++++++ config/freenas/pkg/freenas_functions.inc | 49 + config/freenas/pkg/freenas_guiconfig.inc | 288 +++ config/freenas/pkg/freenas_services.inc | 2025 ++++++++++++++++++++ config/freenas/pkg/freenas_system.inc | 838 ++++++++ config/freenas/pkg/freenas_utils.inc | 1049 ++++++++++ config/freenas/pkg/rc.freenas | 102 + config/freenas/www/diag_ad_infos.php | 159 ++ config/freenas/www/diag_ataidle_infos.php | 149 ++ config/freenas/www/diag_disk_infos.php | 143 ++ config/freenas/www/diag_fn_logs_daemon.php | 119 ++ config/freenas/www/diag_fn_logs_ftp.php | 118 ++ config/freenas/www/diag_fn_logs_rsyncd.php | 117 ++ config/freenas/www/diag_fn_logs_samba.php | 174 ++ config/freenas/www/diag_fn_logs_settings.php | 310 +++ config/freenas/www/diag_fn_logs_smartd.php | 118 ++ config/freenas/www/diag_fn_logs_sshd.php | 117 ++ config/freenas/www/diag_iscsi_infos.php | 142 ++ config/freenas/www/diag_mounts_infos.php | 137 ++ config/freenas/www/diag_part_infos.php | 141 ++ config/freenas/www/diag_raid_infos.php | 163 ++ config/freenas/www/diag_smart_infos.php | 141 ++ config/freenas/www/diag_space_infos.php | 136 ++ config/freenas/www/disks_manage.php | 208 ++ config/freenas/www/disks_manage_edit.php | 275 +++ config/freenas/www/disks_manage_init.php | 511 +++++ config/freenas/www/disks_manage_iscsi.php | 209 ++ config/freenas/www/disks_manage_tools.php | 331 ++++ config/freenas/www/disks_mount.php | 235 +++ config/freenas/www/disks_mount_edit.php | 307 +++ config/freenas/www/disks_mount_tools.php | 233 +++ config/freenas/www/disks_raid_gconcat.php | 236 +++ config/freenas/www/disks_raid_gconcat_edit.php | 256 +++ config/freenas/www/disks_raid_gconcat_infos.php | 143 ++ config/freenas/www/disks_raid_gconcat_tools.php | 187 ++ config/freenas/www/disks_raid_gmirror.php | 236 +++ config/freenas/www/disks_raid_gmirror_edit.php | 277 +++ config/freenas/www/disks_raid_gmirror_infos.php | 143 ++ config/freenas/www/disks_raid_gmirror_init.php | 179 ++ config/freenas/www/disks_raid_gmirror_tools.php | 191 ++ config/freenas/www/disks_raid_graid5.php | 236 +++ config/freenas/www/disks_raid_graid5_edit.php | 258 +++ config/freenas/www/disks_raid_graid5_infos.php | 143 ++ config/freenas/www/disks_raid_graid5_tools.php | 190 ++ config/freenas/www/disks_raid_gstripe.php | 236 +++ config/freenas/www/disks_raid_gstripe_edit.php | 258 +++ config/freenas/www/disks_raid_gstripe_infos.php | 143 ++ config/freenas/www/disks_raid_gstripe_tools.php | 187 ++ config/freenas/www/disks_raid_gvinum.php | 235 +++ config/freenas/www/disks_raid_gvinum_edit.php | 277 +++ config/freenas/www/disks_raid_gvinum_infos.php | 144 ++ config/freenas/www/disks_raid_gvinum_init.php | 181 ++ config/freenas/www/disks_raid_gvinum_tools.php | 220 +++ config/freenas/www/services_afp.php | 199 ++ config/freenas/www/services_ftp.php | 392 ++++ config/freenas/www/services_nfs.php | 243 +++ config/freenas/www/services_nfs_export.php | 165 ++ config/freenas/www/services_nfs_export_edit.php | 783 ++++++++ config/freenas/www/services_rsyncd.php | 277 +++ config/freenas/www/services_rsyncd_client.php | 585 ++++++ config/freenas/www/services_rsyncd_local.php | 579 ++++++ config/freenas/www/services_samba.php | 431 +++++ config/freenas/www/services_samba_share.php | 165 ++ config/freenas/www/services_samba_share_edit.php | 157 ++ config/freenas/www/services_unison.php | 249 +++ config/freenas/www/status_disks.php | 127 ++ 88 files changed, 22170 insertions(+) create mode 100644 config/freenas/bin/ext2fs.ko create mode 100644 config/freenas/bin/geom_concat.ko create mode 100644 config/freenas/bin/geom_gpt.ko create mode 100644 config/freenas/bin/geom_mirror.ko create mode 100644 config/freenas/bin/geom_stripe.ko create mode 100644 config/freenas/bin/geom_vinum.ko create mode 100644 config/freenas/bin/iscontrol create mode 100644 config/freenas/bin/iscsi_initiator.ko create mode 100644 config/freenas/bin/kernel.gz create mode 100644 config/freenas/bin/mountd create mode 100644 config/freenas/bin/nfsd create mode 100644 config/freenas/bin/ntfs.ko create mode 100644 config/freenas/bin/rpc.lockd create mode 100644 config/freenas/bin/rpc.statd create mode 100644 config/freenas/bin/rpcbind create mode 100644 config/freenas/conf.default/config.xml create mode 100644 config/freenas/conf.kernel/pfSense.6.freenas create mode 100644 config/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch create mode 100644 config/freenas/doc/README.txt create mode 100644 config/freenas/pkg/freenas.inc create mode 100644 config/freenas/pkg/freenas.xml create mode 100644 config/freenas/pkg/freenas_config.inc create mode 100644 config/freenas/pkg/freenas_disks.inc create mode 100644 config/freenas/pkg/freenas_functions.inc create mode 100644 config/freenas/pkg/freenas_guiconfig.inc create mode 100644 config/freenas/pkg/freenas_services.inc create mode 100644 config/freenas/pkg/freenas_system.inc create mode 100644 config/freenas/pkg/freenas_utils.inc create mode 100644 config/freenas/pkg/rc.freenas create mode 100644 config/freenas/www/diag_ad_infos.php create mode 100644 config/freenas/www/diag_ataidle_infos.php create mode 100644 config/freenas/www/diag_disk_infos.php create mode 100644 config/freenas/www/diag_fn_logs_daemon.php create mode 100644 config/freenas/www/diag_fn_logs_ftp.php create mode 100644 config/freenas/www/diag_fn_logs_rsyncd.php create mode 100644 config/freenas/www/diag_fn_logs_samba.php create mode 100644 config/freenas/www/diag_fn_logs_settings.php create mode 100644 config/freenas/www/diag_fn_logs_smartd.php create mode 100644 config/freenas/www/diag_fn_logs_sshd.php create mode 100644 config/freenas/www/diag_iscsi_infos.php create mode 100644 config/freenas/www/diag_mounts_infos.php create mode 100644 config/freenas/www/diag_part_infos.php create mode 100644 config/freenas/www/diag_raid_infos.php create mode 100644 config/freenas/www/diag_smart_infos.php create mode 100644 config/freenas/www/diag_space_infos.php create mode 100644 config/freenas/www/disks_manage.php create mode 100644 config/freenas/www/disks_manage_edit.php create mode 100644 config/freenas/www/disks_manage_init.php create mode 100644 config/freenas/www/disks_manage_iscsi.php create mode 100644 config/freenas/www/disks_manage_tools.php create mode 100644 config/freenas/www/disks_mount.php create mode 100644 config/freenas/www/disks_mount_edit.php create mode 100644 config/freenas/www/disks_mount_tools.php create mode 100644 config/freenas/www/disks_raid_gconcat.php create mode 100644 config/freenas/www/disks_raid_gconcat_edit.php create mode 100644 config/freenas/www/disks_raid_gconcat_infos.php create mode 100644 config/freenas/www/disks_raid_gconcat_tools.php create mode 100644 config/freenas/www/disks_raid_gmirror.php create mode 100644 config/freenas/www/disks_raid_gmirror_edit.php create mode 100644 config/freenas/www/disks_raid_gmirror_infos.php create mode 100644 config/freenas/www/disks_raid_gmirror_init.php create mode 100644 config/freenas/www/disks_raid_gmirror_tools.php create mode 100644 config/freenas/www/disks_raid_graid5.php create mode 100644 config/freenas/www/disks_raid_graid5_edit.php create mode 100644 config/freenas/www/disks_raid_graid5_infos.php create mode 100644 config/freenas/www/disks_raid_graid5_tools.php create mode 100644 config/freenas/www/disks_raid_gstripe.php create mode 100644 config/freenas/www/disks_raid_gstripe_edit.php create mode 100644 config/freenas/www/disks_raid_gstripe_infos.php create mode 100644 config/freenas/www/disks_raid_gstripe_tools.php create mode 100644 config/freenas/www/disks_raid_gvinum.php create mode 100644 config/freenas/www/disks_raid_gvinum_edit.php create mode 100644 config/freenas/www/disks_raid_gvinum_infos.php create mode 100644 config/freenas/www/disks_raid_gvinum_init.php create mode 100644 config/freenas/www/disks_raid_gvinum_tools.php create mode 100644 config/freenas/www/services_afp.php create mode 100644 config/freenas/www/services_ftp.php create mode 100644 config/freenas/www/services_nfs.php create mode 100644 config/freenas/www/services_nfs_export.php create mode 100644 config/freenas/www/services_nfs_export_edit.php create mode 100644 config/freenas/www/services_rsyncd.php create mode 100644 config/freenas/www/services_rsyncd_client.php create mode 100644 config/freenas/www/services_rsyncd_local.php create mode 100644 config/freenas/www/services_samba.php create mode 100644 config/freenas/www/services_samba_share.php create mode 100644 config/freenas/www/services_samba_share_edit.php create mode 100644 config/freenas/www/services_unison.php create mode 100644 config/freenas/www/status_disks.php (limited to 'config/freenas') diff --git a/config/freenas/bin/ext2fs.ko b/config/freenas/bin/ext2fs.ko new file mode 100644 index 00000000..042b4bb8 Binary files /dev/null and b/config/freenas/bin/ext2fs.ko differ diff --git a/config/freenas/bin/geom_concat.ko b/config/freenas/bin/geom_concat.ko new file mode 100644 index 00000000..f1c40215 Binary files /dev/null and b/config/freenas/bin/geom_concat.ko differ diff --git a/config/freenas/bin/geom_gpt.ko b/config/freenas/bin/geom_gpt.ko new file mode 100644 index 00000000..308b017b Binary files /dev/null and b/config/freenas/bin/geom_gpt.ko differ diff --git a/config/freenas/bin/geom_mirror.ko b/config/freenas/bin/geom_mirror.ko new file mode 100644 index 00000000..50a5f5ac Binary files /dev/null and b/config/freenas/bin/geom_mirror.ko differ diff --git a/config/freenas/bin/geom_stripe.ko b/config/freenas/bin/geom_stripe.ko new file mode 100644 index 00000000..dd8e6a4d Binary files /dev/null and b/config/freenas/bin/geom_stripe.ko differ diff --git a/config/freenas/bin/geom_vinum.ko b/config/freenas/bin/geom_vinum.ko new file mode 100644 index 00000000..c550fc83 Binary files /dev/null and b/config/freenas/bin/geom_vinum.ko differ diff --git a/config/freenas/bin/iscontrol b/config/freenas/bin/iscontrol new file mode 100644 index 00000000..f2e3f409 Binary files /dev/null and b/config/freenas/bin/iscontrol differ diff --git a/config/freenas/bin/iscsi_initiator.ko b/config/freenas/bin/iscsi_initiator.ko new file mode 100644 index 00000000..94a07423 Binary files /dev/null and b/config/freenas/bin/iscsi_initiator.ko differ diff --git a/config/freenas/bin/kernel.gz b/config/freenas/bin/kernel.gz new file mode 100644 index 00000000..9d9eb3f2 Binary files /dev/null and b/config/freenas/bin/kernel.gz differ diff --git a/config/freenas/bin/mountd b/config/freenas/bin/mountd new file mode 100644 index 00000000..55682c7b Binary files /dev/null and b/config/freenas/bin/mountd differ diff --git a/config/freenas/bin/nfsd b/config/freenas/bin/nfsd new file mode 100644 index 00000000..311f1fca Binary files /dev/null and b/config/freenas/bin/nfsd differ diff --git a/config/freenas/bin/ntfs.ko b/config/freenas/bin/ntfs.ko new file mode 100644 index 00000000..1e923dac Binary files /dev/null and b/config/freenas/bin/ntfs.ko differ diff --git a/config/freenas/bin/rpc.lockd b/config/freenas/bin/rpc.lockd new file mode 100644 index 00000000..906a8641 Binary files /dev/null and b/config/freenas/bin/rpc.lockd differ diff --git a/config/freenas/bin/rpc.statd b/config/freenas/bin/rpc.statd new file mode 100644 index 00000000..c630a05a Binary files /dev/null and b/config/freenas/bin/rpc.statd differ diff --git a/config/freenas/bin/rpcbind b/config/freenas/bin/rpcbind new file mode 100644 index 00000000..882d9c4d Binary files /dev/null and b/config/freenas/bin/rpcbind differ diff --git a/config/freenas/conf.default/config.xml b/config/freenas/conf.default/config.xml new file mode 100644 index 00000000..74ed6186 --- /dev/null +++ b/config/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/config/freenas/conf.kernel/pfSense.6.freenas b/config/freenas/conf.kernel/pfSense.6.freenas new file mode 100644 index 00000000..aee11302 --- /dev/null +++ b/config/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/config/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch b/config/freenas/diffs/netatalk-2.0.3-afpd-zeroconf.patch new file mode 100644 index 00000000..74ee8795 --- /dev/null +++ b/config/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/config/freenas/doc/README.txt b/config/freenas/doc/README.txt new file mode 100644 index 00000000..8183022f --- /dev/null +++ b/config/freenas/doc/README.txt @@ -0,0 +1,52 @@ +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. + +*** NOTES *** + +You should be aware that this package installes a custom +kernel and some additional kernel modules. + +YOU NEED TO REBOOT YOUR pfSense SYSTEM AFTER HAVING INSTALLED +THIS PACKAGE!!! + +Additionally, if you are going to enable the FTP service, you +need to disable the FTP helper on each interface. + +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/config/freenas/pkg/freenas.inc b/config/freenas/pkg/freenas.inc new file mode 100644 index 00000000..b87ebfe6 --- /dev/null +++ b/config/freenas/pkg/freenas.inc @@ -0,0 +1,297 @@ + + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé . + 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. + */ +/* ========================================================================== */ + +require_once("freenas_config.inc"); + +function sync_package_freenas() { +} + +function oninstall_copy_kernel_binaries($action = "install") { + $binaries = array(); + $binaries[] = array("source" => "/usr/local/pkg/iscsi_initiator.ko", + "target" => "/boot/kernel/iscsi_initiator.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/ext2fs.ko", + "target" => "/boot/kernel/ext2fs.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/geom_concat.ko", + "target" => "/boot/kernel/geom_concat.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/geom_gpt.ko", + "target" => "/boot/kernel/geom_gpt.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/geom_mirror.ko", + "target" => "/boot/kernel/geom_mirror.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/geom_stripe.ko", + "target" => "/boot/kernel/geom_stripe.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/geom_vinum.ko", + "target" => "/boot/kernel/geom_vinum.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/ntfs.ko", + "target" => "/boot/kernel/ntfs.ko", + "backup" => false); + $binaries[] = array("source" => "/usr/local/pkg/kernel.gz", + "target" => "/boot/kernel/kernel.gz", + "backup" => true); + + if ($action == "install") { + while (list(, $val) = each($binaries)) { + $static_output .= "FreeNAS: Moving binary file... "; + update_output_window($static_output); + if ($val['backup'] && file_exists($val['target'])) + rename($val['target'], "{$val['target']}.org"); + rename($val['source'], $val['target']); + $static_output .= "done.\n"; + update_output_window($static_output); + } + } else if ($action == "deinstall") { + while (list($source, $target) = each($binaries)) { + $static_output .= "FreeNAS: Removing binary file... "; + update_output_window($static_output); + unlink($target); + $static_output .= "done.\n"; + update_output_window($static_output); + } + } +} + +function remove_package_contents($pkg = "") { + if ($pkg == "") { return; } + + $pd = popen("pkg_info -rf {$pkg}", "r"); + + if (! pd) { return; } + + while (! feof($pd)) { + $buffer = fgets($pd, 4096); + + if (strpos($buffer, "File:") !== false) { + $file = trim(str_replace("File:", "", $buffer)); + + if (strpos($file, "man/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "share/doc/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "share/aclocal/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "include/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "libdata/pkgconfig/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "info/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "etc/rc.d/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } else if (strpos($file, "etc/") !== false) { + if (strpos($file, ".dist") !== false || + strpos($file, ".sample") !== false || + strpos($file, ".example") !== false || + strpos($file, ".default") !== false || + strpos($file, ".sh") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } + } else if (strpos($file, "share/examples/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } + + /* What about locales? */ + /* + } else if (strpos($file, "share/local/") !== false) { + unlink_if_exists("/usr/local/{$file}"); + } + */ + } + } + + fclose ($pd); +} + +function adjust_package_contents() { + remove_package_contents("avahi+libdns-0.6.12"); + remove_package_contents("ataidle-0.9"); + remove_package_contents("perl-5.8.8"); + remove_package_contents("libiconv-1.9.2_2"); + remove_package_contents("libxml2-2.6.26"); + remove_package_contents("gettext-0.14.5_2"); + remove_package_contents("glib-2.10.3"); + remove_package_contents("expat-2.0.0_1"); + remove_package_contents("wzdftpd-0.7.2_1"); + remove_package_contents("e2fsprogs-1.39_1"); + remove_package_contents("smartmontools-5.36"); + remove_package_contents("aaccli-1.0"); + remove_package_contents("rsync-2.6.8_2"); + remove_package_contents("scponly-4.6_1"); + remove_package_contents("cracklib-2.7_2"); + remove_package_contents("samba-3.0.23,1"); + remove_package_contents("netatalk-2.0.3_3,1"); + remove_package_contents("pam_ldap-1.8.2"); +} + +function oninstall_copy_misc_binaries($action = "install") { + $binaries = array(); + $binaries[] = array("source" => "/usr/local/pkg/iscontrol", + "target" => "/usr/local/sbin/iscontrol"); + $binaries[] = array("source" => "/usr/local/pkg/nfsd", + "target" => "/usr/sbin/nfsd"); + $binaries[] = array("source" => "/usr/local/pkg/nfsd", + "target" => "/usr/sbin/mountd"); + $binaries[] = array("source" => "/usr/local/pkg/rpcbind", + "target" => "/usr/sbin/rpcbind"); + $binaries[] = array("source" => "/usr/local/pkg/rpc.lockd", + "target" => "/usr/sbin/rpc.lockd"); + $binaries[] = array("source" => "/usr/local/pkg/rpc.lockd", + "target" => "/usr/sbin/rpc.lockd"); + + if ($action == "install") { + while (list(, $val) = each($binaries)) { + $static_output .= "FreeNAS: Installing binary file... "; + update_output_window($static_output); + mwexec("install -s {$source} ${target}"); + $static_output .= "done.\n"; + update_output_window($static_output); + } + } else if ($action == "deinstall") { + while (list($val['source'], $val['target']) = each($binaries)) { + $static_output .= "FreeNAS: Removing binary file... "; + update_output_window($static_output); + unlink($target); + $static_output .= "done.\n"; + update_output_window($static_output); + } + } +} + +function oninstall_setup_config() { + global $config; + + $config['system']['zeroconf_disable'] = "yes"; + + $freenas_config =& $config['installedpackages']['freenas']['config'][0]; + + if (!is_array($freenas_config['disks'])) + $freenas_config['disks'] = array(); + if (!is_array($freenas_config['mounts'])) + $freenas_config['mounts'] = array(); + + if (!is_array($freenas_config['samba'])) + $freenas_config['samba'] = array(); + $freenas_config['samba']['netbiosname'] = "freenas"; + $freenas_config['samba']['workgroup'] = "WORKGROUP"; + $freenas_config['samba']['serverdesc'] = "pfSense Server"; + $freenas_config['samba']['security'] = "share"; + $freenas_config['samba']['localmaster'] = "yes"; + + if (!is_array($freenas_config['ftp'])) + $freenas_config['ftp'] = array(); + $freenas_config['ftp']['numberclients'] = "5"; + $freenas_config['ftp']['maxconperip'] = "2"; + $freenas_config['ftp']['timeout'] = "300"; + $freenas_config['ftp']['port'] = "21"; + $freenas_config['ftp']['anonymous'] = "yes"; + $freenas_config['ftp']['pasv_max_port'] = "0"; + $freenas_config['ftp']['pasv_min_port'] = "0"; + + if (!is_array($freenas_config['afp'])) + $freenas_config['afp'] = array(); + + if (!is_array($freenas_config['rsyncd'])) + $freenas_config['rsyncd'] = array(); + $freenas_config['rsyncd']['readonly'] = "no"; + $freenas_config['rsyncd']['port'] = "873"; + + if (!is_array($freenas_config['nfs'])) + $freenas_config['nfs'] = array(); +} + +function custom_php_install_command() { + global $g; + + oninstall_copy_kernel_binaries(); + oninstall_copy_misc_binaries(); + adjust_package_contents(); + oninstall_setup_config(); + + if (! file_exists("/usr/local/etc/rc.d")) + mwexec("mkdir -p /usr/local/etc/rc.d"); + + if (! file_exists("{$g['varrun_path']}/dbus")) + mkdir("{$g['varrun_path']}/dbus"); + + if (! file_exists("{$g['varrun_path']}/avahi-daemon")) + mkdir("{$g['varrun_path']}/avahi-daemon"); + + rename("/usr/local/pkg/rc.freenas", "/usr/local/etc/rc.d/freenas.sh"); + chmod ("/usr/local/etc/rc.d/freenas.sh", 0755); + + mwexec("ln -s /usr/local/etc/uams/uams_passwd.so /usr/local/etc/uams/uams_clrtxt.so"); + mwexec("ln -s /usr/local/etc/uams/uams_dhx_passwd.so /usr/local/etc/uams/uams_dhx.so"); + /* hack cause I linked netatalk against db44 instead of db42 */ + mwexec("ln -s /usr/local/lib/libdb-4.4.so.0 /usr/local/lib/libdb-4.2.so.2"); +} + +function custom_php_deinstall_command() { + global $config, $g; + + oninstall_copy_kernel_binaries("deinstall"); + oninstall_copy_misc_binaries("deinstall"); + + if (! file_exists("/usr/local/etc/rc.d")) + mwexec("rm -rf /usr/local/etc/rc.d"); + + if (! file_exists("{$g['varrun_path']}/dbus")) + mwexec("rm -rf {$g['varrun_path']}/dbus"); + + if (! file_exists("{$g['varrun_path']}/avahi-daemon")) + mwexec("rm -rf {$g['varrun_path']}/avahi-daemon"); + + unlink_if_exists("/usr/local/etc/uams/uams_clrtxt.so"); + unlink_if_exists("/usr/local/etc/uams/uams_dhx.so"); + unlink_if_exists("/usr/local/etc/rc.d/freenas.sh"); + unlink_if_exists("/usr/local/lib/libdb-4.2.so.2"); + + unset($config['installedpackages']['freenas']); + write_config(); + conf_mount_ro(); +} +?> diff --git a/config/freenas/pkg/freenas.xml b/config/freenas/pkg/freenas.xml new file mode 100644 index 00000000..edac8085 --- /dev/null +++ b/config/freenas/pkg/freenas.xml @@ -0,0 +1,570 @@ + + + + + + + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + freenas + 1.0 + System: Disks: Management + /usr/local/pkg/freenas.inc + + + Disks +
System
+ /disks_manage.php +
+ + RAID +
System
+ /disks_raid_gmirror.php +
+ + 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 +
+ + AFP +
Services
+ /services_afp.php +
+ + FTP +
Services
+ /services_ftp.php +
+ + NFS +
Services
+ /services_nfs.php +
+ + Rsync +
Services
+ /services_rsyncd.php +
+ + Samba +
Services
+ /services_samba.php +
+ + Unison +
Services
+ /services_unison.php +
+ + + + ['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_manage_tools.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_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_tools.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gconcat.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gconcat_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gconcat_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gconcat_tools.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gstripe.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gstripe_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gstripe_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_gstripe_tools.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_graid5.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_graid5_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_graid5_infos.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/disks_raid_graid5_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/disks_mount_tools.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_nfs_export.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_nfs_export_edit.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_rsyncd_local.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/services_samba_share.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_samba_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/freenas/www/services_unison.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.inc + + + /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_config.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/pkg/freenas_system.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/pkg/rc.freenas + + + + /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 + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/mountd + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/nfsd + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/rpcbind + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/rpc.lockd + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/freenas/bin/rpc.statd + + + + + sync_package_freenas(); + + + custom_php_install_command(); + + + custom_php_deinstall_command(); + +
diff --git a/config/freenas/pkg/freenas_config.inc b/config/freenas/pkg/freenas_config.inc new file mode 100644 index 00000000..fc139228 --- /dev/null +++ b/config/freenas/pkg/freenas_config.inc @@ -0,0 +1,45 @@ + + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé . + 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. + */ +/* ========================================================================== */ + +$GLOBALS['custom_listtags'] = array("disk", "mount", "vdisk"); + +?> \ No newline at end of file diff --git a/config/freenas/pkg/freenas_disks.inc b/config/freenas/pkg/freenas_disks.inc new file mode 100644 index 00000000..0946164f --- /dev/null +++ b/config/freenas/pkg/freenas_disks.inc @@ -0,0 +1,1256 @@ + + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé . + 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"); +require_once("freenas_functions.inc"); + +$freenas_config =& $config['installedpackages']['freenas']['config'][0]; + +/* Mount all configured disks */ +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); + } // end foreach + } // end if + + if ($g['booting']) + echo "done\n"; + + return 0; +} + +/* Mount using the configured mount given in parameter + * Return 0 if sucessful, 1 if error + */ +function disks_mount($mount) { + global $freenas_config, $g; + + /* Create one directory for each device under mnt */ + + $mountname=escapeshellcmd($mount['sharename']); + + @mkdir ("/mnt/$mountname",0777); + + /* mount the filesystems */ + $devname=escapeshellcmd($mount['fullname']); + + /* check the fileystem only if there is a problem*/ + /* This part is too stupid: I must read the FreBSD + * start script for use the same intelligent method + * for checking hard drive + */ + 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"); + $result = 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"); + $result = 0; + } else { + /* Not OK, remove the directory, prevent writing on RAM disk*/ + @rmdir ("/mnt/$mountname"); + $result = 1; + } // end if + } // end if + break; + case "msdosfs": + if (mwexec("/sbin/mount_msdosfs -u ftp -g ftp -m 777 $devname /mnt/$mountname") == 0) { + $result = 0; + } else { + exec("/sbin/fsck -y -t msdosfs {$devname}"); + + if (mwexec("/sbin/mount_msdosfs -u ftp -g ftp -m 777 $devname /mnt/$mountname") == 0) { + $result = 0; + } else { + /* Not OK, remove the directory, prevent writing on RAM disk*/ + @rmdir ("/mnt/$mountname"); + $result = 1; + } + } + break; + case "ntfs": + if (mwexec("/sbin/mount_ntfs -u ftp -g ftp -m 777 $devname /mnt/$mountname") == 0) { + $result = 0; + } else { + /* Not OK, remove the directory, prevent writing on RAM disk */ + @rmdir ("/mnt/$mountname"); + $result = 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"); + $result = 0; + } else { + exec("/usr/local/sbin/e2fsck -f -p {$devname}"); + + if (mwexec("/sbin/mount_ext2fs $devname /mnt/$mountname") == 0) { + /* Change this directory into 777 mode */ + mwexec("/bin/chmod 777 /mnt/$mountname"); + $result = 0; + } else { + /* Not OK, remove the directory, prevent writing on RAM */ + @rmdir ("/mnt/$mountname"); + $result= 1; + } + } + break; + } // end switch + + return $result; +} + +/* Mount using fullname (/dev/ad0s1) given in parameter*/ +function disks_mount_fullname($fullname) { + global $freenas_config; + + if (is_array($freenas_config['mounts']['mount'])) { + /* Search the mount list for given disk and partition */ + foreach($freenas_config['mounts']['mount'] as $mountk => $mountv) { + if($mountv['fullname'] == $fullname) { + $mount = $mountv; + } + } + } + + if($mount) { + $result= disks_mount($mount); + } else { + $result=0; + } + + return $result; +} + +/* Umount the specified configured mount point + * Return 0 is successfull, 1 if error + */ +function disks_umount($mount) { + global $freenas_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 /mnt/$mountname") == 0) { + if (@rmdir ("/mnt/$mountname")) { + return 0; + } else { + return 1; + } + } else { + return 1; + } +} + +/* Advanced unmount the specified mount point without using the sharename value + * Used when changing the 'sharename': Need to umount the old unknow sharename + * Return 0 if successful, 1 if error + */ +function disks_umount_fullname($fullname) { + global $freenas_config; + + /* Search the mount list for given fullname */ + foreach($freenas_config['mounts']['mount'] as $mountk => $mountv) { + if (strcmp($mountv['fullname'],$fullname) == 0) { + $mount = $mountv; + } + } + + if($mount) { + $result = disks_umount($mount); + } else { + $result= 1; + } + + return $result; +} + +/* Advanced unmount the specified mount point without using the sharename value + * Used when changing the 'sharename': Need to umount the old unknow sharename + * Return 0 if successful, 1 if error + */ +function disks_umount_adv($mount) +{ + $fulname="{$mount['fullname']}"; + + // get the mount list + $detmount = get_mounts_list(); + + //Look for the mount point in all mounted point + foreach ($detmount as $detmountk => $detmountv) { + // If we found the mount point on the device + if (strcmp($detmountv['fullname'],$fullname) == 0) { + $mountname="{$detmountv['mp']}"; + } + } + + if ($mountname) { + exec("/sbin/umount $mountname"); + @rmdir ("$mountname"); + return 0; + } else { + $result = 1; + } + + return $result; +} + +function disks_mount_status($mount) { + // This option check if the mount are mounted + global $freenas_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; +} + +/* This option check if this fullname (/dev/ad0s1) is mounted + * Return 0 if not, 1 if yes + */ +function disks_check_mount_fullname($fullname) { + $detmount = get_mounts_list(); + $status=0; + //print_r($detmount); + + foreach ($detmount as $detmountk => $detmountv) { + if (strpos($detmountv['fullname'],$fullname) !== false) { + $status=1; + break; + } + } + + return $status; +} + +/* This option check if the configured mount is mounted. */ +function disks_check_mount($mount) +{ + return disks_check_mount_fullname($mount['fullname']); +} + +/* This function check if the disk is mounted + * Return 0 if not, 1 if yes + */ +function disks_check_mount_disk($disk) { + $detmount = get_mounts_list(); + $status=0; + + foreach ($detmount as $detmountk => $detmountv) { + /* Must found the $disk (ad0) in result $mdisk (ad0s1) */ + // strpos will return 0 (found at position 0) if found, must check the 'false' value + if (strpos($detmountv['mdisk'], $disk) !== false ) { + $status=1; + break; + } +} +return $status; +} + +/* This option check if the configured disk is online (detected by the system) + * Result: "MISSING", disk don't detected by OS + * Result: "ONLINE", disk is online + * Result: "CHANGED", disk have changed (be replaced ?) + */ +function disks_status($diskname) { + // This option check if the configured disk is online + global $freenas_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 $freenas_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("/bin/sync"); + + if (is_array($freenas_config['mounts']['mount'])) { + foreach ($freenas_config['mounts']['mount'] as $mountent) { + /* Umount filesystem */ + disks_umount($mountent); + } + } + + return 0; +} + +/* Configure, create and start gvinum volume */ +function disks_raid_gvinum_configure() { + global $freenas_config, $g; + + /* Generate the raid.conf file */ + if ($freenas_config['gvinum']['vdisk']) { + + foreach ($freenas_config['gvinum']['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']}"); + } + } // end if + + 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']}"); + } + } // end if + + return 0; +} + +/* Configure, create and start gmirror volume */ +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; +} + +/* Configure, create and start gconcat volume */ +function disks_raid_gconcat_configure() { + global $freenas_config, $g; + + if ($freenas_config['gconcat']['vdisk']) { + // Load gconcat + mwexec("/sbin/gconcat load"); + + foreach ($freenas_config['gconcat']['vdisk'] as $a_raid_conf) { + /* Create each volume */ + $cmd = "/sbin/gconcat label {$a_raid_conf['name']} "; + + foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv) { + $cmd .= "{$diskrv} "; + } + + mwexec($cmd); + + } + } + + return 0; +} + +/* Configure, create and start gstripe volume */ +function disks_raid_gstripe_configure() { + global $freenas_config, $g; + + if ($freenas_config['gstripe']['vdisk']) { + // Load gstripe + mwexec("/sbin/gstripe load"); + + foreach ($freenas_config['gstripe']['vdisk'] as $a_raid_conf) { + /* Create each volume */ + $cmd = "/sbin/gstripe label {$a_raid_conf['name']} "; + + foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv) { + $cmd .= "{$diskrv} "; + } + + mwexec($cmd); + } + } + + return 0; +} + +/* Configure, create and start graid5 volume */ + +function disks_raid_graid5_configure() +{ + global $freenas_config, $g; + + if ($freenas_config['graid5']['vdisk']) { + /* Load graid5 */ + mwexec("/sbin/graid5 load"); + + foreach ($freenas_config['graid5']['vdisk'] as $a_raid_conf) { + /* Create each volume */ + $cmd = "/sbin/graid5 label -s 131072 {$a_raid_conf['name']} "; + + foreach ($a_raid_conf['diskr'] as $diskrk => $diskrv) { + $cmd .= "{$diskrv} "; + } + + mwexec($cmd); + } + } + + return 0; +} + +function disks_raid_start() { + global $freenas_config, $g; + + /* WARNING: Must change this code for advanced RAID configuration ex: RAID1+0 + * Geom RAID volume must be started in 'intelligent' sort, for RAID1+0, gmirror must + * be started before gstripe, etc... + */ + disks_raid_gvinum_start(); + disks_raid_gmirror_start(); + disks_raid_gstripe_start(); + disks_raid_gconcat_start(); + disks_raid_graid5_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; +} + +/* Start geom concat volumes */ +function disks_raid_gconcat_start() { + global $freenas_config, $g; + +/* Start Geom concat */ + if ($freenas_config['gconcat']['vdisk']) { + if ($g['booting']) + echo "Start gconcat raid... "; + + // Load geom concat module + mwexec("/sbin/gconcat load"); + + if ($g['booting']) + echo "done\n"; + } + + return 0; +} + +/* Start geom stripe volumes */ +function disks_raid_gstripe_start() { + global $freenas_config, $g; + + /* Start Geom stripe */ + if ($freenas_config['gstripe']['vdisk']) { + if ($g['booting']) + echo "Start gstripe raid... "; + + // Load geom stripe module + mwexec("/sbin/gstripe load"); + + if ($g['booting']) + echo "done\n"; + } + + return 0; +} + +/* Start geom raid5 volumes */ +function disks_raid_graid5_start() { + global $freenas_config, $g; + + /* Start Geom RAID5 */ + if ($freenas_config['graid5']['vdisk']) { + if ($g['booting']) + echo "Start graid5 raid... "; + + // Load geom raid5 module + mwexec("/sbin/graid5 load"); + + if ($g['booting']) + echo "done\n"; + } + + return 0; +} + +function disks_raid_stop() { + /* WARNING: Must change this code for advanced RAID configuration ex: RAID1+0 + * Geom RAID volume must be started in 'intelligent' sort, for RAID1+0, gmirror must + * be started before gstripe, etc... + */ + disks_raid_gvinum_stop(); + disks_raid_graid5_stop(); + disks_raid_gstripe_stop(); + disks_raid_gconcat_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; +} + +/* Stop all geom concat volumes */ +function disks_raid_gconcat_stop() { + global $freenas_config, $g; + + /* Stop geom concat */ + if ($freenas_config['gconcat']['vdisk']) { + /* start each volume */ + foreach ($freenas_config['gconcat']['vdisk'] as $a_raid_conf) { + mwexec("/sbin/gconcat stop {$a_raid_conf['name']}"); + } + } + + return 0; +} + +/* Stop all geom stripe volumes */ +function disks_raid_gstripe_stop() { + global $freenas_config, $g; + + /* Stop geom stripe */ + if ($freenas_config['gstripe']['vdisk']) { + /* start each volume */ + foreach ($freenas_config['gstripe']['vdisk'] as $a_raid_conf) { + mwexec("/sbin/gstripe stop {$a_raid_conf['name']}"); + } + } + + return 0; +} + +/* Stop all geom raid5 volumes */ +function disks_raid_graid5_stop() { + global $freenas_config, $g; + + /* Generate the raid.conf file */ + if ($freenas_config['graid5']['vdisk']) { + /* start each volume */ + foreach ($freenas_config['graid5']['vdisk'] as $a_raid_conf) { + mwexec("/sbin/graid5 stop {$a_raid_conf['name']}"); + } + } + + return 0; +} + + +/* Delete geom gvinum volume given in parameter */ +function disks_raid_gvinum_delete($raidname) { + global $freenas_config, $g; + + exec("/sbin/gvinum lv $raidname",$rawdata); + + if (strpos($rawdata[0],"State: up") === false) { + return 0; + } + + mwexec("/sbin/gvinum rm -r $raidname"); + + foreach ($freenas_config['gvinum']['vdisk'] as $a_raid) { + if ($a_raid['name'] == $raidname) { + foreach ($a_raid['diskr'] as $disk) { + mwexec("/sbin/gvinum rm -r disk_{$disk}"); + } + } + } + + return 0; +} + +/* Delete geom mirror volume given in parameter */ +function disks_raid_gmirror_delete($raidname) { + global $freenas_config, $g; + + // 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; +} + +/* Delete geom concat volume given in parameter */ +function disks_raid_gconcat_delete($raidname) { + global $freenas_config, $g; + + // Stop the volume + mwexec("/sbin/gconcat stop $raidname"); + + // Clear the gconcat information on the hard drive + foreach ($freenas_config['gconcat']['vdisk'] as $a_raid) { + if ($a_raid['name'] == $raidname) { + foreach ($a_raid['diskr'] as $disk) { + mwexec("/sbin/gconcat clear {$disk}"); + } + + mwexec("/sbin/gconcat destroy $raidname"); + } + } + + return 0; +} + +/* Delete geom stripe volume given in parameter */ +function disks_raid_gstripe_delete($raidname) { + global $freenas_config, $g; + + // Stop the volume + mwexec("/sbin/gstripe stop $raidname"); + + // Clear the gconcat information on the hard drive + foreach ($freenas_config['gstripe']['vdisk'] as $a_raid) { + if ($a_raid['name'] == $raidname) { + foreach ($a_raid['diskr'] as $disk) { + mwexec("/sbin/gstripe clear {$disk}"); + } + + mwexec("/sbin/gstripe destroy $raidname"); + } + } + + return 0; +} + +/* Delete geom raid5 volume given in parameter */ +function disks_raid_graid5_delete($raidname) { + global $freenas_config, $g; + + // Stop the volume + mwexec("/sbin/graid5 stop $raidname"); + + // The volume can disapear a few second after stop + sleep(2); + + // Clear the graid5 information on the hard drive + foreach ($freenas_config['graid5']['vdisk'] as $a_raid) { + if ($a_raid['name'] == $raidname) { + foreach ($a_raid['diskr'] as $disk) { + mwexec("/sbin/graid5 remove $raidname {$disk}"); + } + + mwexec("/sbin/graid5 destroy $raidname"); + } + } + + return 0; +} + +/* Initialise HARD DRIVE for installing FreeNAS (creating 2 partition) */ +function fdisk_hd_install($harddrive) { + global $freenas_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: + // Why ??? Must found the web page where I see this method + $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']; + + $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); + } // end if + } // end foreach + + return 1; + } // end if + + return 0; +} + +/* Is this function still used ??? +Get list of partition information from disk. +Result is in the form: +[1] => Array +( + [start] => 31 + [size] => 409169 + [type] => 0xa5 + [flags] => 0x80 +) + +Called in disks_manage_tools.php +*/ +function disks_get_partition_info($disk) { + exec("/sbin/fdisk -s {$disk}", $rawdata); + array_shift($rawdata); + array_shift($rawdata); + + $result = array(); + + foreach($rawdata as $partinfo) { + $apartinfo = preg_split("/\s+/", $partinfo); + $partid = chop($apartinfo[1],":"); + + $result[$partid] = array(); + $result[$partid]['start'] = chop($apartinfo[2]); + $result[$partid]['size'] = chop($apartinfo[3]); + $result[$partid]['type'] = chop($apartinfo[4]); + $result[$partid]['flags'] = chop($apartinfo[5]); + } + + return $result; +} + +?> diff --git a/config/freenas/pkg/freenas_functions.inc b/config/freenas/pkg/freenas_functions.inc new file mode 100644 index 00000000..fcea4478 --- /dev/null +++ b/config/freenas/pkg/freenas_functions.inc @@ -0,0 +1,49 @@ + + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé . + 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 ("freenas_disks.inc"); +require_once ("freenas_utils.inc"); +require_once ("freenas_services.inc"); +require_once ("freenas_system.inc"); + +?> \ No newline at end of file diff --git a/config/freenas/pkg/freenas_guiconfig.inc b/config/freenas/pkg/freenas_guiconfig.inc new file mode 100644 index 00000000..2dec5a42 --- /dev/null +++ b/config/freenas/pkg/freenas_guiconfig.inc @@ -0,0 +1,288 @@ +. + 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"; +$d_smbshareconfdirty_path = $g['varrun_path'] . "/smbshare.conf.dirty"; +$d_nfsexportconfdirty_path = $g['varrun_path'] . "/nfsexport.conf.dirty"; +$d_upnpconfdirty_path = $g['varrun_path'] . "/upnp.conf.dirty"; + +/* ============================================================================= */ +/* == Constants used together with executing a UNIX command line tool == */ +/* ============================================================================= */ + +define("DONE_PARAGRAPH", " +

+ Done! +

+ "); + +define("CMDOUT_PARA", " +

+ Command output (use the toggle icon to unveil detailed infos): +

+ "); + +define("CMDOUT_PARA_WOHINT", " +

+ Command output: +

+ "); + +define("CMDOUT_TOGGLE_FUNC", " +function toggle_cmdout(image, totoggle) { + var plusSrc = \"/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png\"; + var minusSrc = \"/themes/{$g['theme']}/images/misc/bullet_toggle_minus.png\"; + var currentSrc = image.src; + var newSrc = (currentSrc.indexOf(\"plus\") >= 0) ? minusSrc : plusSrc; + + image.src = newSrc; + Effect.toggle(totoggle, 'appear', { duration: 0.75 }); +} +"); + +define("CMDOUT_AJAX_SCRIPT", " + +"); + +$freenas_config =& $config['installedpackages']['freenas']['config'][0]; + +/* ============================================================================= */ +/* == Functions used together with executing a UNIX command line tool == */ +/* ============================================================================= */ + +function assemble_cmdout($button, $out, $done = false) { + $dopara = DONE_PARAGRAPH; + + $retvalue =<<