aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'rc.d/init.d')
-rwxr-xr-xrc.d/init.d/functions128
-rwxr-xr-xrc.d/init.d/halt21
-rwxr-xr-xrc.d/init.d/netfs30
-rwxr-xr-xrc.d/init.d/network30
-rwxr-xr-xrc.d/init.d/random6
-rwxr-xr-xrc.d/init.d/rawdevices24
-rwxr-xr-xrc.d/init.d/single11
7 files changed, 157 insertions, 93 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index ac112eb3..03ec4ce5 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -8,6 +8,11 @@
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Hacked by: Greg Galloway and Marc Ewing
#
+#
+# i18n originally by: Arnaldo Carvalho de Melo <acme@conectiva.com.br>,
+# Wanderlei Antonio Cavassin
+TEXTDOMAIN=initscripts
+TEXTDOMAINDIR=/etc/locale
# First set up a default search path.
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
@@ -49,6 +54,49 @@ else
INITLOG_ARGS=
fi
+if [ -z "$GP_LANG" -a -f /etc/sysconfig/i18n ]; then
+ GP_LANG=$(sed -n 's/"//g ; s/^LANG=//p' /etc/sysconfig/i18n )
+fi
+
+gprintf() {
+ if [ -x /usr/bin/gettext ]; then
+ local TEXT=`LC_MESSAGES=$GP_LANG gettext -e --domain=$TEXTDOMAIN "$1"`
+ else
+ local TEXT=$1
+ fi
+ [ "${1#*\\n}" ] || TEXT="$TEXT\n"
+ shift
+ printf "$TEXT" "$@"
+}
+
+# Frontend to gprintf (support up to 4 %s in format string)
+# returns the message transleted in GPRINTF_MSG and
+# the resting parms in GPRINTF_REST
+# This simplifies a lot the call of functions like action,
+# now with i18n support
+gprintf_msg_rest() {
+case "$1" in
+ *%s*%s*%s*%s*)
+ GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4" "$5")
+ shift 5;;
+ *%s*%s*%s*)
+ GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4")
+ shift 4;;
+ *%s*%s*)
+ GPRINTF_MSG=$(gprintf "$1" "$2" "$3")
+ shift 3;;
+ *%s*)
+ GPRINTF_MSG=$(gprintf "$1" "$2")
+ shift 2;;
+ *)
+ GPRINTF_MSG=$(gprintf "$1")
+ shift;;
+esac
+GPRINTF_REST="$@"
+}
+
+
+
# Check if $pid (could be plural) are running
checkpid() {
while [ "$1" ]; do
@@ -67,7 +115,7 @@ daemon() {
nicelevel=0
while [ "$1" != "${1##-}" -o "$1" != "${1##+}" ]; do
case $1 in
- '') echo '$0: Usage: daemon [+/-nicelevel] {program}'
+ '') gprintf "$0: Usage: daemon [+/-nicelevel] {program}\n" $0
return 1;;
--check)
shift
@@ -121,7 +169,7 @@ killproc() {
RC=0
# Test syntax.
if [ $# = 0 ]; then
- echo "Usage: killproc {program} [signal]"
+ gprintf "Usage: killproc {program} [signal]\n"
return 1
fi
@@ -219,14 +267,14 @@ status() {
# Test syntax.
if [ $# = 0 ] ; then
- echo "Usage: status {program}"
+ gprintf "Usage: status {program}\n"
return 1
fi
# First try "pidof"
pid=`pidof -o $$ -o $PPID -o %PPID -x ${base}`
if [ "$pid" != "" ] ; then
- echo "${base} (pid $pid) is running..."
+ gprintf "%s (pid %s) is running...\n" "${base}" "$pid"
return 0
fi
@@ -234,16 +282,16 @@ status() {
if [ -f /var/run/${base}.pid ] ; then
pid=`cat /var/run/${base}.pid | { read foo ; echo $foo ; }`
if [ "$pid" != "" ] ; then
- echo "${base} dead but pid file exists"
+ gprintf "%s dead but pid file exists\n" "${base}"
return 1
fi
fi
# See if /var/lock/subsys/${base} exists
if [ -f /var/lock/subsys/${base} ]; then
- echo "${base} dead but subsys locked"
+ gprintf "%s dead but subsys locked\n" "${base}"
return 2
fi
- echo "${base} is stopped"
+ gprintf "%s is stopped\n" "${base}"
return 3
}
@@ -251,7 +299,7 @@ echo_success() {
[ "$BOOTUP" = "color" ] && $MOVE_TO_COL
echo -n "[ "
[ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
- echo -n "OK"
+ gprintf "OK"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n " ]"
echo -ne "\r"
@@ -262,7 +310,7 @@ echo_failure() {
[ "$BOOTUP" = "color" ] && $MOVE_TO_COL
echo -n "["
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
- echo -n "FAILED"
+ gprintf "FAILED"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n "]"
echo -ne "\r"
@@ -273,7 +321,7 @@ echo_passed() {
[ "$BOOTUP" = "color" ] && $MOVE_TO_COL
echo -n "["
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
- echo -n "PASSED"
+ gprintf "PASSED"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n "]"
echo -ne "\r"
@@ -282,11 +330,13 @@ echo_passed() {
# Log that something succeeded
success() {
+ gprintf_msg_rest "$@"
if [ -z "$IN_INITLOG" ]; then
- initlog $INITLOG_ARGS -n $0 -s "$1" -e 1
+ initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 1
else
# silly hack to avoid EPIPE killing rc.sysinit
trap "" SIGPIPE
+# FIXME?
echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21
trap - SIGPIPE
fi
@@ -297,11 +347,12 @@ success() {
# Log that something failed
failure() {
rc=$?
+ gprintf_msg_rest "$@"
if [ -z "$IN_INITLOG" ]; then
- initlog $INITLOG_ARGS -n $0 -s "$1" -e 2
+ initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 2
else
trap "" SIGPIPE
- echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 2" >&21
+ echo "-n $0 -s \"$GPRINTF_MSG\" -e 1" >&21
trap - SIGPIPE
fi
[ "$BOOTUP" != "verbose" ] && echo_failure
@@ -311,10 +362,12 @@ failure() {
# Log that something passed, but may have had errors. Useful for fsck
passed() {
rc=$?
+ gprintf_msg_rest "$@"
if [ -z "$IN_INITLOG" ]; then
- initlog $INITLOG_ARGS -n $0 -s "$1" -e 1
+ initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 1
else
trap "" SIGPIPE
+#FIXME?
echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21
trap - SIGPIPE
fi
@@ -324,32 +377,39 @@ passed() {
# Run some action. Log its output.
action() {
- STRING=$1
- echo -n "$STRING "
- shift
- initlog $INITLOG_ARGS -c "$*" && success "$STRING" || failure "$STRING"
+ gprintf_msg_rest "$@"
+ echo -n "$GPRINTF_MSG "
+ initlog $INITLOG_ARGS -c "$GPRINTF_REST" && success "$GPRINTF_MSG" || failure "$GPRINTF_MSG"
rc=$?
echo
return $rc
}
+# returns OK if $1 contains $2
+strstr() {
+ [ "$1" = "$2" ] && return 0
+ slice=${1#*$2*}
+ [ "$slice" = "$1" ] && return 1
+ return 0
+}
+
+
# Confirm whether we really want to run this service
confirm() {
- echo -n "Start service $1 (Y)es/(N)o/(C)ontinue? [Y] "
+ gprintf "Start service %s (Y)es/(N)o/(C)ontinue? [Y] " $1
+ local YES=`gprintf "yY"`
+ local NOT=`gprintf "nN"`
+ local CNT=`gprintf "cC"`
+
read answer
- case $answer in
- y|Y|"")
- return 0
- ;;
- c|C)
- return 2
- ;;
- n|N)
- return 1
- ;;
- *)
- confirm $1
- return $?
- ;;
- esac
+
+ if strstr "$YES" "$answer" || [ "$answer" = "" ] ; then
+ return 0
+ elif strstr "$CNT" "$answer" ; then
+ return 2
+ elif strstr "$NOT" "$answer" ; then
+ return 1
+ fi
+ confirm $*
+
}
diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt
index 362a4c5f..095b0e74 100755
--- a/rc.d/init.d/halt
+++ b/rc.d/init.d/halt
@@ -14,12 +14,13 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin
. /etc/init.d/functions
runcmd() {
- echo -n "$1 "
+ gprintf_msg_rest "$@"
+ echo -n "$GPRINTF_MSG "
shift
if [ "$BOOTUP" = "color" ]; then
- $* && echo_success || echo_failure
+ $GPRINTF_REST && echo_success || echo_failure
else
- $*
+ $GPRINTF_REST
fi
echo
}
@@ -27,15 +28,15 @@ runcmd() {
# See how we were called.
case "$0" in
*halt)
- message="The system is halted"
+ message=`gprintf "The system is halted"`
command="halt"
;;
*reboot)
- message="Please stand by while rebooting the system..."
+ message=`gprintf "Please stand by while rebooting the system..."`
command="reboot"
;;
*)
- echo "$0: call me as \"rc.halt\" or \"rc.reboot\" please!"
+ gprintf "%s: call me as 'halt' or 'reboot' please!" $0
exit 1
;;
esac
@@ -43,9 +44,9 @@ esac
# Kill all processes.
[ "${BASH+bash}" = bash ] && enable kill
-runcmd "Sending all processes the TERM signal..." /sbin/killall5 -15
+runcmd "Sending all processes the %s signal..." "TERM" /sbin/killall5 -15
sleep 5
-runcmd "Sending all processes the KILL signal..." /sbin/killall5 -9
+runcmd "Sending all processes the %s signal.." "KILL" /sbin/killall5 -9
# Write to wtmp file before unmounting /var
halt -w
@@ -100,9 +101,9 @@ runcmd "Unmounting proc file system: " umount /proc
# Now halt or reboot.
echo "$message"
if [ -f /fastboot ]; then
- echo "On the next boot fsck will be skipped."
+ gprintf "On the next boot fsck will be skipped.\n"
elif [ -f /forcefsck ]; then
- echo "On the next boot fsck will be forced."
+ gprintf "On the next boot fsck will be forced.\n"
fi
HALTARGS="-i -d"
diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs
index fbb8ce64..3d18afd6 100755
--- a/rc.d/init.d/netfs
+++ b/rc.d/init.d/netfs
@@ -35,10 +35,10 @@ case "$1" in
[ -n "$NFSFSTAB" ] &&
{
[ ! -f /var/lock/subsys/portmap ] && service portmap start
- action "Mounting NFS filesystems: " mount -a -t nfs
+ action "Mounting %s filesystems: " NFS mount -a -t nfs
}
- [ -n "$SMBFSTAB" ] && action "Mounting SMB filesystems: " mount -a -t smbfs
- [ -n "$NCPFSTAB" ] && action "Mounting NCP filesystems: " mount -a -t ncpfs
+ [ -n "$SMBFSTAB" ] && action "Mounting %s filesystems: " SMB mount -a -t smbfs
+ [ -n "$NCPFSTAB" ] && action "Mounting %s filesystems: " NCP mount -a -t ncpfs
touch /var/lock/subsys/netfs
action "Mounting other filesystems: " mount -a -t nonfs,smbfs,ncpfs
;;
@@ -50,9 +50,9 @@ case "$1" in
while [ -n "$remaining" -a "$retry" -gt 0 ]
do
if [ "$retry" -lt 3 ]; then
- action "Unmounting NFS filesystems (retry): " umount -f -a -t nfs
+ action "Unmounting %s filesystems (retry): " NFS umount -f -a -t nfs
else
- action "Unmounting NFS filesystems: " umount -f -a -t nfs
+ action "Unmounting %s filesystems: " NFS umount -f -a -t nfs
fi
sleep 2
remaining=`awk '!/^#/ && $3 ~ /^nfs/ && $2 != "/" {print $2}' /proc/mounts`
@@ -63,38 +63,38 @@ case "$1" in
sig=-9
done
}
- [ -n "$SMBMTAB" ] && action "Unmounting SMB filesystems: " umount -a -t smbfs
- [ -n "$NCPMTAB" ] && action "Unmounting NCP filesystems: " umount -a -t ncpfs
+ [ -n "$SMBMTAB" ] && action "Unmounting %s filesystems: " SMB umount -a -t smbfs
+ [ -n "$NCPMTAB" ] && action "Unmounting %s filesystems: " NCP umount -a -t ncpfs
rm -f /var/lock/subsys/netfs
;;
status)
if [ -f /proc/mounts ] ; then
[ -n "$NFSFSTAB" ] && {
- echo "Configured NFS mountpoints: "
+ gprintf "Configured %s mountpoints:\n" NFS
for fs in $NFSFSTAB; do echo $fs ; done
}
[ -n "$SMBFSTAB" ] && {
- echo "Configured SMB mountpoints: "
+ gprintf "Configured %s mountpoints:\n" SMB
for fs in $SMBFSTAB; do echo $fs ; done
}
[ -n "$NCPFSTAB" ] && {
- echo "Configured NCP mountpoints: "
+ gprintf "Configured %s mountpoints:\n" NCP
for fs in $NCPFSTAB; do echo $fs ; done
}
[ -n "$NFSMTAB" ] && {
- echo "Active NFS mountpoints: "
+ gprintf "Active %s mountpoints:\n" NFS
for fs in $NFSMTAB; do echo $fs ; done
}
[ -n "$SMBMTAB" ] && {
- echo "Active SMB mountpoints: "
+ gprintf "Active %s mountpoints:\n" SMB
for fs in $SMBMTAB; do echo $fs ; done
}
[ -n "$NCPMTAB" ] && {
- echo "Active NCP mountpoints: "
+ gprintf "Active %s mountpoints:\n" NCP
for fs in $NCPMTAB; do echo $fs ; done
}
else
- echo "/proc filesystem unavailable"
+ gprintf "/proc filesystem unavailable\n"
fi
;;
restart)
@@ -105,7 +105,7 @@ case "$1" in
$0 start
;;
*)
- echo "Usage: netfs {start|stop|restart|reload|status}"
+ gprintf "Usage: %s {start|stop|restart|reload|status}\n" netfs
exit 1
esac
diff --git a/rc.d/init.d/network b/rc.d/init.d/network
index 6e348d52..46f84493 100755
--- a/rc.d/init.d/network
+++ b/rc.d/init.d/network
@@ -45,7 +45,7 @@ case "$1" in
action "Setting network parameters: " sysctl -p /etc/sysctl.conf
- action "Bringing up interface lo: " ./ifup ifcfg-lo
+ action "Bringing up interface %s: " lo ./ifup ifcfg-lo
case "$IPX" in
yes|true)
@@ -94,7 +94,7 @@ case "$1" in
for i in $interfaces ; do
if LC_ALL= LANG= ifconfig $i 2>/dev/null | grep -q " UP " >/dev/null 2>&1 ; then
- action "Shutting down interface $i: " ./ifdown $i boot
+ action "Shutting down interface %s: " $i ./ifdown $i boot
fi
done
case "$IPX" in
@@ -121,18 +121,18 @@ case "$1" in
rm -f /var/lock/subsys/network
;;
status)
- echo "Configured devices:"
+ gprintf "Configured devices:\n"
echo lo $interfaces
if [ -x /sbin/linuxconf ] ; then
eval `/sbin/linuxconf --hint netdev`
- echo "Devices that are down:"
+ gprintf "Devices that are down:\n"
echo $DEV_UP
- echo "Devices with modified configuration:"
+ gprintf "Devices with modified configuration:\n"
echo $DEV_RECONF
else
- echo "Currently active devices:"
- echo `/sbin/ifconfig | grep ^[a-z] | awk '{print $1}'`
+ gprintf "Currently active devices:\n"
+ echo `LC_ALL= LANG= /sbin/ifconfig | grep ^[a-z] | awk '{print $1}'`
fi
;;
restart)
@@ -144,26 +144,26 @@ case "$1" in
if [ -x /sbin/linuxconf ] ; then
eval `/sbin/linuxconf --hint netdev`
for device in $DEV_UP ; do
- action "Bringing up device $device: " ./ifup $device
+ action "Bringing up device %s: " $device ./ifup $device
done
for device in $DEV_DOWN ; do
- action "Shutting down device $device: " ./ifdown $device
+ action "Shutting down device %s: " $device ./ifdown $device
done
for device in $DEV_RECONF ; do
- action "Shutting down device $device: " ./ifdown $device
- action "Bringing up device $device: " ./ifup $device
+ action "Shutting down device %s: " $device ./ifdown $device
+ action "Bringing up device %s: " $device ./ifup $device
done
for device in $DEV_RECONF_ALIASES ; do
- action "Briging up alias $device: " /etc/sysconfig/network-scripts/ifup-aliases $device
+ action "Briging up alias %s: " $device /etc/sysconfig/network-scripts/ifup-aliases $device
done
for device in $DEV_RECONF_ROUTES ; do
- action "Bringing up route $device: " /etc/sysconfig/network-scripts/ifup-routes $device
+ action "Bringing up route %s: " $device /etc/sysconfig/network-scripts/ifup-routes $device
done
case $IPX in yes|true)
case $IPXINTERNALNET in
reconf)
action "Deleting internal IPX network: " /sbin/ipx_internal_net del
- action "Adding internal IPX network $IPXINTERNALNETNUM $IPXINTERNALNODENUM: " /sbin/ipx_internal_net add $IPXINTERNALNETNUM \
+ action "Adding internal IPX network %s %s: " $IPXINTERNALNETNUM $IPXINTERNALNODENUM /sbin/ipx_internal_net add $IPXINTERNALNETNUM \
$IPXINTERNALNODENUM
;;
add)
@@ -197,7 +197,7 @@ case "$1" in
fi
;;
*)
- echo "Usage: network {start|stop|restart|reload|status|probe}"
+ gprintf "Usage: %s {start|stop|restart|reload|status|probe}\n" "network"
exit 1
esac
diff --git a/rc.d/init.d/random b/rc.d/init.d/random
index 81c7a780..2eb95f66 100755
--- a/rc.d/init.d/random
+++ b/rc.d/init.d/random
@@ -41,9 +41,9 @@ case "$1" in
status)
# this is way overkill, but at least we have some status output...
if [ -c /dev/random ] ; then
- echo "The random data source exists"
+ gprintf "The random data source exists\n"
else
- echo "The random data source is missing"
+ gprintf "The random data source is missing\n"
fi
;;
restart|reload)
@@ -53,7 +53,7 @@ case "$1" in
*)
# do not advertise unreasonable commands that there is no reason
# to use with this device
- echo "Usage: random {start|stop|status|restart|reload}"
+ gprintf "Usage: %s {start|stop|status|restart|reload}\n" "random"
exit 1
esac
diff --git a/rc.d/init.d/rawdevices b/rc.d/init.d/rawdevices
index 2d883ef0..cb4152a2 100755
--- a/rc.d/init.d/rawdevices
+++ b/rc.d/init.d/rawdevices
@@ -13,6 +13,8 @@
# Source function library.
. /etc/init.d/functions
+TEXTDOMAIN=initscripts
+
[ -f /usr/bin/raw ] || exit 0
[ -f /etc/sysconfig/rawdevices ] || exit 0
@@ -26,17 +28,17 @@ function assign_raw()
cat /etc/sysconfig/rawdevices | egrep -v '^ *#' | while read RAW BLOCK; do
if [ -n "$RAW" -a -n "$BLOCK" ]; then
if [ "`dirname $RAW`" = "/dev" -a -d /dev/raw ]; then
- echo " Please correct your /etc/sysconfig/rawdevices:"
- echo " rawdevices are now located in the directory /dev/raw/ "
- echo " If the command 'raw' still refers to /dev/raw as a file."
- echo " you'll have to upgrade your util-linux package"
+ gprintf " Please correct your /etc/sysconfig/rawdevices:\n"
+ gprintf " rawdevices are now located in the directory /dev/raw/\n"
+ gprintf " If the command 'raw' still refers to /dev/raw as a file.\n"
+ gprintf " you'll have to upgrade your util-linux package\n"
exit 0
fi
if [ "`dirname $RAW`" = "/dev/raw" -a -f /dev/raw ]; then
- echo " Please correct your /etc/sysconfig/rawdevices:"
- echo " rawdevices are now located in the directory /dev/raw/ "
- echo " If the command 'raw' still refers to /dev/raw as a file."
- echo " you'll have to upgrade your util-linux package"
+ gprintf " Please correct your /etc/sysconfig/rawdevices:\n"
+ gprintf " rawdevices are now located in the directory /dev/raw/\n"
+ gprintf " If the command 'raw' still refers to /dev/raw as a file.\n"
+ gprintf " you'll have to upgrade your util-linux package\n"
exit 0
fi
@@ -50,7 +52,7 @@ function assign_raw()
case "$1" in
start)
# Assign devices
- echo "Assigning devices: "
+ gprintf "Assigning devices: "
assign_raw
echo "done"
;;
@@ -63,7 +65,7 @@ case "$1" in
if [ $ID -eq 0 ]; then
raw -qa
else
- echo "You need to be root to use this command ! "
+ gprintf "You need to be root to use this command!\n"
fi
;;
@@ -72,7 +74,7 @@ case "$1" in
;;
*)
- echo "Usage: rawdevice {start|stop|status|restart}"
+ gprintf "Usage: rawdevice {start|stop|status|restart}\n"
exit 1
esac
diff --git a/rc.d/init.d/single b/rc.d/init.d/single
index 6806d0c3..92de156e 100755
--- a/rc.d/init.d/single
+++ b/rc.d/init.d/single
@@ -10,10 +10,11 @@
# Modified for RHS Linux by Damien Neil
#
-. /etc/init.d/functions
-
# Set the path.
PATH=/sbin:/bin:/usr/sbin:/usr/bin
+TEXTDOMAIN=initscripts
+
+. /etc/rc.d/init.d/functions
if [ "$1" != "start" ] ; then
exit 0
@@ -22,10 +23,10 @@ fi
# Kill all processes.
[ "${BASH+bash}" = bash ] && enable kill
-echo "Sending all processes the TERM signal..."
+gprintf "Sending all processes the %s signal...\n" "TERM"
kill -15 -1
sleep 5
-echo "Sending all processes the KILL signal.."
+gprintf "Sending all processes the %s signal..\n" "KILL"
kill -9 -1
rm -f /var/lock/subsys/*
@@ -52,5 +53,5 @@ for i in /etc/rc1.d/S[0-9][0-9]*; do
done
# Now go to the single user level.
-echo "Telling INIT to go to single user mode."
+gprintf "Telling INIT to go to single user mode.\n"
exec init -t1 S