File: bootcd.init

package info (click to toggle)
bootcd 6.4
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 540 kB
  • sloc: sh: 1,914; makefile: 50
file content (95 lines) | stat: -rwxr-xr-x 1,997 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          bootcd
# Required-Start:    mountall-bootclean $local_fs
# Required-Stop:
# X-Start-Before:    networking
# Default-Start:     S
# Default-Stop:
# Short-Description: bootcd reads changes from floppy if running from bootcd
# Description:       When running from bootcd this script tries to access
#                    the floppy to read changes last time saved with
#                    bootcdflopcp from a running bootcd.
### END INIT INFO

. /lib/lsb/init-functions

MNT=/mnt
FLOPPY=/dev/fd0
BOOT_ONLY_WITH_FLOPPY="no"
FSTYPES="ext3,ext2,reiserfs,iso9660,vfat,auto"

my_exit()
{
  echo "bootcd: $2"
  if [ "$BOOT_ONLY_WITH_FLOPPY" = "yes" -a $1 != 0 ]; then
    echo "The floppy could not be mounted."
    echo "Manual interaction required."
    # Start a single user shell on the console
    /sbin/sulogin $CONSOLE
  fi
  exit 0
}

startscript()
{
  # bootcdwrite modifies this script. FLOPPY could be unset.
  if [ ! "$FLOPPY" ]; then
    my_exit 0 "No Floppy device specified !!"
  fi

  # Only run this script if we have booted from bootcd
  if [ ! "$(grep "\<bootcd=" /proc/cmdline)" ]; then
    my_exit 0 "not booted from bootcd"
  fi

  # Try only once, if /dev/fd0 is readable.
  cat $FLOPPY >/dev/null
  RET=$?
  [ $RET -eq 0 ] || my_exit $RET "$FLOPPY not readable"

  echo "Reading floppy"
  fsck -a -t $FSTYPES $FLOPPY
  mount -v -o ro -n -t $FSTYPES $FLOPPY $MNT
  RET=$?
  [ $RET -eq 0 ] || my_exit $RET "$FLOPPY not mountable"

  [ -f $MNT/change.tgz ] && (cd /; tar xzf $MNT/change.tgz)

  [ -f $MNT/remove ] && for i in `cat $MNT/remove`
  do
    rm -f /$i
  done

  [ -x $MNT/execute ] && $MNT/execute

  umount $MNT

  # If something has been changed in /etc/inittab
  init q
}

case "$1" in
  start)
    startscript
    ;;
  restart)
    ;;
  status)
    ;;
  force-reload)
    ;;
  stop)
    ;;
  restart)
    ;;
  force-reload)
    ;;
  *)
    echo "Usage: /etc/init.d/bootcdram start" >&2
    exit 1
    ;;
esac

exit 0