Guest User

Untitled

a guest
Oct 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. #!/usr/bin/php
  2. <? // vim:set et ts=4 sw=4 sts=4:
  3. # Copyright (C) 2003-2009 Axentra Corporation.
  4. #
  5. # This is UNPUBLISHED PROPRIETARY SOURCE CODE OF Axentra Corporation.
  6. # The copyright notice above does not evidence any actual or intended
  7. # publication of such source code. The contents of this file may not
  8. # be disclosed to third parties, copied or duplicated in any form, in
  9. # whole or in part, without the prior written permission of
  10. # Axentra Corporation.
  11. #
  12.  
  13. include("/usr/lib/spd/scripts/usb/usbToolbox.php");
  14. include("/usr/lib/spd/scripts/usb/plugLib.php");
  15.  
  16. // if we are still early in the boot sequence, do not process
  17. // insert events
  18. if( !file_exists( "/var/lock/subsys/oe-bootinit" ) ) {
  19. exit(1);
  20. }
  21. $device = substr( $argv[1], 0, strlen( $argv[1] ) -1 );
  22.  
  23. llog("**************************");
  24. llog("insert $device `id`");
  25.  
  26. if( isset( $argv[2] ) && $argv[2]=="backup" )
  27. $backup=true;
  28. else
  29. $backup=false;
  30.  
  31. if( @stat( "/tmp/format_in_progress" ) ) {
  32. llog("format in progress !!!!");
  33. exit(1);
  34. }
  35.  
  36. $info=getDevInfo( $argv[1] );
  37. $loc = getLocation( $info );
  38. /*
  39. NOTE: the eSataPorts, which lists external eSata ports, is
  40. not checked here, since we assume/know that this script will
  41. only be called on udev events, which implies it is an external
  42. device. The mountatboot script does check this list (via findUSBDevices)
  43. since we cannot make this assumption, and then invokes the usbinsert script
  44. on each device which should be mounted.
  45. */
  46. if( $loc == -1 && getFeaturesValue( "eSataNotRAID" ) != 1 ) {
  47. exit(1);
  48. }
  49.  
  50. $isOnlyUSB = isOnlyUSBStorage();
  51.  
  52. if( isBackupPort( $device ) == true && $backup == false ) {
  53. exit(0); // dont automount the backup port device
  54. }
  55.  
  56. sanitizeMountPoints();
  57.  
  58. $partcount = getPartCount( $device );
  59. llog("$device found $partcount partitions");
  60.  
  61. $ejectList = readManualEjectFile();
  62. if( count( $ejectList ) ) {
  63. removeDeviceFromEjectFile( $ejectList, $device );
  64. }
  65.  
  66. $issata = isSata( $argv[1] );
  67. if( $isOnlyUSB && !isVM() && $issata ) {
  68. prepSwapfile( $argv[1] );
  69. }
  70.  
  71. if( $isOnlyUSB ) {
  72. $setLEDs = true;
  73. // insert in progress
  74. setLED( "drive_progress", $issate );
  75. } else
  76. $setLEDs = false;
  77.  
  78. $success=0;
  79. // for each partition up to 4
  80. for($partnum=1; $partnum <= $partcount; $partnum++ ) {
  81. $partition = "$device$partnum";
  82. exec("/sbin/blockdev --setra 2048 $partition &> /dev/null");
  83. $fstype = strtolower( getPartFSType( $partition ));
  84. llog("$partition found $fstype partition");
  85. $hasParagon = hasParagon();
  86. if( $fstype == "vfat" || $fstype == "ntfs" || ($hasParagon && $fstype == "hfsplus" ) ) {
  87. // check if it's MySafe (NTFS w/ sig)
  88. if( $isOnlyUSB == FALSE && isMySafe( $partition ) === true ) {
  89. // mount as my safe
  90. llog("$partition is detected as MySafe");
  91. $retval = mountPart( $partition, MSMOUNTPOINT, $fstype );
  92. if( $retval == 0 ) {
  93. exec("touch ". MSACTIVEFILE );
  94. }
  95. } else {
  96. // create a pretty mount point
  97. llog("$partition is a regular partition");
  98. $mp = genMountPoint( $partition, $partcount,$backup );
  99. if( $mp == FALSE )
  100. continue;
  101. // mount it
  102. $retval = mountPart( $partition, $mp, $fstype );
  103. if( $retval != 0 ) {
  104. // Log error
  105. llog("$partition unable to mount $fstype on $mp");
  106. } else {
  107. // Log success
  108. llog("$partition successful mount $fstype on $mp");
  109. $success++;
  110. if( isSata( $partition, TRUE ) && $isOnlyUSB ) {
  111. bindMountOnFamLib( $partition );
  112. if( !isVM() ) {
  113. startSwapfile( $mp );
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120.  
  121. if( $success && file_exists( "/usr/lib/spd/scripts/usb/setupTmp.php" ) && $isOnlyUSB ) {
  122. exec("/usr/lib/spd/scripts/usb/setupTmp.php", $lines, $retval );
  123. exec("/usr/lib/spd/scripts/usb/setupUsers.php");
  124. if( $setLEDs ) {
  125. if( $retval == 0 ) {
  126. // drive on
  127. setLED("drive_on", $issata );
  128. } else {
  129. // drive error
  130. setLED("drive_error", $issata );
  131. }
  132. }
  133. }
  134.  
  135. if( $success ) {
  136. $services = stopFileServices();
  137. startFileServices();
  138. }
  139.  
  140. if( $success && $issata ) {
  141. startTransmission();
  142. }
  143. if( $success == 0 && $setLEDs ) {
  144. // drive error
  145. setLED("drive_error", $issata );
  146. }
  147. finishPlugLED();
  148. ?>
Add Comment
Please, Sign In to add comment