Compare commits

..

6 Commits

Author SHA1 Message Date
Daniel Robbins
d308a781f2 Copyright update 2015-03-14 17:46:23 -06:00
Daniel Robbins
888bc07f7b Update /etc/conf.d/hostname with better documentation. 2015-03-14 17:43:26 -06:00
Daniel Robbins
8169cd89b1 Revert "FL-227: Change how /etc/hosts is generated"
This change was never discussed in the bug on the bug tracker. It is thus being removed.

This reverts commit 6b78f4c8e0.
2015-03-14 17:38:50 -06:00
Daniel Robbins
e67ab2da48 FL-1906: fix hostname setting so 'hostname' returns short, not full, hostname. 2015-01-03 21:22:27 -07:00
Oleg Vinichenko
8137d15c1a FL-1729: backport tmpfiles changes from upstream 2014-12-02 20:40:58 +00:00
Dantrell B
7447c63e02 Replace space with tab in conf.d/hostname 2014-08-16 02:23:49 -04:00
5 changed files with 85 additions and 50 deletions

View File

@@ -1,15 +1,18 @@
# Set to the fully qualified domain name (e.g. "mybox.example.com") of # Set to the fully qualified domain name (e.g. "mybox.example.com") of this
# this machine, if it has one, otherwise set to the machine name # machine, if it has one, otherwise set to the machine name (e.g. "mybox").
# (e.g. "mybox"). # This hostname will be automatically added to /etc/hosts for the 127.0.0.1 and
# ::1 addresses.
hostname="localhost" hostname="localhost"
# Set to the NIS domain name of this machine, if it has one, otherwise # If your local system has other aliases for your local interfaces, you can
# leave commented out. # add them here. These will also be added to /etc/hosts for 127.0.0.1 and ::1:
#nisdomainname="localdomain.com" # Add aliases for other hosts to /etc/hosts directly. The networking scripts
# automatically generate the localhost lines only.
# Set other alias-to-address mappings, if needed, otherwise leave #aliases="mybox server1"
# Set to the NIS domain name of this machine, if it has one, otherwise leave
# commented out. # commented out.
#aliases="127.0.0.1 mybox
#10.0.0.1 mylaptop #nisdomainname="localdomain.com"
#172.16.0.1 myserver
#192.168.0.1 myworkstation"

View File

@@ -1,5 +1,5 @@
#!@PREFIX@/sbin/runscript #!@PREFIX@/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> # Copyright (c) 2009-2015 Funtoo Technologies
# Released under the 2-clause BSD license. # Released under the 2-clause BSD license.
description="Sets the hostname of the machine." description="Sets the hostname of the machine."
@@ -27,32 +27,17 @@ start()
if [ "$hostname" != "localhost.localdomain" ]; then if [ "$hostname" != "localhost.localdomain" ]; then
out="$out localhost.localdomain" out="$out localhost.localdomain"
fi fi
[ -n "$aliases" ] && out2="$aliases" [ -n "$aliases" ] && out="$out $aliases"
ebegin "Configuring /etc/hosts" ebegin "Configuring /etc/hosts"
cat << END > /etc/hosts [ -e /etc/hosts ] && sed -i -e '/[[:space:]]*127.0.0.1[[:space:]]/d' -e '/[[:space:]]*::1[[:space:]]/d' /etc/hosts
# Local Host Database cat <<END >> /etc/hosts
#
# This AUTOMATICALLY-GENERATED file describes a number of aliases-to-address
# mappings for the local hosts that share this file.
#
# In the presence of the domain name service or NIS, this file may not be
# consulted at all; see /etc/host.conf for the resolution order.
#
# DO NOT EDIT THIS FILE BY HAND; YOUR CHANGES WILL BE OVERWRITTEN
#
# Define alias-to-address mappings in /etc/conf.d/hostname
# IPv4 and IPv6 localhost aliases
127.0.0.1 $out 127.0.0.1 $out
::1 $out ::1 $out
# Other aliases
$out2
END END
chmod 0644 /etc/hosts chmod 0644 /etc/hosts
eend $? eend $?
[ "$RC_SYS" = "LXC" ] && return 0 [ "$RC_SYS" = "LXC" ] && return 0
ebegin "Setting hostname to $hostname" ebegin "Setting hostname to $hostname"
hostname "$hostname" hostname "$short"
eend $? "Failed to set the hostname" eend $? "Failed to set the hostname"
} }

View File

