live-build/helpers/lh_chroot_hostname

91 lines
1.8 KiB
Plaintext
Raw Normal View History

2007-09-23 08:05:13 +00:00
#!/bin/sh
2007-09-23 08:05:17 +00:00
# lh_chroot_hostname(1) - manage /bin/hostname
2008-03-06 14:43:00 -01:00
# Copyright (C) 2006-2008 Daniel Baumann <daniel@debian.org>
2007-09-23 08:05:13 +00:00
#
# live-helper 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.
set -e
# Including common functions
LH_BASE="${LH_BASE:-/usr/share/live-helper}"
for FUNCTION in "${LH_BASE}"/functions/*.sh
do
. "${FUNCTION}"
done
# Setting static variables
2007-09-23 08:05:17 +00:00
DESCRIPTION="manage /bin/hostname"
2007-09-23 08:05:13 +00:00
HELP=""
USAGE="${PROGRAM} {install|remove} [--force]"
Arguments "${@}"
# Reading configuration files
2008-04-07 10:10:21 +00:00
Read_conffile 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
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
2007-09-23 08:05:17 +00:00
Echo_message "Deconfiguring file /bin/hostname"
# Restore hostname file
mv chroot/bin/hostname.orig chroot/bin/hostname
2007-09-23 08:05:13 +00:00
# Removing stage file
rm -f .stage/chroot_hostname
;;
*)
Usage
;;
esac