Advertisement
sa_drug

[MT]: Scripts - ros-functions

Nov 21st, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.13 KB | None | 0 0
  1. /system script add comment="=ROS-FUNCTIONS=" dont-require-permissions=no name=ros-functions owner=admin policy=ftp,reboot,read,write,policy,test,sniff source="# ROS Scripts - Custom functions \
  2.    \n# Dmitry Shevchenko - 11.11.2019\
  3.    \n\
  4.    \n# Filesystem type\
  5.    \n:global funcIsFlash do={\
  6.    \n\t:local isFlash false;\
  7.    \n\t:if ( [ :len [ file find where type=\"disk\" and name=\"flash\" ] ] != 0 ) do={ :set \$isFlash true ; } ; \
  8.    \n\t:return [ \$isFlash ] ; \
  9.    \n}\
  10.    \n\
  11.    \n# Convert command to script and run it\
  12.    \n:global funcCmd2Script do={\
  13.    \n\t:if ( [ :len \$cmd ] != 0 ) do={\
  14.    \n\t\t# Remove (previous errors)\
  15.    \n\t\t/system script remove [ find name=tmp-ros-m9e ];\
  16.    \n\t\t# Create new & run it\
  17.    \n\t\t/system script add name=\"tmp-ros-m9e\" source=\$cmd;\
  18.    \n\t\t/system script run tmp-ros-m9e;\
  19.    \n\t\t:delay 5s;\
  20.    \n\t\t# Remove \
  21.    \n\t\t/system script remove [ find name=tmp-ros-m9e ];\
  22.    \n\t\t:delay 5s;\
  23.    \n\t}\
  24.    \n}\
  25.    \n\
  26.    \n# ROS Version Compare\
  27.    \n:global funcROSVersionCompare do={\
  28.    \n# Parse input values\
  29.    \n# Current ROS version\
  30.    \n\t:local curmajver [ :pick \$versionA 0 [ :find \$versionA \".\" ] ]\
  31.    \n\t:local curminver [ :pick \$versionA ([ :find \$versionA \".\" ] + 1) [ :len \$versionA ] ]\
  32.    \n# Control / Test ROS version ( user-defined value )\
  33.    \n\t:local ctrmajver [ :pick \$versionB 0 [ :find \$versionB \".\" ] ]\
  34.    \n\t:local ctrminver [ :pick \$versionB ([ :find \$versionB \".\" ] + 1) [ :len \$versionB ] ]\
  35.    \n# Minor version check flag\
  36.    \n\t:local minvercheck false;\
  37.    \n# Version check\
  38.    \n# Major version check\
  39.    \n\t:if (  \$curmajver > \$ctrmajver  ) do={ :return 1; } else={\
  40.    \n\t\t:if ( \$curmajver = \$ctrmajver  ) do={ :set minvercheck true; } else={ :return -1; };\
  41.    \n\t};\
  42.    \n# Minor version check\
  43.    \n\t:if ( \$minvercheck ) do={\
  44.    \n\t\t:if (  \$curminver > \$ctrminver  ) do={ :return 1; } else={\
  45.    \n\t\t\t\t:if ( \$curminver = \$ctrminver  ) do={ :return 0; } else={ :return -1; };\
  46.    \n\t\t};\
  47.    \n\t};\t\
  48.    \n}\
  49.    \n\
  50.    \n# End"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement