Compare commits
6 Commits
funtoo-ope
...
funtoo-ope
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d308a781f2 | ||
|
|
888bc07f7b | ||
|
|
8169cd89b1 | ||
|
|
e67ab2da48 | ||
|
|
8137d15c1a | ||
|
|
7447c63e02 |
@@ -1,15 +1,18 @@
|
||||
# Set to the fully qualified domain name (e.g. "mybox.example.com") of
|
||||
# this machine, if it has one, otherwise set to the machine name
|
||||
# (e.g. "mybox").
|
||||
# Set to the fully qualified domain name (e.g. "mybox.example.com") of this
|
||||
# machine, if it has one, otherwise set to the machine name (e.g. "mybox").
|
||||
# This hostname will be automatically added to /etc/hosts for the 127.0.0.1 and
|
||||
# ::1 addresses.
|
||||
|
||||
hostname="localhost"
|
||||
|
||||
# Set to the NIS domain name of this machine, if it has one, otherwise
|
||||
# leave commented out.
|
||||
#nisdomainname="localdomain.com"
|
||||
# If your local system has other aliases for your local interfaces, you can
|
||||
# add them here. These will also be added to /etc/hosts for 127.0.0.1 and ::1:
|
||||
# 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.
|
||||
#aliases="127.0.0.1 mybox
|
||||
#10.0.0.1 mylaptop
|
||||
#172.16.0.1 myserver
|
||||
#192.168.0.1 myworkstation"
|
||||
|
||||
#nisdomainname="localdomain.com"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!@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.
|
||||
|
||||
description="Sets the hostname of the machine."
|
||||
@@ -27,32 +27,17 @@ start()
|
||||
if [ "$hostname" != "localhost.localdomain" ]; then
|
||||
out="$out localhost.localdomain"
|
||||
fi
|
||||
[ -n "$aliases" ] && out2="$aliases"
|
||||
[ -n "$aliases" ] && out="$out $aliases"
|
||||
ebegin "Configuring /etc/hosts"
|
||||
cat << END > /etc/hosts
|
||||
# Local Host Database
|
||||
#
|
||||
# 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
|
||||
[ -e /etc/hosts ] && sed -i -e '/[[:space:]]*127.0.0.1[[:space:]]/d' -e '/[[:space:]]*::1[[:space:]]/d' /etc/hosts
|
||||
cat <<END >> /etc/hosts
|
||||
127.0.0.1 $out
|
||||
::1 $out
|
||||
|
||||
# Other aliases
|
||||
$out2
|
||||
END
|
||||
chmod 0644 /etc/hosts
|
||||
eend $?
|
||||
[ "$RC_SYS" = "LXC" ] && return 0
|
||||
ebegin "Setting hostname to $hostname"
|
||||
hostname "$hostname"
|
||||
hostname "$short"
|
||||
eend $? "Failed to set the hostname"
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ depend()
|
||||
start()
|
||||
{
|
||||
ebegin "setting up tmpfiles.d entries for /dev"
|
||||
@LIBEXECDIR@/sh/tmpfiles.sh --prefix=/dev --create --remove \
|
||||
${tmpfiles_opts}
|
||||
@LIBEXECDIR@/sh/tmpfiles.sh --prefix=/dev --create ${tmpfiles_opts}
|
||||
eend $?
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ depend()
|
||||
start()
|
||||
{
|
||||
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}
|
||||
eend $?
|
||||
return 0
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
# Control creation, deletion, and cleaning of volatile and temporary files
|
||||
#
|
||||
# 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
|
||||
# As of 2012/01/01
|
||||
#
|
||||
# See the tmpfiles.d manpage as well:
|
||||
# http://0pointer.de/public/systemd-man/tmpfiles.d.html
|
||||
@@ -14,6 +15,7 @@
|
||||
#
|
||||
|
||||
DRYRUN=0
|
||||
CHECKPATH="@LIBEXECDIR@/bin/checkpath"
|
||||
|
||||
checkprefix() {
|
||||
n=$1
|
||||
@@ -43,19 +45,27 @@ relabel() {
|
||||
|
||||
for path in ${paths}; do
|
||||
if [ -e "$path" ]; then
|
||||
[ -x /sbin/restorecon ] && dryrun_or_real restorecon $CHOPTS "$path"
|
||||
[ $uid != '-' ] && dryrun_or_real chown $CHOPTS "$uid" "$path"
|
||||
[ $gid != '-' ] && dryrun_or_real chgrp $CHOPTS "$gid" "$path"
|
||||
[ $mode != '-' ] && dryrun_or_real chmod $CHOPTS "$mode" "$path"
|
||||
[ -x /sbin/restorecon ] && dryrun_or_real restorecon $CHOPTS "$path"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_restorecon() {
|
||||
local path=$1
|
||||
if [ -x /sbin/restorecon ]; then
|
||||
dryrun_or_real restorecon -F "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
_b() {
|
||||
# Create a block device node if it doesn't exist yet
|
||||
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
||||
if [ ! -e "$path" ]; then
|
||||
dryrun_or_real mknod -m $mode $path b ${arg%:*} ${arg#*:}
|
||||
_restorecon "$path"
|
||||
dryrun_or_real chown $uid:$gid $path
|
||||
fi
|
||||
}
|
||||
@@ -65,10 +75,22 @@ _c() {
|
||||
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
||||
if [ ! -e "$path" ]; then
|
||||
dryrun_or_real mknod -m $mode $path c ${arg%:*} ${arg#*:}
|
||||
_restorecon "$path"
|
||||
dryrun_or_real chown $uid:$gid $path
|
||||
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() {
|
||||
# Create a file if it doesn't exist yet
|
||||
@@ -77,7 +99,7 @@ _f() {
|
||||
[ $CREATE -gt 0 ] || return 0
|
||||
|
||||
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 "$@"
|
||||
fi
|
||||
}
|
||||
@@ -88,7 +110,7 @@ _F() {
|
||||
|
||||
[ $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 "$@"
|
||||
}
|
||||
|
||||
@@ -99,7 +121,8 @@ _d() {
|
||||
[ $CREATE -gt 0 ] || return 0
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -109,10 +132,12 @@ _D() {
|
||||
|
||||
if [ -d "$path" ] && [ $REMOVE -gt 0 ]; then
|
||||
dryrun_or_real find "$path" -mindepth 1 -maxdepth 1 -xdev -exec rm -rf {} +
|
||||
_restorecon "$path"
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -120,6 +145,7 @@ _L() {
|
||||
# Create a symlink if it doesn't exist yet
|
||||
local path=$1 mode=$2 uid=$3 gid=$4 age=$5 arg=$6
|
||||
[ ! -e "$path" ] && dryrun_or_real ln -s "$arg" "$path"
|
||||
_restorecon "$path"
|
||||
}
|
||||
|
||||
_p() {
|
||||
@@ -129,8 +155,7 @@ _p() {
|
||||
[ $CREATE -gt 0 ] || return 0
|
||||
|
||||
if [ ! -p "$path" ]; then
|
||||
dryrun_or_real mkfifo -m$mode "$path"
|
||||
dryrun_or_real chown "$uid:$gid" "$path"
|
||||
dryrun_or_real $CHECKPATH -pq -m $mode -o "$uid:$gid" "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -214,7 +239,7 @@ _Z() {
|
||||
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=
|
||||
PREFIX=
|
||||
FILE=
|
||||
@@ -230,11 +255,13 @@ tmpfiles_d=''
|
||||
# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
|
||||
for d in ${tmpfiles_dirs} ; 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##*/}"
|
||||
done # for f in ${d}
|
||||
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
|
||||
real_f=''
|
||||
@@ -247,6 +274,7 @@ done
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--boot) BOOT=1 ;;
|
||||
--create) CREATE=1 ;;
|
||||
--remove) REMOVE=1 ;;
|
||||
--clean) CLEAN=1 ;; # TODO: Not implemented
|
||||
@@ -264,7 +292,7 @@ if [ $(( CLEAN )) -eq 1 ] ; then
|
||||
fi
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
@@ -281,21 +309,34 @@ for FILE in $tmpfiles_d ; do
|
||||
# Cmd Path Mode UID GID Age Argument
|
||||
# d /run/user 0755 root root 10d -
|
||||
# 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.
|
||||
# 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
|
||||
LINENUM=$(( LINENUM+1 ))
|
||||
FORCE=0
|
||||
|
||||
# Unless we have both command and path, skip this line.
|
||||
if [ -z "$cmd" -o -z "$path" ]; then
|
||||
continue
|
||||
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
|
||||
case $cmd in
|
||||
f|F|w|d|D|p|L|c|b|x|X|r|R|z|Z) ;;
|
||||
\#) continue ;;
|
||||
f|F|w|d|D|p|L|c|C|b|x|X|r|R|z|Z) ;;
|
||||
*) warninvalid ; continue ;;
|
||||
esac
|
||||
|
||||
@@ -304,7 +345,7 @@ for FILE in $tmpfiles_d ; do
|
||||
case "$cmd" in
|
||||
p|f|F) mode=0644 ;;
|
||||
d|D) mode=0755 ;;
|
||||
z|Z|x|r|R|L) ;;
|
||||
C|z|Z|x|r|R|L) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -316,6 +357,13 @@ for FILE in $tmpfiles_d ; do
|
||||
|
||||
[ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && 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 "$@"
|
||||
_$cmd "$@"
|
||||
rc=$?
|
||||
|
||||
Reference in New Issue
Block a user