~timrchavez/live-build/lb-sg-2.x-add-suppport-for-pxz

« back to all changes in this revision

Viewing changes to scripts/build/chroot_sysv-rc

  • Committer: Daniel Baumann
  • Date: 2011-03-09 18:17:15 UTC
  • Revision ID: daniel@debian.org-20110309181715-2s6s9tqa8xup5aep
Rearranging helpers scripts in source tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# lh_chroot_sysv-rc(1) - manage /usr/sbin/policy-rc.d
 
4
# Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
 
5
#
 
6
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 
7
# This is free software, and you are welcome to redistribute it
 
8
# under certain conditions; see COPYING for details.
 
9
 
 
10
set -e
 
11
 
 
12
# Including common functions
 
13
. "${LH_BASE:-/usr/share/live-helper}"/scripts/build.sh
 
14
 
 
15
# Setting static variables
 
16
DESCRIPTION="$(Echo 'manage /usr/sbin/policy-rc.d')"
 
17
HELP=""
 
18
USAGE="${PROGRAM} {install|remove} [--force]"
 
19
 
 
20
Arguments "${@}"
 
21
 
 
22
# Reading configuration files
 
23
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
 
24
Set_defaults
 
25
 
 
26
# Requiring stage file
 
27
Require_stagefile .stage/config .stage/bootstrap
 
28
 
 
29
case "${1}" in
 
30
        install)
 
31
                Echo_message "Configuring file /usr/sbin/policy-rc.d"
 
32
 
 
33
                # Checking stage file
 
34
                Check_stagefile .stage/chroot_sysv-rc
 
35
 
 
36
                # Checking lock file
 
37
                Check_lockfile .lock
 
38
 
 
39
                # Creating lock file
 
40
                Create_lockfile .lock
 
41
 
 
42
                if [ -f chroot/usr/sbin/policy-rc.d ]
 
43
                then
 
44
                        # Save policy-rc.d file
 
45
                        mv chroot/usr/sbin/policy-rc.d chroot/usr/sbin/policy-rc.d.orig
 
46
                fi
 
47
 
 
48
                # Create policy-rc.d file
 
49
cat > chroot/usr/sbin/policy-rc.d << EOF
 
50
#!/bin/sh
 
51
echo "All runlevel operations denied by policy" >&2
 
52
exit 101
 
53
EOF
 
54
 
 
55
                chmod 0755 chroot/usr/sbin/policy-rc.d
 
56
 
 
57
                # Creating stage file
 
58
                Create_stagefile .stage/chroot_sysv-rc
 
59
                ;;
 
60
 
 
61
        remove)
 
62
                Echo_message "Deconfiguring file /usr/sbin/policy-rc.d"
 
63
 
 
64
                # Checking lock file
 
65
                Check_lockfile .lock
 
66
 
 
67
                # Creating lock file
 
68
                Create_lockfile .lock
 
69
 
 
70
                if [ -f chroot/usr/sbin/policy-rc.d.orig ]
 
71
                then
 
72
                        # Restore policy-rc.d file
 
73
                        mv chroot/usr/sbin/policy-rc.d.orig chroot/usr/sbin/policy-rc.d
 
74
                else
 
75
                        # Remove policy-rc.d file
 
76
                        rm -f chroot/usr/sbin/policy-rc.d
 
77
                fi
 
78
 
 
79
                # Removing stage file
 
80
                rm -f .stage/chroot_sysv-rc
 
81
                ;;
 
82
 
 
83
        *)
 
84
                Usage
 
85
                ;;
 
86
esac