LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1093|回复: 7

怎样更改routeros默认的shell?

[复制链接]
发表于 2004-12-31 16:07:55 | 显示全部楼层 |阅读模式
routeros是一种强大的路由软件,基于linux开发.它在启动的时候能自动认识硬件设备并驱动它.routeros使用了自己的ash这个shell,这个shell只能支持特定的命令,可是我想在其中运行linux命令就不行了.

于是我想怎样用我自己的shell去替换它默认的shell?是更改它的getty吗?或者,请高手指教!
其网站地址 :
http://www.mikrotik.com/

附启动时各脚本文件:
inittab


  1. id:3:initdefault:

  2. # System initialization.
  3. si::sysinit:/etc/rc.d/rc.sysinit

  4. # halt
  5. l0:0:wait:/etc/rc.d/rc.halt
  6. # starting
  7. l3:3:wait:/etc/rc.d/rc.start
  8. # rebooting
  9. l6:6:wait:/etc/rc.d/rc.reboot

  10. # Things to run in every runlevel.
  11. ud::once:/sbin/update

  12. # Trap CTRL-ALT-DELETE
  13. ca::ctrlaltdel:/sbin/shutdown -t3 -r now

  14. # Consoles
  15. 1:3:respawn:/sbin/getty 38400 tty1
  16. 2:3:respawn:/sbin/getty 38400 tty2
  17. # Serial lines
  18. #s1:3:respawn:/sbin/getty -L 9600 ttyS0 vt100
复制代码




