diff --git a/src/etc/config.xml b/src/etc/config.xml index c95fac607..db870b444 100644 --- a/src/etc/config.xml +++ b/src/etc/config.xml @@ -152,7 +152,7 @@ normal - pfSense + OPNsense localdomain diff --git a/src/etc/ecl.php b/src/etc/ecl.php deleted file mode 100755 index 683c2a7fb..000000000 --- a/src/etc/ecl.php +++ /dev/null @@ -1,174 +0,0 @@ -/dev/null")); - $slices = str_replace("/dev/", "", $slices); - if($slices == "ls: No match.") - return; - $slices_array = explode(" ", $slices); - return $slices_array; -} - -function get_disks() { - global $g, $debug; - $disks_array = array(); - $disks_s = explode(" ", get_single_sysctl("kern.disks")); - foreach($disks_s as $disk) - if(trim($disk)) - $disks_array[] = $disk; - return $disks_array; -} - -function discover_config($mountpoint) { - global $g, $debug; - $locations_to_check = array("/", "/config"); - foreach($locations_to_check as $ltc) { - $tocheck = "/tmp/mnt/cf{$ltc}config.xml"; - if($debug) { - echo "\nChecking for $tocheck"; - if(file_exists($tocheck)) - echo " -> found!"; - } - if(file_exists($tocheck)) - return $tocheck; - } - return ""; -} - -function test_config($file_location) { - global $g, $debug; - if(!$file_location) - return; - // config.xml was found. ensure it is sound. - $root_obj = trim("<{$g['xml_rootobj']}>"); - $xml_file_head = exec("/usr/bin/head -2 " . escapeshellarg($file_location) . " | /usr/bin/tail -n1"); - if($debug) { - echo "\nroot obj = $root_obj"; - echo "\nfile head = $xml_file_head"; - } - if($xml_file_head == $root_obj) { - // Now parse config to make sure - $config_status = config_validate($file_location); - if($config_status) - return true; - } - return false; -} - -// Probes all disks looking for config.xml -function find_config_xml() { - global $g, $debug; - $disks = get_disks(); - // Safety check. - if(!is_array($disks)) - return; - $boot_disk = get_boot_disk(); - $swap_disks = get_swap_disks(); - exec("/bin/mkdir -p /tmp/mnt/cf"); - foreach($disks as $disk) { - $slices = get_disk_slices($disk); - if(is_array($slices)) { - foreach($slices as $slice) { - if($slice == "") - continue; - if(stristr($slice, $boot_disk)) { - if($debug) - echo "\nSkipping boot device slice $slice"; - continue; - } - if(in_array($slice, $swap_disks)) { - if($debug) - echo "\nSkipping swap device slice $slice"; - continue; - } - echo " $slice"; - // First try msdos fs - if($debug) - echo "\n/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n"; - $result = exec("/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null"); - // Next try regular fs (ufs) - if(!$result) { - if($debug) - echo "\n/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n"; - $result = exec("/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null"); - } - $mounted = trim(exec("/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep '/tmp/mnt/cf' | /usr/bin/wc -l")); - if($debug) - echo "\nmounted: $mounted "; - if(intval($mounted) > 0) { - // Item was mounted - look for config.xml file - $config_location = discover_config($slice); - if($config_location) { - if(test_config($config_location)) { - // We have a valid configuration. Install it. - echo " -> found config.xml\n"; - echo "Backing up old configuration...\n"; - backup_config(); - echo "Restoring [{$slice}] {$config_location}...\n"; - restore_backup($config_location); - echo "Cleaning up...\n"; - exec("/sbin/umount /tmp/mnt/cf"); - exit; - } - } - exec("/sbin/umount /tmp/mnt/cf"); - } - } - } - } -} - -echo "External config loader 1.0 is now starting..."; -find_config_xml(); -echo "\n"; - -?> diff --git a/src/etc/inc/globals.inc b/src/etc/inc/globals.inc index 2b8096dc1..f99177660 100644 --- a/src/etc/inc/globals.inc +++ b/src/etc/inc/globals.inc @@ -63,7 +63,6 @@ $g = array( "product_website" => "www.opnsense.org", "product_website_footer" => "https://www.opnsense.org/?gui22", "product_email" => "coreteam@opnsense.org", - "hideplatform" => false, "hidedownloadbackup" => false, "hidebackupbeforeupgrade" => false, "disablethemeselection" => false, diff --git a/src/etc/phpshellsessions/externalconfiglocator b/src/etc/phpshellsessions/externalconfiglocator deleted file mode 100644 index 225832916..000000000 --- a/src/etc/phpshellsessions/externalconfiglocator +++ /dev/null @@ -1 +0,0 @@ -include("/usr/local/etc/ecl.php"); diff --git a/src/etc/rc b/src/etc/rc index 74e543db9..a418a9c43 100755 --- a/src/etc/rc +++ b/src/etc/rc @@ -1,9 +1,8 @@ #!/bin/sh -# part of pfSense by Scott Ullrich # Copyright (C) 2004-2010 Scott Ullrich, All rights reserved. -# originally based on m0n0wall (http://neon1.net/m0n0wall) # Copyright (C) 2003-2004 Manuel Kasper . +# Copyright (C) 2014 Franco Fichtner # All rights reserved. stty status '^T' 2> /dev/null @@ -18,18 +17,15 @@ HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin export HOME PATH -# Set our operating platform PLATFORM=`/bin/cat /usr/local/etc/platform` -# Set our current version -version=`/bin/cat /usr/local/etc/version` - if [ -e /root/force_fsck ]; then echo "Forcing filesystem check..." /sbin/fsck -y -t ufs / if [ "$PLATFORM" = "nanobsd" ]; then /sbin/fsck -y -t ufs /cf fi + /bin/rm -f /root/force_fsck fi if [ "${PLATFORM}" = "nanobsd" ]; then @@ -150,10 +146,6 @@ if [ ! -f /conf/config.xml ]; then echo " done." fi -/bin/rm -f /root/force_fsck -/bin/rm -f /root/TRIM_set -/bin/rm -f /root/TRIM_unset - # Disable APM on ATA drives. Leaving this on will kill drives long-term, especially laptop drives, by generating excessive Load Cycles. if [ -f /usr/local/etc/rc.disable_hdd_apm ]; then /usr/local/etc/rc.disable_hdd_apm @@ -170,24 +162,10 @@ fi rm -f /etc/spwd.db.tmp /usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd -product=`/usr/bin/grep product_name /usr/local/etc/inc/globals.inc | /usr/bin/cut -d'"' -f4` -hideplatform=`/usr/bin/grep hideplatform /usr/local/etc/inc/globals.inc | /usr/bin/wc -l` -varrunpath=`/usr/bin/grep varrun_path /usr/local/etc/inc/globals.inc | /usr/bin/cut -d'"' -f4` - if [ "$PLATFORM" = "pfSense" ] && [ ${USE_MFS_TMPVAR} -eq 0 ]; then - /sbin/mdmfs -S -M -s 4m md $varrunpath + /sbin/mdmfs -S -M -s 4m md /var/run fi -if [ "$hideplatform" -gt "0" ]; then - platformbanner="" # hide the platform -else - platformbanner=" on the '${PLATFORM}' platform" -fi - -echo -echo "Welcome to ${product} ${version} ${platformbanner} ..." -echo - if [ ! "$PLATFORM" = "jail" ]; then # Enable console output if its muted. /sbin/conscontrol mute off >/dev/null @@ -207,7 +185,6 @@ elif [ "$PLATFORM" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then elif [ "$PLATFORM" = "jail" ]; then # do nothing for jail platform else - SWAPDEVICE=`/bin/cat /etc/fstab | /usr/bin/grep swap | /usr/bin/cut -f1` /sbin/swapon -a /usr/local/etc/rc.savecore @@ -220,17 +197,9 @@ else fi fi -# Copy PBI keys -if ls /usr/local/share/pbi-keys/*.ssl >/dev/null 2>&1; then - if [ ! -d "/var/db/pbi/keys" ]; then - mkdir -p /var/db/pbi/keys - fi - cp -f /usr/local/share/pbi-keys/*.ssl /var/db/pbi/keys -fi - # make some directories in /var -/bin/mkdir -p $varrunpath /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null -/bin/rm -rf $varrunpath/* +/bin/mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null +/bin/rm -rf /var/run/* if [ "$PLATFORM" != "pfSense" ]; then /bin/rm /var/log/* 2>/dev/null fi @@ -278,10 +247,7 @@ if [ ! -h /tmp/tmp ]; then /bin/ln -hfs / /tmp/tmp fi -# Make sure our /tmp is 777 + Sticky -if [ ! "$PLATFORM" = "cdrom" ] ; then - /bin/rm -rf /tmp/* -fi +/bin/rm -rf /tmp/* /bin/chmod 1777 /tmp if [ ! "$PLATFORM" = "cdrom" ] ; then @@ -351,7 +317,7 @@ if [ ! "$PLATFORM" = "jail" ]; then fi # Create an initial utmp file -cd $varrunpath && /bin/cp /dev/null utmp && /bin/chmod 644 utmp +cd /var/run && /bin/cp /dev/null utmp && /bin/chmod 644 utmp echo -n "." /sbin/ldconfig -elf /usr/lib /usr/local/lib /lib @@ -378,14 +344,8 @@ echo "done." # Recreate capabilities DB /usr/bin/cap_mkdb /etc/login.conf -# Run the php.ini setup file and populate -# /usr/local/etc/php.ini and /usr/local/lib/php.ini -/usr/local/etc/rc.php_ini_setup 2>/tmp/php_errors.txt - -# Launch external configuration loader for supported platforms -if [ "$PLATFORM" = "nanobsd" -o "$PLATFORM" = "pfSense" ]; then - /usr/local/bin/php -q /usr/local/etc/ecl.php -fi +# Run the php.ini setup file +/usr/local/etc/rc.php_ini_setup chmod u+rx /usr/local/opnsense/service/check_reload_status.py /usr/bin/nice -n20 /usr/local/opnsense/service/check_reload_status.py @@ -395,11 +355,11 @@ sleep 1 # give check_reload_status some time to load to prevent missing socket echo -n "Launching the init system..." /bin/rm -f /cf/conf/backup/backup.cache /bin/rm -f /root/lighttpd* -/usr/bin/touch $varrunpath/booting +/usr/bin/touch /var/run/booting /usr/local/etc/rc.bootup # rc.bootup unset $g['booting'], remove file right now to be consistent -/bin/rm $varrunpath/booting +/bin/rm /var/run/booting # If a shell was selected from recovery # console then just drop to the shell now. @@ -412,16 +372,14 @@ echo -n "Starting CRON... " cd /tmp && /usr/sbin/cron -s 2>/dev/null echo "done." -/bin/rm -rf /usr/local/pkg/pf/CVS - # Start ping handler every 240 seconds -/usr/local/bin/minicron 240 $varrunpath/ping_hosts.pid /usr/local/bin/ping_hosts.sh +/usr/local/bin/minicron 240 /var/run/ping_hosts.pid /usr/local/bin/ping_hosts.sh # Start account expire handler every hour -/usr/local/bin/minicron 3600 $varrunpath/expire_accounts.pid /usr/local/etc/rc.expireaccounts +/usr/local/bin/minicron 3600 /var/run/expire_accounts.pid /usr/local/etc/rc.expireaccounts # Start alias url updater every 24 hours -/usr/local/bin/minicron 86400 $varrunpath/update_alias_url_data.pid /usr/local/etc/rc.update_alias_url_data +/usr/local/bin/minicron 86400 /var/run/update_alias_url_data.pid /usr/local/etc/rc.update_alias_url_data /bin/chmod a+rw /tmp/. @@ -434,15 +392,13 @@ if [ "${GMIRROR_STATUS}" != "" ]; then /usr/local/bin/minicron 60 /var/run/gmirror_status_check.pid /usr/local/sbin/gmirror_status_check.php fi -# Log product version to syslog -ARCH=`uname -m` -echo "$product ($PLATFORM) $version $ARCH" - -echo "Bootup complete" - /usr/local/bin/beep.sh start 2>&1 >/dev/null # Reset the cache. read-only requires this. /bin/rm -f /tmp/config.cache +echo + +/usr/local/etc/rc.initial.banner + exit 0 diff --git a/src/etc/rc.banner b/src/etc/rc.banner deleted file mode 100755 index d368249fb..000000000 --- a/src/etc/rc.banner +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/local/bin/php -f - $friendly) { - /* point to this interface's config */ - $ifconf = $config['interfaces'][$ifname]; - /* look for 'special cases' */ - switch($ifconf['ipaddr']) { - case "dhcp": - $class = "/DHCP4"; - break; - case "pppoe": - $class = "/PPPoE"; - break; - case "pptp": - $class = "/PPTP"; - break; - case "l2tp": - $class = "/L2TP"; - break; - default: - $class = ""; - break; - } - switch($ifconf['ipaddrv6']) { - case "dhcp6": - $class6 = "/DHCP6"; - break; - case "slaac": - $class6 = "/SLAAC"; - break; - case "6rd": - $class6 = "/6RD"; - break; - case "6to4": - $class6 = "/6to4"; - break; - case "track6": - $class6 = "/t6"; - break; - } - $ipaddr = get_interface_ip($ifname); - $subnet = get_interface_subnet($ifname); - $ipaddr6 = get_interface_ipv6($ifname); - $subnet6 = get_interface_subnetv6($ifname); - $realif = get_real_interface($ifname); - $tobanner = "{$friendly} ({$ifname})"; - - printf("\n %-15s -> %-10s -> ", - $tobanner, - $realif - ); - $v6first = false; - if (!empty($ipaddr) && !empty($subnet)) { - printf("v4%s: %s/%s", - $class, - $ipaddr, - $subnet - ); - } else { - $v6first = true; - } - if (!empty($ipaddr6) && !empty($subnet6)) { - if (!$v6first) { - printf("\n%s", str_repeat(" ",34)); - } - printf("v6%s: %s/%s", - $class6, - $ipaddr6, - $subnet6 - ); - } - } - -?> diff --git a/src/etc/rc.initial b/src/etc/rc.initial index 7641951d3..153a9f87a 100755 --- a/src/etc/rc.initial +++ b/src/etc/rc.initial @@ -35,15 +35,7 @@ fi # endless loop while : ; do -if [ -f /tmp/ttybug ]; then - rm /tmp/ttybug - exit && exit && logout -fi - -/usr/local/etc/rc.banner - product=`grep product_name /usr/local/etc/inc/globals.inc | cut -d'"' -f4` -hidebanner=`grep hidebanner /usr/local/etc/inc/globals.inc | cut -d'"' -f4` # Check to see if SSH is running. if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then @@ -52,20 +44,12 @@ else sshd_option="14) Enable Secure Shell (sshd)"; fi -for i in /var/db/pfi/capable_*; do - if [ -f $i -a ! -L /cf/conf ]; then - option98="98) Move configuration file to removable device" - break - fi -done - if [ "$PLATFORM" = "cdrom" ]; then option99="99) Install ${product} to a hard drive, etc." fi # display a cheap menu -echo "" -echo " 0) Logout (SSH only) 8) Shell" +echo " 0) Logout 8) Shell" echo " 1) Assign Interfaces 9) pfTop" echo " 2) Set interface(s) IP address 10) Filter Logs" echo " 3) Reset webConfigurator password 11) Restart webConfigurator" @@ -73,8 +57,6 @@ echo " 4) Reset to factory defaults 12) ${product} Developer Shell" echo " 5) Reboot system 13) Upgrade from console" echo " 6) Halt system ${sshd_option}" echo " 7) Ping host 15) Restore recent configuration" -echo " ${option98} " - if [ "${option99}" != "" ]; then /bin/echo "${option99}" fi @@ -86,7 +68,7 @@ echo # see what the user has chosen case ${opmode} in 0) - logout + exit ;; 1) /usr/local/etc/rc.initial.setports @@ -144,5 +126,8 @@ case ${opmode} in ;; esac -done +/usr/local/etc/rc.initial.banner +echo + +done diff --git a/src/etc/rc.initial.banner b/src/etc/rc.initial.banner new file mode 100755 index 000000000..ceb226ddb --- /dev/null +++ b/src/etc/rc.initial.banner @@ -0,0 +1,113 @@ +#!/usr/local/bin/php -f + $friendly) { + /* point to this interface's config */ + $ifconf = $config['interfaces'][$ifname]; + /* look for 'special cases' */ + switch($ifconf['ipaddr']) { + case "dhcp": + $class = "/DHCP4"; + break; + case "pppoe": + $class = "/PPPoE"; + break; + case "pptp": + $class = "/PPTP"; + break; + case "l2tp": + $class = "/L2TP"; + break; + default: + $class = ""; + break; + } + switch($ifconf['ipaddrv6']) { + case "dhcp6": + $class6 = "/DHCP6"; + break; + case "slaac": + $class6 = "/SLAAC"; + break; + case "6rd": + $class6 = "/6RD"; + break; + case "6to4": + $class6 = "/6to4"; + break; + case "track6": + $class6 = "/t6"; + break; + } + $ipaddr = get_interface_ip($ifname); + $subnet = get_interface_subnet($ifname); + $ipaddr6 = get_interface_ipv6($ifname); + $subnet6 = get_interface_subnetv6($ifname); + $realif = get_real_interface($ifname); + $tobanner = "{$friendly} ({$realif})"; + + printf("\n %-15s -> ", $tobanner); + + $v6first = false; + if (!empty($ipaddr) && !empty($subnet)) { + printf("v4%s: %s/%s", + $class, + $ipaddr, + $subnet + ); + } else { + $v6first = true; + } + if (!empty($ipaddr6) && !empty($subnet6)) { + if (!$v6first) { + printf("\n%s", str_repeat(" ", 20)); + } + printf("v6%s: %s/%s", + $class6, + $ipaddr6, + $subnet6 + ); + } +} + +printf("\n"); diff --git a/src/www/widgets/widgets/system_information.widget.php b/src/www/widgets/widgets/system_information.widget.php index 3a0d5e2b5..2ede27eb6 100644 --- a/src/www/widgets/widgets/system_information.widget.php +++ b/src/www/widgets/widgets/system_information.widget.php @@ -135,7 +135,6 @@ $filesystems = get_mounted_filesystems(); - @@ -145,7 +144,6 @@ $filesystems = get_mounted_filesystems(); } ?> -