2007-09-23 08:05:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
|
|
|
## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
|
|
|
|
##
|
|
|
|
## live-build comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:05:13 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Including common functions
|
2010-08-14 18:29:05 +00:00
|
|
|
. "${LH_BASE:-/usr/share/live/build}"/scripts/build.sh
|
2007-09-23 08:05:13 +00:00
|
|
|
|
|
|
|
# Setting static variables
|
2009-01-15 01:37:42 -01:00
|
|
|
DESCRIPTION="$(Echo 'manage /bin/hostname')"
|
2007-09-23 08:05:13 +00:00
|
|
|
HELP=""
|
|
|
|
USAGE="${PROGRAM} {install|remove} [--force]"
|
|
|
|
|
|
|
|
Arguments "${@}"
|
|
|
|
|
|
|
|
# Reading configuration files
|
2008-10-28 14:26:17 -01:00
|
|
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
2007-09-23 08:05:13 +00:00
|
|
|
Set_defaults
|
|
|
|
|
|
|
|
# Requiring stage file
|
2008-10-14 19:32:50 +00:00
|
|
|
Require_stagefile .stage/config .stage/bootstrap
|
2007-09-23 08:05:13 +00:00
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
install)
|
|
|
|
Echo_message "Configuring file /etc/hostname"
|
|
|
|
|
|
|
|
# Checking stage file
|
|
|
|
Check_stagefile .stage/chroot_hostname
|
|
|
|
|
|
|
|
# Checking lock file
|
|
|
|
Check_lockfile .lock
|
|
|
|
|
|
|
|
# Creating lock file
|
|
|
|
Create_lockfile .lock
|
|
|
|
|
2007-09-23 08:05:17 +00:00
|
|
|
# Save hostname
|
|
|
|
mv chroot/bin/hostname chroot/bin/hostname.orig
|
2007-09-23 08:05:13 +00:00
|
|
|
|
|
|
|
# Create hostname file
|
|
|
|
echo "localhost.localdomain" > chroot/etc/hostname
|
|
|
|
|
2007-09-23 08:05:17 +00:00
|
|
|
Echo_message "Configuring file /bin/hostname"
|
|
|
|
|
|
|
|
# Create hostname program
|
|
|
|
|
|
|
|
cat > chroot/bin/hostname << EOF
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo "localhost.localdomain"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod 755 chroot/bin/hostname
|
2007-09-23 08:05:13 +00:00
|
|
|
|
|
|
|
# Creating stage file
|
|
|
|
Create_stagefile .stage/chroot_hostname
|
|
|
|
;;
|
|
|
|
|
|
|
|
remove)
|
|
|
|
Echo_message "Deconfiguring file /etc/hostname"
|
|
|
|
|
|
|
|
# Checking lock file
|
|
|
|
Check_lockfile .lock
|
|
|
|
|
|
|
|
# Creating lock file
|
|
|
|
Create_lockfile .lock
|
|
|
|
|
2009-10-13 11:24:56 +00:00
|
|
|
# Copying hostname from local-includes, if existing
|
|
|
|
if [ -e config/chroot_local-includes/etc/hostname ]
|
|
|
|
then
|
|
|
|
cp -a config/chroot_local-includes/etc/hostname chroot/etc/hostname
|
|
|
|
fi
|
|
|
|
|
2007-09-23 08:05:17 +00:00
|
|
|
Echo_message "Deconfiguring file /bin/hostname"
|
|
|
|
|
|
|
|
# Restore hostname file
|
2009-09-02 05:32:45 +00:00
|
|
|
if [ -e chroot/bin/hostname.orig ]
|
|
|
|
then
|
|
|
|
mv chroot/bin/hostname.orig chroot/bin/hostname
|
|
|
|
fi
|
2007-09-23 08:05:13 +00:00
|
|
|
|
|
|
|
# Removing stage file
|
|
|
|
rm -f .stage/chroot_hostname
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
Usage
|
|
|
|
;;
|
|
|
|
esac
|