mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-02-19 16:15:39 +08:00
update initscripts for larch8
This commit is contained in:
parent
1cba74a4e7
commit
c9068c6582
@ -10,7 +10,7 @@ source ../_buildscripts/${current_repo}-${_arch}-cfg.conf
|
||||
_origname=initscripts
|
||||
pkgname=chakra-initscripts
|
||||
pkgver=2010.07
|
||||
pkgrel=2
|
||||
pkgrel=3
|
||||
pkgdesc="System initialization/bootup scripts"
|
||||
arch=(i686 x86_64)
|
||||
url="http://www.chakra-project.org"
|
||||
|
137
chakra-initscripts/etc/rc.d/functions
Executable file → Normal file
137
chakra-initscripts/etc/rc.d/functions
Executable file → Normal file
@ -4,17 +4,29 @@
|
||||
|
||||
# width:
|
||||
|
||||
STAT_COL=$(/bin/stty size)
|
||||
# strip the rows number, we just want columns
|
||||
STAT_COL=${STAT_COL##* }
|
||||
if [ "$STAT_COL" = "0" ]; then
|
||||
# if output was 0 (serial console), set default width to 80
|
||||
STAT_COL=80
|
||||
elif [ ! -t 1 ]; then
|
||||
# disable color on output to non-tty
|
||||
STAT_COL=80
|
||||
USECOLOR=""
|
||||
STAT_COL=80
|
||||
if [ ! -t 1 ]; then
|
||||
USECOLOR=""
|
||||
|
||||
# stty will fail when stdin isn't a terminal
|
||||
elif [ -t 0 ]; then
|
||||
STAT_COL="$(/bin/stty size)"
|
||||
# stty gives "rows cols"; strip the rows number, we just want columns
|
||||
STAT_COL="${STAT_COL##* }"
|
||||
|
||||
else
|
||||
# is /usr/share/terminfo already mounted, and TERM recognized?
|
||||
/bin/tput cols &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
STAT_COL=$(/bin/tput cols)
|
||||
fi
|
||||
fi
|
||||
if [ "0$STAT_COL" -eq 0 ]; then
|
||||
# if output was 0 (serial console), set default width to 80
|
||||
STAT_COL=80
|
||||
USECOLOR=""
|
||||
fi
|
||||
|
||||
# we use 13 characters for our own stuff
|
||||
STAT_COL=$(($STAT_COL - 13))
|
||||
|
||||
@ -62,12 +74,16 @@ if [ -t 1 ]; then
|
||||
SAVE_POSITION="\033[s"
|
||||
RESTORE_POSITION="\033[u"
|
||||
DEL_TEXT="\033[$(($STAT_COL+4))G"
|
||||
else
|
||||
SAVE_POSITION=""
|
||||
RESTORE_POSITION=""
|
||||
DEL_TEXT=""
|
||||
fi
|
||||
|
||||
# prefixes:
|
||||
|
||||
PREFIX_REG="::"
|
||||
PREFIX_HL=" *"
|
||||
PREFIX_HL=" >"
|
||||
|
||||
# functions:
|
||||
|
||||
@ -76,7 +92,7 @@ deltext() {
|
||||
}
|
||||
|
||||
printhl() {
|
||||
printf "${C_OTHER}${PREFIX_HL} ${C_H1}${1}${C_CLEAR}\n"
|
||||
printf "${C_OTHER}${PREFIX_HL} ${C_H1}${1}${C_CLEAR} \n"
|
||||
}
|
||||
|
||||
printhl2() {
|
||||
@ -106,7 +122,7 @@ stat_busy() {
|
||||
|
||||
stat_append() {
|
||||
printf "${RESTORE_POSITION}"
|
||||
printf "${C_MAIN}${1}${C_CLEAR}"
|
||||
printf -- "${C_MAIN}${1}${C_CLEAR}"
|
||||
printf "${SAVE_POSITION}"
|
||||
}
|
||||
|
||||
@ -140,6 +156,24 @@ status() {
|
||||
fi
|
||||
}
|
||||
|
||||
# usage : in_array( $needle, $haystack )
|
||||
# return : 0 - found
|
||||
# 1 - not found
|
||||
# Copied from makepkg
|
||||
in_array() {
|
||||
local needle=$1; shift
|
||||
[ -z "$1" ] && return 1 # Not Found
|
||||
local item
|
||||
for item in "$@"; do
|
||||
local c="${item:0:1}"
|
||||
if [ "x$c" = "x@" ]; then
|
||||
item="${item:1}"
|
||||
fi
|
||||
[ "$item" = "$needle" ] && return 0 # Found
|
||||
done
|
||||
return 1 # Not Found
|
||||
}
|
||||
|
||||
# daemons:
|
||||
|
||||
add_daemon() {
|
||||
@ -197,8 +231,83 @@ ck_status() {
|
||||
fi
|
||||
}
|
||||
|
||||
###############################
|
||||
# Custom hooks in initscripts #
|
||||
###############################
|
||||
# Hooks can be used to include custom code in various places in the rc.* scripts
|
||||
#
|
||||
# Define a hook function in a functions.d file using:
|
||||
# function_name() {
|
||||
# ...
|
||||
# }
|
||||
# add_hook hook_name function_name
|
||||
# It is allowed to register several hook functions for the same hook
|
||||
# Is is also allowed to register the same hook function for several hooks
|
||||
#
|
||||
# Currently, the following hooks exist:
|
||||
# sysinit_start: at the beginning of rc.sysinit
|
||||
# multi_start: at the beginning of rc.multi
|
||||
# single_start: at the beginning of rc.single
|
||||
# shutdown_start: at the beginning of rc.shutdown
|
||||
# sysinit_end: at the end of rc.sysinit
|
||||
# multi_end: at the end of rc.multi
|
||||
# single_end: at the end of rc.single
|
||||
# sysinit_udevlaunched: after udev has been launched in rc.sysinit
|
||||
# single_udevlaunched: after udev has been launched in rc.single
|
||||
# sysinit_udevsettled: after uevents have settled in rc.sysinit
|
||||
# single_udevsettled: after uevents have settled in rc.single
|
||||
# sysinit_premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit
|
||||
# shutdown_prekillall: before all processes are being killed in rc.shutdown
|
||||
# single_prekillall: before all processes are being killed in rc.single
|
||||
# shutdown_postkillall: after all processes have been killed in rc.shutdown
|
||||
# single_postkillall: after all processes have been killed in rc.single
|
||||
# shutdown_poweroff: directly before powering off in rc.shutdown
|
||||
#
|
||||
# Make sure to never override the add_hook and run_hook functions via functions.d
|
||||
|
||||
#Source additional functions at the end to allow overrides
|
||||
declare -A hook_funcs
|
||||
|
||||
add_hook() {
|
||||
[ -z "$1" -o -z "$2" ] && return 1
|
||||
hook_funcs["$1"]="${hook_funcs["$1"]} $2"
|
||||
}
|
||||
|
||||
run_hook() {
|
||||
local func
|
||||
|
||||
[ -z "$1" ] && return 1
|
||||
for func in ${hook_funcs["$1"]}; do
|
||||
${func}
|
||||
done
|
||||
}
|
||||
|
||||
# Function for setting console font if required
|
||||
set_consolefont() {
|
||||
if [ -n "$CONSOLEFONT" ]; then
|
||||
stat_busy "Loading Console Font: $CONSOLEFONT"
|
||||
#CONSOLEMAP in UTF-8 shouldn't be used
|
||||
if [ -n "$CONSOLEMAP" ] && echo "$LOCALE" | /bin/grep -qi utf ; then
|
||||
CONSOLEMAP=""
|
||||
fi
|
||||
for i in /dev/tty[0-9]*; do
|
||||
if [ -n "$CONSOLEMAP" ]; then
|
||||
/usr/bin/setfont -m $CONSOLEMAP $CONSOLEFONT -C ${i} >/dev/null 2>&1
|
||||
else
|
||||
/usr/bin/setfont $CONSOLEFONT -C ${i} >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
if [ $? -ne 0 ]; then
|
||||
stat_fail
|
||||
else
|
||||
if [ -n "$CONSOLEMAP" ]; then
|
||||
echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\033(K"; fi' >>/etc/profile.d/locale.sh
|
||||
fi
|
||||
stat_done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Source additional functions at the end to allow overrides
|
||||
for f in /etc/rc.d/functions.d/*; do
|
||||
if [ -e $f ]; then
|
||||
. $f
|
||||
|
Loading…
Reference in New Issue
Block a user