rc.sysinit

  1. #!/bin/bash
  2. #
  3. # /etc/rc.d/rc.sysinit - run once at boot time
  4. #

  5. # Set the hostname.
  6. /bin/hostname localhost

  7. /sbin/fsck -v -T -A -R -y >/dev/null 2>&1

  8. CHECK=no
  9. FSCK_ARGS=

  10. if [ -f /.fsck ]; then
  11.    CHECK=yes
  12.    FSCK_ARGS=-f
  13. elif ! /sbin/diskman --big-disk; then
  14.    CHECK=yes
  15. elif [ ! -f /.asked ]; then
  16.    echo
  17.    echo "It is recomended to check your disk drive for errors,"
  18.    echo "but it may take a while (~1min for 1Gb)."
  19.    echo "It can be done later with "/system check-disk"."
  20.    if /bin/ask -t 10 "Do you want to do it now?"; then CHECK=yes; fi
  21.    echo
  22. fi

  23. RC=
  24. if [ "$CHECK" = "yes" ]; then
  25.    echo "Checking disk integrity..."
  26.    /sbin/fsck $FSCK_ARGS -v -T -y / >/dev/null 2>&1
  27.    RC=$?
  28. elif [ ! -f /.nofsck ]; then
  29.    echo "Doing full check..."
  30.    /sbin/fsck -v -T -p -y / >dev/null 2>&1
  31.    RC=$?
  32. fi

  33. if [ "$RC" = "" ]; then
  34.    echo -n
  35. elif [ $RC -eq 0 ]; then
  36.    echo "No errors found."
  37.    echo
  38. elif [ $RC -eq 1 ] || [ $RC -eq 2 ] || [ $RC -eq 3 ]; then
  39.    echo "Found errors, corrected."
  40.    kill -INT 1
  41.    exit 1
  42. else
  43.    echo "ERROR: Your disk file system is corrupted!"
  44.    echo "Please, reinstall your router"
  45.    kill -WINCH 1
  46.    exit 1
  47. fi

  48. # Remount the root filesystem read-write.
  49. echo "Remounting root filesystem in read-write mode." >/dev/null
  50. /bin/mount -n -o remount,rw,noatime /
  51. rm -f /.fsck
  52. echo >/.asked

  53. # Clear mtab
  54. : >/etc/mtab

  55. # Enter root into mtab.
  56. /bin/mount -f /

  57. # Should be removed later
  58. /bin/ln -f /etc/ld.so.cache /etc/ld.so.cache.old
  59. /sbin/ldconfig 2>/dev/null

  60. # Mount all other filesystems (except for NFS). Contrary to standard usage,
  61. # filesystems are NOT unmounted in single user mode.
  62. /bin/mount -a -t nonfs
  63. /bin/mkdir -p /ram
  64. /bin/mount -t tmpfs tmpfs /ram

  65. /sbin/diskman --to-ext3

  66. # Clean out /etc.
  67. /bin/rm -f /etc/mtab~ /fastboot /etc/nologin
  68. /bin/rm -f /var/log/* /var/run/*
  69. /bin/rm -f /var/lock/*
  70. : >/var/run/utmp

  71. #make device nodes that get modified
  72. /bin/mknod /ram/ptmx c 5 2

  73. # Cleanup tmp files
  74. /bin/rm -rf /tmp/*

  75. # Cleanup core files
  76. /bin/rm -rf /core

  77. # Remove unneeded stuff
  78. rm -f /bin/sh

  79. # Set the system clock.
  80. /sbin/hwclock --hctosys --localtime --noadjfile >/dev/null
  81. /bin/date >/dev/null

  82. # Turn on routing
  83. echo "1" >/proc/sys/net/ipv4/ip_forward

  84. # Set maximum opened file limit
  85. echo "32768" >/proc/sys/fs/file-max

  86. if [ ! -f /nova/etc/logo ]; then
  87. cp /nova/etc/logo.org /nova/etc/logo
  88. fi
  89. /nova/bin/mkissue /etc/issue
  90. if [ ! -f /nova/etc/url ]; then
  91. cp /nova/etc/url.org /nova/etc/url
  92. fi
  93. if [ ! -f /home/web/index2.html ]; then
  94. cp /home/web/index2.html.org /home/web/index2.html
  95. fi
  96. if [ ! -f /nova/lib/console/logo.txt ]; then
  97. cp /nova/lib/console/logo.txt.org /nova/lib/console/logo.txt
  98. fi

  99. if [ ! -f /etc/issue ]; then
  100. /nova/bin/mkissue /etc/issue
  101. fi

  102. # set hostname
  103. if [ ! -f /etc/ident ]; then
  104. echo -n $(cat /nova/etc/logo) >>/etc/ident
  105. fi

  106. hostname "$(cat /etc/ident)"

  107. # fix some perms
  108. chmod a+x /var
  109. chmod a+x /var/pdb
  110. chmod a+x /var/pdb/system

  111. exit 0
复制代码
发表于 2004-12-31 16:52:03 | 显示全部楼层
用whereis ash得到ash的绝对路径,并把它当成用户的主shell
修改/etc/passwd文件,把对应用户记录的最后一项更改为ash的路径
 楼主| 发表于 2004-12-31 20:30:13 | 显示全部楼层
passwd文件内容为:

  1. nobody:*:99:99:nobody:/tmp:/bin/sh
  2. root::0:0:root:/home/root:/bin/sh
复制代码



看来routeros使用的是一个所谓的它自己开发的sh ,不是标准的sh吧。

我需要编译一个sh安装到系统中吗?
发表于 2004-12-31 21:01:29 | 显示全部楼层
是的,从你的介绍来看,是它自己开发的shell
你把ash的绝对路径代替上面的/bin/sh就可以了
发表于 2004-12-31 23:53:49 | 显示全部楼层
把/bin/sh链接到你的shell不就行了
 楼主| 发表于 2005-1-1 00:29:00 | 显示全部楼层
问题是我没有它的源代码,不知道它用哪个版本的glibc,难道要用静态编译一个shell?
发表于 2005-1-1 01:04:19 | 显示全部楼层
Post by nait
把/bin/sh链接到你的shell不就行了

那别人还怎么用/bin/sh?
发表于 2005-1-1 11:50:01 | 显示全部楼层
Post by kiron
那别人还怎么用/bin/sh?

哦,是了
我一向是一个人独占自己的pc的   
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表