Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <? // vim:set et ts=4 sw=4 sts=4:
- # Copyright (C) 2003-2009 Axentra Corporation.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE OF Axentra Corporation.
- # The copyright notice above does not evidence any actual or intended
- # publication of such source code. The contents of this file may not
- # be disclosed to third parties, copied or duplicated in any form, in
- # whole or in part, without the prior written permission of
- # Axentra Corporation.
- #
- include("/usr/lib/spd/scripts/usb/usbToolbox.php");
- include("/usr/lib/spd/scripts/usb/plugLib.php");
- // if we are still early in the boot sequence, do not process
- // insert events
- if( !file_exists( "/var/lock/subsys/oe-bootinit" ) ) {
- exit(1);
- }
- $device = substr( $argv[1], 0, strlen( $argv[1] ) -1 );
- llog("**************************");
- llog("insert $device `id`");
- if( isset( $argv[2] ) && $argv[2]=="backup" )
- $backup=true;
- else
- $backup=false;
- if( @stat( "/tmp/format_in_progress" ) ) {
- llog("format in progress !!!!");
- exit(1);
- }
- $info=getDevInfo( $argv[1] );
- $loc = getLocation( $info );
- /*
- NOTE: the eSataPorts, which lists external eSata ports, is
- not checked here, since we assume/know that this script will
- only be called on udev events, which implies it is an external
- device. The mountatboot script does check this list (via findUSBDevices)
- since we cannot make this assumption, and then invokes the usbinsert script
- on each device which should be mounted.
- */
- if( $loc == -1 && getFeaturesValue( "eSataNotRAID" ) != 1 ) {
- exit(1);
- }
- $isOnlyUSB = isOnlyUSBStorage();
- if( isBackupPort( $device ) == true && $backup == false ) {
- exit(0); // dont automount the backup port device
- }
- sanitizeMountPoints();
- $partcount = getPartCount( $device );
- llog("$device found $partcount partitions");
- $ejectList = readManualEjectFile();
- if( count( $ejectList ) ) {
- removeDeviceFromEjectFile( $ejectList, $device );
- }
- $issata = isSata( $argv[1] );
- if( $isOnlyUSB && !isVM() && $issata ) {
- prepSwapfile( $argv[1] );
- }
- if( $isOnlyUSB ) {
- $setLEDs = true;
- // insert in progress
- setLED( "drive_progress", $issate );
- } else
- $setLEDs = false;
- $success=0;
- // for each partition up to 4
- for($partnum=1; $partnum <= $partcount; $partnum++ ) {
- $partition = "$device$partnum";
- exec("/sbin/blockdev --setra 2048 $partition &> /dev/null");
- $fstype = strtolower( getPartFSType( $partition ));
- llog("$partition found $fstype partition");
- $hasParagon = hasParagon();
- if( $fstype == "vfat" || $fstype == "ntfs" || ($hasParagon && $fstype == "hfsplus" ) ) {
- // check if it's MySafe (NTFS w/ sig)
- if( $isOnlyUSB == FALSE && isMySafe( $partition ) === true ) {
- // mount as my safe
- llog("$partition is detected as MySafe");
- $retval = mountPart( $partition, MSMOUNTPOINT, $fstype );
- if( $retval == 0 ) {
- exec("touch ". MSACTIVEFILE );
- }
- } else {
- // create a pretty mount point
- llog("$partition is a regular partition");
- $mp = genMountPoint( $partition, $partcount,$backup );
- if( $mp == FALSE )
- continue;
- // mount it
- $retval = mountPart( $partition, $mp, $fstype );
- if( $retval != 0 ) {
- // Log error
- llog("$partition unable to mount $fstype on $mp");
- } else {
- // Log success
- llog("$partition successful mount $fstype on $mp");
- $success++;
- if( isSata( $partition, TRUE ) && $isOnlyUSB ) {
- bindMountOnFamLib( $partition );
- if( !isVM() ) {
- startSwapfile( $mp );
- }
- }
- }
- }
- }
- }
- if( $success && file_exists( "/usr/lib/spd/scripts/usb/setupTmp.php" ) && $isOnlyUSB ) {
- exec("/usr/lib/spd/scripts/usb/setupTmp.php", $lines, $retval );
- exec("/usr/lib/spd/scripts/usb/setupUsers.php");
- if( $setLEDs ) {
- if( $retval == 0 ) {
- // drive on
- setLED("drive_on", $issata );
- } else {
- // drive error
- setLED("drive_error", $issata );
- }
- }
- }
- if( $success ) {
- $services = stopFileServices();
- startFileServices();
- }
- if( $success && $issata ) {
- startTransmission();
- }
- if( $success == 0 && $setLEDs ) {
- // drive error
- setLED("drive_error", $issata );
- }
- finishPlugLED();
- ?>
Add Comment
Please, Sign In to add comment