Guest User

Untitled

a guest
Jan 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.59 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # /etc/rc.d/rc.S: Initialize system.
  4. #
  5. # ���󥰥�桼���⡼�ɡ��ޥ��桼���⡼�ɶ��̤ν�����Ԥʤ�
  6. #
  7. # ��������:
  8. # udev��������ե����륷���ƥࡦ�ۥ���̾��RTC��syslogd/klogd(����ư)��
  9. # CPU����å�(������)��ISAPnP�������ͥ�⥸�塼�롦�ե졼��Хåե���unicon��
  10. # ���󥽡���ե���ȡ������ޥåס�motd/issue�����ꥢ��ݡ���
  11. #
  12.  
  13. # Set the path.
  14. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  15.  
  16. # Start udev.
  17. echo "Starting udev..."
  18.  
  19. mount -w -n -t proc /proc /proc
  20. mount -w -n -t sysfs /sys /sys
  21. mount -w -n -o mode=0755 -t tmpfs /dev /dev
  22. mkdir /dev/pts
  23. mkdir /dev/shm
  24. chmod 1777 /dev/shm
  25.  
  26. # ln -s /bin/true /dev/.hotplug.agent
  27.  
  28. mknod /dev/null -m 0666 c 1 3
  29. mknod /dev/unikey -m 0644 c 10 202
  30. mknod /dev/ppp -m 0660 c 108 0
  31. mknod /dev/loop0 -m 0660 b 7 0
  32. chgrp disk /dev/loop0
  33. mknod /dev/md0 -m 0660 b 9 0
  34. chgrp disk /dev/md0
  35. mknod /dev/fd0 -m 0660 b 2 0
  36. chgrp floppy /dev/fd0
  37. ln -sf /proc/self/fd /dev/fd
  38. ln -sf /proc/self/fd/0 /dev/stdin
  39. ln -sf /proc/self/fd/1 /dev/stdout
  40. ln -sf /proc/self/fd/2 /dev/stderr
  41.  
  42.  
  43. /sbin/udevd --daemon
  44. /sbin/udevadm trigger
  45.  
  46. dev2mod(){
  47. while read dev;
  48. do modprobe $dev 2>/dev/null 1> /dev/null
  49. #if [ $? == 0 ]; then
  50. # echo "$dev module loaded"
  51. #fi
  52. done
  53. }
  54.  
  55. cat /sys/bus/*/devices/*/modalias | dev2mod
  56. sleep 1
  57. cat /sys/bus/*/devices/*/modalias | dev2mod
  58. sleep 1
  59. cat /sys/bus/*/devices/*/modalias | dev2mod
  60. sleep 1
  61.  
  62. if [ -x /sbin/hwclock ]; then
  63. # Setup timezone for now.
  64. /sbin/hwclock --hctosys --utc
  65. fi
  66.  
  67. # disable unused hibernation data
  68. if [ -x /etc/rc.d/hibernate-cleanup.sh ]; then
  69. /etc/rc.d/hibernate-cleanup.sh start
  70. fi
  71.  
  72. # Enable swapping.
  73. /sbin/swapon -a
  74.  
  75. # Test to see if the root partition is read-only, like it ought to be.
  76. if /bin/touch /.writetest > /dev/null 2>&1; then # Read-write
  77. /bin/rm -f /.writetest
  78. # No warn for ReiserFS or UMSDOS.
  79. if [ -n "`/sbin/mount -t umsdos`" ]; then
  80. ROOTTYPE=umsdos
  81. elif [ -z "`/sbin/mount -t reiserfs`" ]; then
  82. cat <<EOF
  83.  
  84. *** ERROR: Root partition is mounted as read-write; cannot check! ***
  85.  
  86. Root partition must be mounted as read only to be checked properly.
  87.  
  88. Add `ro' flag to the `kernel' line of GRUB configuration (it can be done by
  89. typing `e' in grub menu or by editing /etc/grub.conf), or modify the kernel
  90. with `rdev' command:
  91.  
  92. rdev -R <kernel-image> 1
  93.  
  94. This will fix the problem and eliminate this annoying message. :^)
  95.  
  96. EOF
  97. echo -n "Press ENTER to continue: "
  98. read junk
  99. fi
  100. else # Read-only
  101. # /bin/rm -f /.writetest
  102. if [ -z "`/sbin/mount -t reiserfs`" ]; then
  103. if [ -f /fastboot ]; then
  104. echo "FAST-BOOT, skipping fsck."
  105. else
  106. # Check the integrity of root filesystem.
  107. echo "Checking root filesystem..."
  108. /sbin/fsck -a -C /
  109. # If there was a failure, drop into single-user mode.
  110. if [ $? -gt 1 ]; then
  111. cat <<EOF
  112.  
  113. *************************************************
  114. fsck returned error - repair manually and REBOOT!
  115. *************************************************
  116.  
  117. Note that root partition is currently mounted read-only.
  118. To modify it, remember to remount it read-write with:
  119.  
  120. mount -n -o remount,rw /
  121.  
  122. EOF
  123. /sbin/sulogin
  124. echo "Exited from the single-user shell."
  125. echo -n "Press ENTER to REBOOT: "
  126. read junk
  127. reboot
  128. fi
  129. fi
  130. fi
  131. # Remount the root filesystem in read-write mode.
  132. echo "Remounting root filesystem with read-write enabled..."
  133. /sbin/mount -w -n -o remount /
  134. if [ $? -gt 0 ]; then
  135. cat << EOF
  136.  
  137. *** Remounting root partition as read-write failed! ***
  138.  
  139. If you are using the UMSDOS filesystem, you *MUST* mount the root partition as
  140. read-write.
  141.  
  142. Add `rw' flag to the `kernel' line of GRUB configuration (it can be done by
  143. typing `e' in grub menu or by editing /etc/grub.conf), or modify the kernel
  144. with `rdev' command:
  145.  
  146. rdev -R <kernel-image> 0
  147.  
  148. Reboot immediately and use one of the above methods.
  149.  
  150. EOF
  151. echo -n "Press ENTER to continue: "
  152. read junk
  153. fi
  154. fi
  155.  
  156. # Clean /etc/mtab* and create new one with a root entry.
  157. /bin/rm -f /etc/mtab*
  158. /sbin/mount -f -v -o remount /
  159. /sbin/mount -f -v /proc
  160. /sbin/mount -f -v /sys
  161. /sbin/mount -f -v /dev
  162.  
  163. # copy the rules generated before / was mounted read-write
  164. for file in /dev/.udev/tmp-rules--*; do
  165. dest=${file##*tmp-rules--}
  166. [ "$dest" = '*' ] && break
  167. cat $file >> /etc/udev/rules.d/$dest
  168. rm -f $file
  169. done
  170.  
  171. # Set the hostname.
  172. echo -n "Set the hostname: "
  173. if [ ! -r /etc/HOSTNAME ]; then
  174. # If there's no /etc/HOSTNAME, fall back on this default.
  175. echo "darkstar.frop.org" > /etc/HOSTNAME
  176. fi
  177. HOST=`cat /etc/HOSTNAME`
  178. HOST=${HOST%%.*}
  179. echo "$HOST."
  180. /bin/hostname "$HOST"
  181.  
  182. # Configure the system clock.
  183. # This can be changed if your system keeps GMT.
  184. #if [ -x /sbin/hwclock ]; then
  185. # /sbin/hwclock --adjust
  186. # /sbin/hwclock --hctosys
  187. #fi
  188.  
  189. # Suppless system logs displayed into console.
  190. if [ -x /sbin/rsyslogd ]; then
  191. echo "*.info /bootlog" > /bootlog.conf
  192. if [ ! -d /var/run ]; then
  193. # Workaround when /var is on non-root partition.
  194. mkdir /var/run
  195. /sbin/rsyslogd -m 0 -f /bootlog.conf
  196. # /sbin/klogd -c 5
  197. sleep 1
  198. mv -f /var/run/rsyslogd.pid /
  199. rmdir /var/run
  200. else
  201. /sbin/rsyslogd -m 0 -f /bootlog.conf
  202. #/sbin/klogd -c 5
  203. sleep 1
  204. mv -f /var/run/rsyslogd.pid /
  205. fi
  206. fi
  207.  
  208. # Set CPU frequency with the support of Speedstep technology.
  209. #if [ ! -d /sys/devices/system/cpu/cpu0/cpufreq -a -f /proc/cpufreq ]; then
  210. # # Old API needs setting the default governer to "performance".
  211. # echo -n "0%50%100%performance" > /proc/cpufreq
  212. #fi
  213.  
  214. # Configure the ISA PnP cards.
  215. if [ -x /sbin/isapnp -a -r /etc/isapnp.conf ]; then
  216. echo "Configuring ISA PnP cards..."
  217. /sbin/isapnp /etc/isapnp.conf
  218. fi
  219.  
  220. # Initializing kernel modules stuff and load necessary modules by hand.
  221. # Any recent modules are auto-probed by murasaki.
  222. if [ -x /etc/rc.d/rc.modules ]; then
  223. . /etc/rc.d/rc.modules
  224. fi
  225.  
  226. # Clean up /tmp and /media directory.
  227. # /bin/rm -rf /tmp /media
  228. if [ ! -d /tmp ]; then
  229. mkdir /tmp
  230. fi
  231. if [ ! -d /media ]; then
  232. mkdir /media
  233. fi
  234. /sbin/mount -v -o mode=0755 -t tmpfs /media /media
  235. /sbin/mount -v -t tmpfs /tmp /tmp
  236. chmod 1777 /tmp
  237. mkdir /tmp/.ICE-unix
  238. chmod 1777 /tmp/.ICE-unix
  239.  
  240. # lvm
  241. if [ -x /sbin/lvm ]; then
  242. echo "Starting LVM volume groups..."
  243. /sbin/lvm vgchange -a y
  244.  
  245. if [ $? -gt 0 ]; then
  246. echo "*** An error occurred during the LVM startup"
  247. /sbin/sulogin
  248. echo "Exited from the single-user shell."
  249. echo -n "Press ENTER to continue: "
  250. read junk
  251. fi
  252. fi
  253.  
  254. # Check the integrity of the other filesystems.
  255. if [ -n "`/sbin/mount -afnvt ext2,ext3,ext4,umsdos 2> /dev/null`" ]; then
  256. if [ ! -f /fastboot ]; then
  257. echo "Checking all file systems..."
  258. /sbin/fsck -R -A -a -C
  259. # If there was a failure, drop into single-user mode.
  260. if [ $? -gt 1 ]; then
  261. cat <<EOF
  262.  
  263. **************************************
  264. fsck returned error - repair manually!
  265. **************************************
  266.  
  267. EOF
  268. /sbin/sulogin
  269. echo "Exited from the single-user shell."
  270. echo -n "Press ENTER to continue: "
  271. read junk
  272. fi
  273. fi
  274. fi
  275.  
  276. # Mount local filesystems in fstab.
  277. # But not NFS because TCP/IP is not yet configured.
  278. echo "Mounting local filesystems..."
  279. /sbin/mount -avt nonfs,proc,sysfs,tmpfs,nocifs
  280.  
  281. if grep -q usbfs /proc/filesystems && ! grep -q usbfs /etc/mtab; then
  282. mount -t usbfs usbfs /proc/bus/usb
  283. sleep 3
  284. fi
  285.  
  286. # Clean up temporary files on the /etc and /var volume.
  287. /bin/rm -f /etc/nologin /etc/shutdownpid /fastboot
  288. /bin/rm -f /var/run/utmp /var/run/*.pid /var/run/*/*pid /var/run/gpm* /var/run/news/*
  289.  
  290. # Looks like we have to create this.
  291. cat /dev/null > /var/run/utmp
  292. /bin/chown root:utmp /var/run/utmp
  293. /bin/chmod 664 /var/run/utmp
  294.  
  295. # ��ư�ѥ�᡼���� "vga16" ���ɲä����VGA16�ե졼��Хåե������
  296. # ����ʳ����Ѥ������ "vga" ���Ŭ�������Τ���
  297.  
  298. # Set VGA framebuffer if necessary.
  299. chk_parm () {
  300. /usr/bin/sed -e "
  301. s/\(^\|.* \)$1=\([^ ]*\).*\$/\2/
  302. t
  303. s/\(^\|.* \)\($1\)\( .*\|\$\)/\2/
  304. t
  305. d" /proc/cmdline
  306. }
  307. look_mod () {
  308. [ -n "`/sbin/modprobe -l $1`" -o -n "`/sbin/modprobe -l $1.o`" ]
  309. }
  310. if look_mod vga16fb && [ -n "`chk_parm vga16`" ]; then
  311. /sbin/modprobe vga16fb
  312. fi
  313.  
  314. # ��ư�ѥ�᡼���� "unicon=���󥳡���" ���ɲä���� unicon �����
  315. # (�ե졼��Хåե����ѻ��Τ�)
  316.  
  317. # Set console encoding mode.
  318. UCENC="`chk_parm unicon`"
  319. if look_mod encode-$UCENC &&
  320. [ -x /usr/bin/uniconctrl -a -n "$UCENC" -a -n "`cat /proc/fb`" ]; then
  321. echo "Set console encoding mode: $UCENC."
  322. /sbin/modprobe unikey
  323. /sbin/modprobe encode-$UCENC
  324. /usr/bin/loadunimap /usr/share/unicon/direct.uni
  325. TTYS="`/usr/bin/awk -F'[: ]+' '/^[^#].*:respawn:/{print $6}' /etc/inittab`"
  326. for t in $TTYS; do
  327. /usr/bin/uniconctrl --$UCENC $t
  328. done
  329. fi
  330.  
  331. # Load a custom screen font if the user has an rc.font script.
  332. if [ -x /etc/rc.d/rc.font ]; then
  333. . /etc/rc.d/rc.font
  334. fi
  335.  
  336. # Load a custom keymap if the user has an rc.keymap script.
  337. if [ -x /etc/rc.d/rc.keymap ]; then
  338. . /etc/rc.d/rc.keymap
  339. fi
  340.  
  341. # We need to update any files added in DOS if using UMSDOS.
  342. if [ "$ROOTTYPE" = "umsdos" ]; then
  343. echo "Synchronizing UMSDOS directory structure..."
  344. umssync -r99 -v- /
  345. fi
  346.  
  347. # /etc/issue �� /etc/motd ��ƥ�ץ졼�� (*.in) ������
  348. # �ƥ�ץ졼���桢%s�������ƥ�̾ / %r�������ƥ��꡼�� / %v��OS�С������ /
  349. # %m���ϡ��ɥ��������� / %p���ץ��å����� �ˡ����줾���ִ������
  350.  
  351. # Generate the /etc/issue and /etc/motd.
  352. UNS=`uname -s`; UNR=`uname -r`; UNV=`uname -v`; UNM=`uname -m`; UNP=`uname -p`
  353. makemsg () {
  354. /usr/bin/sed -e "s/%s/$UNS/g" -e "s/%r/$UNR/g" -e "s/%v/$UNV/g" \
  355. -e "s/%m/$UNM/g" -e "s/%p/$UNP/g" $1.in > $1
  356. }
  357. makemsg /etc/issue
  358. makemsg /etc/motd
  359.  
  360. # Run serial port setup script:
  361. # (CAREFUL! This can make some systems hang if the rc.serial script isn't
  362. # set up correctly. If this happens, you may have to edit the file from a
  363. # boot disk)
  364. #
  365. # . /etc/rc.d/rc.serial
Add Comment
Please, Sign In to add comment