source: live-build/trunk/fuentes/scripts/build/lb_chroot_resolv @ 900

Last change on this file since 900 was 900, checked in by kbut, 4 years ago

add original source

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program 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
11set -e
12
13# Including common functions
14( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
15
16# Setting static variables
17DESCRIPTION="$(Echo 'manage /etc/resolv.conf')"
18HELP=""
19USAGE="${PROGRAM} {install|remove} [--force]"
20
21Arguments "${@}"
22
23# Reading configuration files
24Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25Set_defaults
26
27# Requiring stage file
28Require_stagefile .build/config .build/bootstrap
29
30case "${1}" in
31        install)
32                Echo_message "Configuring file /etc/resolv.conf"
33
34                # Checking stage file
35                Check_stagefile .build/chroot_resolv
36
37                # Checking lock file
38                Check_lockfile .lock
39
40                # Creating lock file
41                Create_lockfile .lock
42
43                if [ -e chroot/etc/resolv.conf ]
44                then
45                        # Save resolv file or symlink
46                        mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig
47
48                        # Also truncate it, otherwise we'll end up with the one
49                        # created by debootstrap in the final image.
50                        #
51                        # If you want to have a custom resolv.conf, please
52                        # overwrite it with normal local_includes mechanism.
53                        Truncate chroot/etc/resolv.conf.orig
54                elif [ -L chroot/etc/resolv.conf ]
55                then
56                        # Move resolv.conf aside if it's a symlink (likely resolvconf)
57                        mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig
58                fi
59
60                if [ -f /etc/resolv.conf ]
61                then
62                        # Copy resolv file
63                        cp /etc/resolv.conf chroot/etc/resolv.conf
64                fi
65
66                # Creating stage file
67                Create_stagefile .build/chroot_resolv
68                ;;
69
70        remove)
71                Echo_message "Deconfiguring file /etc/resolv.conf"
72
73                # Checking lock file
74                Check_lockfile .lock
75
76                # Creating lock file
77                Create_lockfile .lock
78
79                if [ -e config/includes.chroot/etc/resolv.conf ] ||  [ -L config/includes.chroot/etc/resolv.conf ];
80                then
81                        # Copying local resolv.conf
82                        cp -a config/includes.chroot/etc/resolv.conf chroot/etc/resolv.conf
83                        rm -f chroot/etc/resolv.conf.orig
84                elif [ -e chroot/etc/resolv.conf.orig ] || [ -L chroot/etc/resolv.conf.orig ]
85                then
86                        # Restoring resolv file or symlink
87                        mv chroot/etc/resolv.conf.orig chroot/etc/resolv.conf
88                else
89                        # Truncating resolv file
90                        Truncate chroot/etc/resolv.conf
91                fi
92
93                # Clean up resolvconf's pollution
94                if [ -d chroot/etc/resolvconf/resolv.conf.d ]; then
95                        rm -f chroot/etc/resolvconf/resolv.conf.d/original
96                        rm -f chroot/etc/resolvconf/resolv.conf.d/tail
97                fi
98
99                # Removing stage file
100                rm -f .build/chroot_resolv
101                ;;
102
103        *)
104                Usage
105                ;;
106esac
Note: See TracBrowser for help on using the repository browser.