source: trunk/debian/rootfs/files/all/etc/init.d/debwrt @ 880

Last change on this file since 880 was 880, checked in by amain, 3 years ago

rootfs: several minor fixes

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/sh
2
3### BEGIN INIT INFO
4# Provides:          debwrt
5# Author:            Johan van Zoomeren <amain@debwrt.net>
6# Required-Start:   
7# Required-Stop:     
8# Default-Start:     S
9# Default-Stop:      0 1 6
10# X-Start-Before:    mountkernfs
11# Short-Description: Copy target specific files
12# Description:       DebWrt rootfs are generic images. However most targets
13#                    customized files. Mostly in /etc. When the kernel boots
14#                    we don't known which target/sub-target we're dealing with,
15#                    hence the files /lib/modules/debwrt.target and
16#                    /lib/modules/debwrt.sub-target are installed when
17#                    extracting the target specific debwrt-modules<version>.tar.gz.
18### END INIT INFO
19
20# Include core init functions if needed
21. /lib/lsb/init-functions
22
23DESC="DebWrt"
24
25is_ro()
26{
27    touch /.is_rw 1>/dev/null 2>/dev/null
28    err=$?
29    rm -f /.is_rw
30    if [ ! ${err} -eq 0 ]
31    then
32        return 0
33    else
34        return 1
35    fi
36}
37
38start()
39{
40    target=$(cat /lib/modules/debwrt.target 2>/dev/null)
41    subtarget=$(cat /lib/modules/debwrt.sub-target 2>/dev/null)
42
43    if [ "" != "${target}" -a "" != "${subtarget}" ]
44    then
45        if [ ! -f /etc/debwrt/target.installed ]
46        then
47            mkdir -p /etc/debwrt
48            if [ -d /target/${target} ]
49            then
50                log_action_msg "Extracting target '${target}' specific files from /target/${target}"
51                if is_ro
52                then
53                    mount -o remount,rw /
54                    makero=1
55                fi
56                tar cf - -C /target/${target} . | tar xf - --warning=no-timestamp -C /
57                if [ "${makero}" = "1" ]
58                then
59                    mount -o remount,ro /
60                fi
61            else
62                # no extra files for this target
63                :
64            fi
65            touch /etc/debwrt/target.installed
66        fi
67    else
68        log_warning_msg "No targets configured in /lib/modules/debwrt.target and/or /lib/modules/debwrt.subtarget. Unabl"
69    fi
70}
71
72case "${1}" in
73    start)
74        log_action_msg "Starting --- DebWrt ---"
75        start
76        return 0
77    ;;
78    *)
79        echo "usage: $(basename ${0}) start"
80    ;;
81esac
82
Note: See TracBrowser for help on using the repository browser.