Move _shell_var shell function to shell_var C applet
This commit is contained in:
parent
e5933843e8
commit
fadee8e656
@ -30,21 +30,6 @@ depend() {
|
|||||||
use isapnp
|
use isapnp
|
||||||
}
|
}
|
||||||
|
|
||||||
_shell_var() {
|
|
||||||
local rem=$1 c= r= var=
|
|
||||||
while [ -n "${rem}" ]; do
|
|
||||||
r=${rem#?}
|
|
||||||
c=${rem%${r}}
|
|
||||||
case "${c}" in
|
|
||||||
[a-zA-Z0-9]);;
|
|
||||||
*) c=_;;
|
|
||||||
esac
|
|
||||||
var=${var}${c}
|
|
||||||
rem=${r}
|
|
||||||
done
|
|
||||||
echo ${var}
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
# Should not fail if kernel do not have module
|
# Should not fail if kernel do not have module
|
||||||
# support compiled in ...
|
# support compiled in ...
|
||||||
@ -59,14 +44,14 @@ start() {
|
|||||||
|
|
||||||
local list= x= args= cnt=0
|
local list= x= args= cnt=0
|
||||||
for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR}; do
|
for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR}; do
|
||||||
eval list=\$modules_$(_shell_var "${x}")
|
eval list=\$modules_$(shell_var "${x}")
|
||||||
[ -n "${list}" ] && break
|
[ -n "${list}" ] && break
|
||||||
done
|
done
|
||||||
[ -z "${list}" ] && list=${modules}
|
[ -z "${list}" ] && list=${modules}
|
||||||
|
|
||||||
for x in ${list}; do
|
for x in ${list}; do
|
||||||
ebegin "Loading module ${x}"
|
ebegin "Loading module ${x}"
|
||||||
eval args=\$module_$(_shell_var "${x}")_args
|
eval args=\$module_$(shell_var "${x}")_args
|
||||||
eval modprobe -q "${x}" "${args}"
|
eval modprobe -q "${x}" "${args}"
|
||||||
eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1))
|
eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1))
|
||||||
done
|
done
|
||||||
|
@ -119,7 +119,7 @@ iwconfig_setup_specific() {
|
|||||||
|
|
||||||
iwconfig_set_mode "${mode}" || return 1
|
iwconfig_set_mode "${mode}" || return 1
|
||||||
|
|
||||||
SSIDVAR=$(_shell_var "${SSID}")
|
SSIDVAR=$(shell_var "${SSID}")
|
||||||
local key=$(iwconfig_get_wep_key)
|
local key=$(iwconfig_get_wep_key)
|
||||||
|
|
||||||
# Now set the key
|
# Now set the key
|
||||||
@ -140,7 +140,7 @@ iwconfig_associate() {
|
|||||||
local mac="$1" channel="$2" caps="$3"
|
local mac="$1" channel="$2" caps="$3"
|
||||||
local mode= w="(WEP Disabled)" key=
|
local mode= w="(WEP Disabled)" key=
|
||||||
|
|
||||||
SSIDVAR=$(_shell_var "${SSID}")
|
SSIDVAR=$(shell_var "${SSID}")
|
||||||
key=$(iwconfig_get_wep_key "${mac}")
|
key=$(iwconfig_get_wep_key "${mac}")
|
||||||
case "${caps}" in
|
case "${caps}" in
|
||||||
[EI]P*)
|
[EI]P*)
|
||||||
|
@ -165,7 +165,7 @@ iwconfig_setup_specific() {
|
|||||||
eerror "adjust the ssid_${IFVAR} setting in /etc/conf.d/net"
|
eerror "adjust the ssid_${IFVAR} setting in /etc/conf.d/net"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
SSIDVAR=$(_shell_var "${SSID}")
|
SSIDVAR=$(shell_var "${SSID}")
|
||||||
local key=$(iwconfig_get_wep_key)
|
local key=$(iwconfig_get_wep_key)
|
||||||
|
|
||||||
iwconfig_set_mode "${mode}"
|
iwconfig_set_mode "${mode}"
|
||||||
@ -246,7 +246,7 @@ iwconfig_associate() {
|
|||||||
iwconfig "${IFACE}" ap any 2>/dev/null
|
iwconfig "${IFACE}" ap any 2>/dev/null
|
||||||
unset SSIDVAR
|
unset SSIDVAR
|
||||||
else
|
else
|
||||||
SSIDVAR=$(_shell_var "${SSID}")
|
SSIDVAR=$(shell_var "${SSID}")
|
||||||
key="$(iwconfig_get_wep_key "${mac}")"
|
key="$(iwconfig_get_wep_key "${mac}")"
|
||||||
if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then
|
if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then
|
||||||
ewarn "WEP key is not set for \"${SSID}\" - not connecting"
|
ewarn "WEP key is not set for \"${SSID}\" - not connecting"
|
||||||
|
21
sh/net.sh
21
sh/net.sh
@ -34,24 +34,9 @@ description="Configures network interfaces."
|
|||||||
# Handy var so we don't have to embed new lines everywhere for array splitting
|
# Handy var so we don't have to embed new lines everywhere for array splitting
|
||||||
__IFS="
|
__IFS="
|
||||||
"
|
"
|
||||||
_shell_var() {
|
|
||||||
local rem=$1 c= r= var=
|
|
||||||
while [ -n "${rem}" ]; do
|
|
||||||
r=${rem#?}
|
|
||||||
c=${rem%${r}}
|
|
||||||
case "${c}" in
|
|
||||||
[a-zA-Z0-9]);;
|
|
||||||
*) c=_;;
|
|
||||||
esac
|
|
||||||
var=${var}${c}
|
|
||||||
rem=${r}
|
|
||||||
done
|
|
||||||
echo ${var}
|
|
||||||
}
|
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
local IFACE=${SVCNAME#*.}
|
local IFACE=${SVCNAME#*.}
|
||||||
local IFVAR=$(_shell_var "${IFACE}")
|
local IFVAR=$(shell_var "${IFACE}")
|
||||||
|
|
||||||
need localmount
|
need localmount
|
||||||
after bootmisc
|
after bootmisc
|
||||||
@ -454,7 +439,7 @@ _load_config() {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
local IFACE=${SVCNAME#*.} oneworked=false module=
|
local IFACE=${SVCNAME#*.} oneworked=false module=
|
||||||
local IFVAR=$(_shell_var "${IFACE}") cmd= our_metric=
|
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
|
||||||
local metric=0
|
local metric=0
|
||||||
|
|
||||||
einfo "Bringing up interface ${IFACE}"
|
einfo "Bringing up interface ${IFACE}"
|
||||||
@ -629,7 +614,7 @@ ${routes}"
|
|||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
local IFACE=${SVCNAME#*.} module=
|
local IFACE=${SVCNAME#*.} module=
|
||||||
local IFVAR=$(_shell_var "${IFACE}") opts=
|
local IFVAR=$(shell_var "${IFACE}") opts=
|
||||||
|
|
||||||
einfo "Bringing down interface ${IFACE}"
|
einfo "Bringing down interface ${IFACE}"
|
||||||
eindent
|
eindent
|
||||||
|
@ -69,7 +69,8 @@ RC_BINLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
|
|||||||
service_inactive service_wasinactive \
|
service_inactive service_wasinactive \
|
||||||
service_coldplugged service_started_daemon \
|
service_coldplugged service_started_daemon \
|
||||||
checkpath fstabinfo mountinfo rc-depend \
|
checkpath fstabinfo mountinfo rc-depend \
|
||||||
service_get_value service_set_value get_options save_options
|
service_get_value service_set_value get_options save_options \
|
||||||
|
shell_var
|
||||||
RC_SBINLINKS = mark_service_starting mark_service_started \
|
RC_SBINLINKS = mark_service_starting mark_service_started \
|
||||||
mark_service_stopping mark_service_stopped \
|
mark_service_stopping mark_service_stopped \
|
||||||
mark_service_inactive mark_service_wasinactive \
|
mark_service_inactive mark_service_wasinactive \
|
||||||
|
25
src/rc.c
25
src/rc.c
@ -457,6 +457,28 @@ static int do_value (int argc, char **argv)
|
|||||||
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_shell_var (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
char *p = argv[i];
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
putchar (' ');
|
||||||
|
|
||||||
|
while (*p) {
|
||||||
|
char c = *p++;
|
||||||
|
if (! isalnum (c))
|
||||||
|
c = '_';
|
||||||
|
putchar (c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
putchar ('\n');
|
||||||
|
|
||||||
|
return (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static char *proc_getent (const char *ent)
|
static char *proc_getent (const char *ent)
|
||||||
{
|
{
|
||||||
@ -903,6 +925,9 @@ int main (int argc, char **argv)
|
|||||||
else if (strcmp (applet, "is_runlevel_stop") == 0)
|
else if (strcmp (applet, "is_runlevel_stop") == 0)
|
||||||
exit (rc_runlevel_stopping () ? 0 : 1);
|
exit (rc_runlevel_stopping () ? 0 : 1);
|
||||||
|
|
||||||
|
if (strcmp (applet, "shell_var") == 0)
|
||||||
|
exit (do_shell_var (argc, argv));
|
||||||
|
|
||||||
if (strcmp (applet, "rc-abort") == 0) {
|
if (strcmp (applet, "rc-abort") == 0) {
|
||||||
char *p = getenv ("RC_PID");
|
char *p = getenv ("RC_PID");
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user