Browse Source

Clifford Wolf:


			
			
				rocklinux
			
			
		
Clifford Wolf 20 years ago
parent
commit
ad199ea4c4
2 changed files with 32 additions and 10 deletions
  1. +21
    -3
      package/base/sysfiles/network.init
  2. +11
    -7
      package/base/sysfiles/rc.c

+ 21
- 3
package/base/sysfiles/network.init

@ -29,9 +29,22 @@
main_begin
block_begin(start, `Setting up network devices.')
[ -x /etc/network/getprofile ] && /etc/network/getprofile
profile="$(cat /etc/network/profile 2>/dev/null)"
profile=${profile:-default}
oldprof="$(cat /etc/network/profile 2>/dev/null)"
oldprof=${oldprof:-default}
if [ -n "$2" ]; then
echo $2 > /etc/network/profile
profile="$(cat /etc/network/profile 2>/dev/null)"
profile=${profile:-default}
echo "Active network profile is now $profile (was: $oldprof)."
elif [ -x /etc/network/getprofile ]; then
echo "Running network profile autodetection ..."
/etc/network/getprofile
profile="$(cat /etc/network/profile 2>/dev/null)"
profile=${profile:-default}
echo "Active network profile is now $profile (was: $oldprof)."
else
profile="$oldprof"
fi
check(`/etc/network/rocknet $profile auto up')
block_end
@ -41,5 +54,10 @@ main_begin
check(`/etc/network/rocknet $profile auto down')
block_end
block_begin(restart, `Reconfiguring network devices.')
check(`$0 stop')
check(`$0 start $2')
block_end
main_end

+ 11
- 7
package/base/sysfiles/rc.c

@ -76,7 +76,7 @@ int main(int argc, char ** argv) {
char command[1024];
int use_btee = 1;
int btee_pipe[2];
int i;
int i, cmd_space;
/* Copy some environment variables to the new environment if set */
if ( getenv("PREVLEVEL") )
@ -93,13 +93,13 @@ int main(int argc, char ** argv) {
}
/* Display help message */
if ( argc != 3 ) {
if ( argc < 3 ) {
fprintf(stderr,
"\n"
" Run SystemV Init-Scripts with a clean environment and detached from\n"
" the terminal.\n"
"\n"
" Usage: rc [ --nobtee ] <service> { start | stop | ... | help }\n"
" Usage: rc [ --nobtee ] <service> { start | stop | ... | help } [ args ]\n"
"\n"
" <service> might be one of:\n"
"\n");
@ -178,10 +178,14 @@ int main(int argc, char ** argv) {
/* Run the command in a (non-interactive) login shell (i.e. read
* /etc/profile) and send \004 after running the script if we are
* using btee. */
snprintf(command, 1024, "%s%s %s </dev/null 2>&1%s",
strchr(argv[1], '/') ? "" : "/etc/rc.d/init.d/",
argv[1], argv[2], use_btee ? "; echo -ne '\004'" : "");
execle("/bin/bash", "-bash", "-l", "-c", command, NULL, clean_env);
cmd_space = snprintf(command, 1024, "%s%s",
strchr(argv[1], '/') ? "" : "/etc/rc.d/init.d/", argv[1]);
for (i=2; i<argc; i++)
cmd_space += snprintf(command+cmd_space, 1024-cmd_space, " %s", argv[i]);
cmd_space += snprintf(command+cmd_space, 1024-cmd_space, " </dev/null 2>&1%s",
use_btee ? "; echo -ne '\004'" : "");
if ( cmd_space < 1000 )
execle("/bin/bash", "-bash", "-l", "-c", command, NULL, clean_env);
/* Oups! Can't exec the shell. */
if ( use_btee ) write(1, "\004", 1);

Loading…
Cancel
Save