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

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

add original source

  • Property svn:executable set to *
File size: 2.1 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/hosts')"
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/hosts"
33
34                # Checking stage file
35                Check_stagefile .build/chroot_hosts
36
37                # Checking lock file
38                Check_lockfile .lock
39
40                # Creating lock file
41                Create_lockfile .lock
42
43                if [ -f chroot/etc/hosts ]
44                then
45                        # Save hosts file
46                        mv chroot/etc/hosts chroot/etc/hosts.orig
47                fi
48
49                # Creating hosts file
50
51cat > chroot/etc/hosts << EOF
52127.0.0.1       localhost localhost.localdomain
53127.0.1.1       debian
54EOF
55
56                if [ -f /etc/hosts ]
57                then
58                        # Append hosts file
59                        #grep -e "127.0.0.1" -e "127.0.1.1" /etc/hosts >> chroot/etc/hosts
60                        cat /etc/hosts >> chroot/etc/hosts
61                fi
62
63                # Creating stage file
64                Create_stagefile .build/chroot_hosts
65                ;;
66
67        remove)
68                Echo_message "Deconfiguring file /etc/hosts"
69
70                # Checking lock file
71                Check_lockfile .lock
72
73                # Creating lock file
74                Create_lockfile .lock
75
76                if [ -e config/includes.chroot/etc/hosts ]
77                then
78                        # Copying local hosts
79                        cp -a config/includes.chroot/etc/hosts chroot/etc/hosts
80                        rm -f chroot/etc/hosts.orig
81                elif [ -f chroot/etc/hosts.orig ]
82                then
83                        # Restore hosts file
84                        mv chroot/etc/hosts.orig chroot/etc/hosts
85                else
86                        # Blank out hosts file, don't remove in case
87                        # its a symlink, as in the case of exposedroot mode
88                        Truncate chroot/etc/hosts
89                fi
90
91                # Removing stage file
92                rm -f .build/chroot_hosts
93                ;;
94
95        *)
96                Usage
97                ;;
98esac
Note: See TracBrowser for help on using the repository browser.