@@ -14,8 +14,7 @@ depend()
start() start()
{ {
ebegin "setting up tmpfiles.d entries for /dev" ebegin "setting up tmpfiles.d entries for /dev"
@LIBEXECDIR@/sh/tmpfiles.sh --prefix=/dev --create --remove \ @LIBEXECDIR@/sh/tmpfiles.sh --prefix=/dev --create ${tmpfiles_opts}
${tmpfiles_opts}
eend $? eend $?
return 0 return 0
} }

View File

@@ -12,7 +12,7 @@ depend()
start() start()
{ {
ebegin "setting up tmpfiles.d entries" ebegin "setting up tmpfiles.d entries"
@LIBEXECDIR@/sh/tmpfiles.sh --exclude-prefix=/dev --create --remove \ @LIBEXECDIR@/sh/tmpfiles.sh --exclude-prefix=/dev --create --remove --boot \
${tmpfiles_opts} ${tmpfiles_opts}
eend $? eend $?
return 0 return 0

View File

@@ -3,10 +3,11 @@
# Control creation, deletion, and cleaning of volatile and temporary files # Control creation, deletion, and cleaning of volatile and temporary files
# #
# Copyright (c) 2012 Gentoo Foundation # Copyright (c) 2012 Gentoo Foundation
# Released under the 2-clause BSD license.
# #
# This instance based on the Arch Linux version: # This instance is a pure-POSIX sh version, written by Robin H Johnson
# <robbat2@gentoo.org>, based on the Arch Linux version as of 2012/01/01:
# http://projects.archlinux.org/initscripts.git/tree/arch-tmpfiles # http://projects.archlinux.org/initscripts.git/tree/arch-tmpfiles
# As of 2012/01/01
# #
# See the tmpfiles.d manpage as well: # See the tmpfiles.d manpage as well:
# http://0pointer.de/public/systemd-man/tmpfiles.d.html # http://0pointer.de/public/systemd-man/tmpfiles.d.html
@@ -14,6 +15,7 @@
# #
DRYRUN=0 DRYRUN=0
CHECKPATH="@LIBEXECDIR@/bin/checkpath"
checkprefix() { checkprefix() {
n=$1 n=$1
@@ -43,19 +45,27 @@ relabel() {
for path in ${paths}; do for path in ${paths}; do
if [ -e "$path" ]; then if [ -e "$path" ]; then
[ -x /sbin/restorecon ] && dryrun_or_real restorecon $CHOPTS "$path"
[ $uid != '-' ] && dryrun_or_real chown $CHOPTS "$uid" "$path" [ $uid != '-' ] && dryrun_or_real chown $CHOPTS "$uid" "$path"
[ $gid != '-' ] && dryrun_or_real chgrp $CHOPTS "$gid" "$path" [ $gid != '-' ] && dryrun_or_real chgrp $CHOPTS "$gid" "$path"
[ $mode != '-' ] && dryrun_or_real chmod $CHOPTS "$mode" "$path" [ $mode != '-' ] && dryrun_or_real chmod $CHOPTS "$mode" "$path"
[ -x /sbin/restorecon ] && dryrun_or_real restorecon $CHOPTS "$path"
fi fi
done done
} }
_restorecon() {
local path=$1
if [ -x /sbin/restorecon ]; then
dryrun_or_real restorecon -F "$path"
fi
}
_b() { _b() {
# Create a block device node if it doesn't exist yet # Create a block device node if it doesn't exist yet
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6 local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
if [ ! -e "$path" ]; then if [ ! -e "$path" ]; then
dryrun_or_real mknod -m $mode $path b ${arg%:*} ${arg#*:} dryrun_or_real mknod -m $mode $path b ${arg%:*} ${arg#*:}
_restorecon "$path"
dryrun_or_real chown $uid:$gid $path dryrun_or_real chown $uid:$gid $path
fi fi
} }
@@ -65,10 +75,22 @@ _c() {
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6 local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
if [ ! -e "$path" ]; then if [ ! -e "$path" ]; then
dryrun_or_real mknod -m $mode $path c ${arg%:*} ${arg#*:} dryrun_or_real mknod -m $mode $path c ${arg%:*} ${arg#*:}
_restorecon "$path"
dryrun_or_real chown $uid:$gid $path dryrun_or_real chown $uid:$gid $path
fi fi
} }
_C() {
# recursively copy a file or directory
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
if [ ! -e "$path" ]; then
dryrun_or_real cp -r "$arg" "$path"
_restorecon "$path"
[ $uid != '-' ] && dryrun_or_real chown "$uid" "$path"
[ $gid != '-' ] && dryrun_or_real chgrp "$gid" "$path"
[ $mode != '-' ] && dryrun_or_real chmod "$mode" "$path"
fi
}
_f() { _f() {
# Create a file if it doesn't exist yet # Create a file if it doesn't exist yet
@@ -77,7 +99,7 @@ _f() {
[ $CREATE -gt 0 ] || return 0 [ $CREATE -gt 0 ] || return 0
if [ ! -e "$path" ]; then if [ ! -e "$path" ]; then
dryrun_or_real install -m"$mode" -o"$uid" -g"$gid" /dev/null "$path" dryrun_or_real $CHECKPATH -fq -m "$mode" -o "$uid:$gid" "$path"
[ -z "$arg" ] || _w "$@" [ -z "$arg" ] || _w "$@"
fi fi
} }
@@ -88,7 +110,7 @@ _F() {
[ $CREATE -gt 0 ] || return 0 [ $CREATE -gt 0 ] || return 0
dryrun_or_real install -m"$mode" -o"$uid" -g"$gid" /dev/null "$path" dryrun_or_real $CHECKPATH -Fq -m "$mode" -o "$uid:$gid" "$path"
[ -z "$arg" ] || _w "$@" [ -z "$arg" ] || _w "$@"
} }
@@ -99,7 +121,8 @@ _d() {
[ $CREATE -gt 0 ] || return 0 [ $CREATE -gt 0 ] || return 0
if [ ! -d "$path" ]; then if [ ! -d "$path" ]; then
dryrun_or_real install -d -m"$mode" -o"$uid" -g"$gid" "$path" dryrun_or_real mkdir -p "$path" 2>/dev/null
dryrun_or_real $CHECKPATH -dq -m "$mode" -o "$uid:$gid" "$path"
fi fi
} }
@@ -109,10 +132,12 @@ _D() {
if [ -d "$path" ] && [ $REMOVE -gt 0 ]; then if [ -d "$path" ] && [ $REMOVE -gt 0 ]; then
dryrun_or_real find "$path" -mindepth 1 -maxdepth 1 -xdev -exec rm -rf {} + dryrun_or_real find "$path" -mindepth 1 -maxdepth 1 -xdev -exec rm -rf {} +
_restorecon "$path"
fi fi
if [ $CREATE -gt 0 ]; then if [ $CREATE -gt 0 ]; then
dryrun_or_real install -d -m"$mode" -o"$uid" -g"$gid" "$path" dryrun_or_real mkdir -p "$path" 2>/dev/null
dryrun_or_real $CHECKPATH -Dq -m "$mode" -o "$uid:$gid" "$path"
fi fi
} }
@@ -120,6 +145,7 @@ _L() {
# Create a symlink if it doesn't exist yet # Create a symlink if it doesn't exist yet
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6 local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
[ ! -e "$path" ] && dryrun_or_real ln -s "$arg" "$path" [ ! -e "$path" ] && dryrun_or_real ln -s "$arg" "$path"
_restorecon "$path"
} }
_p() { _p() {
@@ -129,8 +155,7 @@ _p() {
[ $CREATE -gt 0 ] || return 0 [ $CREATE -gt 0 ] || return 0
if [ ! -p "$path" ]; then if [ ! -p "$path" ]; then
dryrun_or_real mkfifo -m$mode "$path" dryrun_or_real $CHECKPATH -pq -m $mode -o "$uid:$gid" "$path"
dryrun_or_real chown "$uid:$gid" "$path"
fi fi
} }
@@ -214,7 +239,7 @@ _Z() {
CHOPTS=-R relabel "$@" CHOPTS=-R relabel "$@"
} }
CREATE=0 REMOVE=0 CLEAN=0 VERBOSE=0 DRYRUN=0 error=0 LINENO=0 BOOT=0 CREATE=0 REMOVE=0 CLEAN=0 VERBOSE=0 DRYRUN=0 error=0 LINENO=0
EXCLUDE= EXCLUDE=
PREFIX= PREFIX=
FILE= FILE=
@@ -230,11 +255,13 @@ tmpfiles_d=''
# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf' # `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
for d in ${tmpfiles_dirs} ; do for d in ${tmpfiles_dirs} ; do
[ -d $d ] && for f in ${d}/*.conf ; do [ -d $d ] && for f in ${d}/*.conf ; do
[ "$f" = "$d/systemd.conf" ] && continue case "${f##*/}" in
systemd.conf|systemd-*.conf) continue;;
esac
[ -f $f ] && tmpfiles_basenames="${tmpfiles_basenames}\n${f##*/}" [ -f $f ] && tmpfiles_basenames="${tmpfiles_basenames}\n${f##*/}"
done # for f in ${d} done # for f in ${d}
done # for d in ${tmpfiles_dirs} done # for d in ${tmpfiles_dirs}
tmpfiles_basenames="`printf "${tmpfiles_basenames}\n" | sort | uniq`" tmpfiles_basenames="$(printf "${tmpfiles_basenames}\n" | sort -u )"
for b in $tmpfiles_basenames ; do for b in $tmpfiles_basenames ; do
real_f='' real_f=''
@@ -247,6 +274,7 @@ done
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case $1 in case $1 in
--boot) BOOT=1 ;;
--create) CREATE=1 ;; --create) CREATE=1 ;;
--remove) REMOVE=1 ;; --remove) REMOVE=1 ;;
--clean) CLEAN=1 ;; # TODO: Not implemented --clean) CLEAN=1 ;; # TODO: Not implemented
@@ -264,7 +292,7 @@ if [ $(( CLEAN )) -eq 1 ] ; then
fi fi
if [ "$CREATE$REMOVE" = '00' ]; then if [ "$CREATE$REMOVE" = '00' ]; then
printf 'usage: %s [--exclude-prefix=path] [--prefix=path] [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}" printf 'usage: %s [--exclude-prefix=path] [--prefix=path] [--boot] [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}"
exit 1 exit 1
fi fi
@@ -281,21 +309,34 @@ for FILE in $tmpfiles_d ; do
# Cmd Path Mode UID GID Age Argument # Cmd Path Mode UID GID Age Argument
# d /run/user 0755 root root 10d - # d /run/user 0755 root root 10d -
# Mode, UID, GID, Age, Argument may be omitted! # Mode, UID, GID, Age, Argument may be omitted!
# If Cmd ends with !, the line is only processed if --boot is passed
# XXX: Upstream says whitespace is NOT permitted in the Path argument. # XXX: Upstream says whitespace is NOT permitted in the Path argument.
# But IS allowed when globs are expanded for the x/r/R/z/Z types. # But IS allowed when globs are expanded for the x/r/R/z/Z types.
while read cmd path mode uid gid age arg; do while read cmd path mode uid gid age arg; do
LINENUM=$(( LINENUM+1 )) LINENUM=$(( LINENUM+1 ))
FORCE=0
# Unless we have both command and path, skip this line. # Unless we have both command and path, skip this line.
if [ -z "$cmd" -o -z "$path" ]; then if [ -z "$cmd" -o -z "$path" ]; then
continue continue
fi fi
case $cmd in
\#*) continue ;;
esac
while [ ${#cmd} -gt 1 ]; do
case $cmd in
*!) cmd=${cmd%!}; [ "$BOOT" -eq "1" ] || continue 2 ;;
*+) cmd=${cmd%+}; FORCE=1; ;;
*) warninvalid ; continue 2 ;;
esac
done
# whine about invalid entries # whine about invalid entries
case $cmd in case $cmd in
f|F|w|d|D|p|L|c|b|x|X|r|R|z|Z) ;; f|F|w|d|D|p|L|c|C|b|x|X|r|R|z|Z) ;;
\#) continue ;;
*) warninvalid ; continue ;; *) warninvalid ; continue ;;
esac esac
@@ -304,7 +345,7 @@ for FILE in $tmpfiles_d ; do
case "$cmd" in case "$cmd" in
p|f|F) mode=0644 ;; p|f|F) mode=0644 ;;
d|D) mode=0755 ;; d|D) mode=0755 ;;
z|Z|x|r|R|L) ;; C|z|Z|x|r|R|L) ;;
esac esac
fi fi
@@ -316,6 +357,13 @@ for FILE in $tmpfiles_d ; do
[ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && continue [ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && continue
[ -n "$PREFIX" ] && ! checkprefix $path $PREFIX && continue [ -n "$PREFIX" ] && ! checkprefix $path $PREFIX && continue
if [ $FORCE -gt 0 ]; then
case $cmd in
p|L|c|b) [ -f "$path" ] && dryrun_or_real rm -f "$path"
esac
fi
[ "$VERBOSE" -eq "1" ] && echo _$cmd "$@" [ "$VERBOSE" -eq "1" ] && echo _$cmd "$@"
_$cmd "$@" _$cmd "$@"
rc=$? rc=$?