source: live-build/trunk/fuentes/scripts/build/lb_chroot_hostname @ 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.0 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 /bin/hostname')"
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                # Checking stage file
33                Check_stagefile .build/chroot_hostname
34
35                # Checking lock file
36                Check_lockfile .lock
37
38                # Creating lock file
39                Create_lockfile .lock
40
41                # Create hostname file
42                Echo_message "Configuring file /etc/hostname"
43
44                echo "localhost.localdomain" > chroot/etc/hostname
45
46                # Create custom hostname
47                Echo_message "Configuring file /bin/hostname"
48
49                Chroot chroot dpkg-divert --rename --quiet --add /bin/hostname
50
51cat > chroot/bin/hostname << EOF
52#!/bin/sh
53
54echo "localhost.localdomain"
55EOF
56
57                chmod 755 chroot/bin/hostname
58
59                # Creating stage file
60                Create_stagefile .build/chroot_hostname
61                ;;
62
63        remove)
64                Echo_message "Deconfiguring file /etc/hostname"
65
66                # Checking lock file
67                Check_lockfile .lock
68
69                # Creating lock file
70                Create_lockfile .lock
71
72                # Copying hostname from includes, if existing
73                if [ -e config/includes.chroot/etc/hostname ]
74                then
75                        cp -a config/includes.chroot/etc/hostname chroot/etc/hostname
76                fi
77
78                Echo_message "Deconfiguring file /bin/hostname"
79
80                # Remove custom hostname
81                rm -f chroot/bin/hostname
82                Chroot chroot dpkg-divert --rename --quiet --remove /bin/hostname
83
84                # Removing stage file
85                rm -f .build/chroot_hostname
86                ;;
87
88        *)
89                Usage
90                ;;
91esac
Note: See TracBrowser for help on using the repository browser.