mirror of
https://github.com/troglobit/finit.git
synced 2026-11-07 16:01:08 +00:00
Add a run-parts implementation, not sure if really needed
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
e4f675fa1a
commit
6c807c3a95
4 files changed
+76
-3
No files matched your search
@@ -73,5 +73,5 @@ problems related to udev and pam.
|
|||||||
|
|
||||||
4 - Set the pointer device in the X server configuration to /dev/input/mice
|
4 - Set the pointer device in the X server configuration to /dev/input/mice
|
||||||
|
|
||||||
5 - Have a user named "user", or change DEFUSER in the source file
|
5 - Have a user named "user", or change the default in Makefile
|
||||||
|
|
||||||
+2
-2
@@ -58,7 +58,7 @@ THE SOFTWARE.
|
|||||||
#define RANDOMSEED "/var/lib/random-seed"
|
#define RANDOMSEED "/var/lib/random-seed"
|
||||||
#define SYSROOT "/sysroot"
|
#define SYSROOT "/sysroot"
|
||||||
#define GETTY "/sbin/mingetty tty3"
|
#define GETTY "/sbin/mingetty tty3"
|
||||||
#define RUNPARTS "/usr/bin/run-parts --arg=-i"
|
#define RUNPARTS "/usr/bin/run-parts"
|
||||||
#define REMOUNT_ROOTFS_RW
|
#define REMOUNT_ROOTFS_RW
|
||||||
#define MAKE_DEVICES
|
#define MAKE_DEVICES
|
||||||
#else /* original Eeepc distribution */
|
#else /* original Eeepc distribution */
|
||||||
@@ -230,7 +230,7 @@ int main()
|
|||||||
touch("/etc/resolvconf/run/enable-updates");
|
touch("/etc/resolvconf/run/enable-updates");
|
||||||
|
|
||||||
chdir("/etc/resolvconf/run/interface");
|
chdir("/etc/resolvconf/run/interface");
|
||||||
system(RUNPARTS " /etc/resolvconf/update.d");
|
system(RUNPARTS " --arg=i /etc/resolvconf/update.d");
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
#ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE
|
#ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -9,6 +10,8 @@
|
|||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
@@ -90,3 +93,72 @@ void copyfile(char *src, char *dst, int size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
/* Running the system /bin/run-parts is good enough, enable this if you
|
||||||
|
can't use it. Some distributions have it under /usr/bin, in this case
|
||||||
|
you can assume that the distribution is broken or run-parts is not used
|
||||||
|
in the boot process.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NUM_SCRIPTS 128 /* ought to be enough for anyone */
|
||||||
|
#define NUM_ARGS 16
|
||||||
|
|
||||||
|
static int cmp(const void *s1, const void *s2)
|
||||||
|
{
|
||||||
|
return strcmp(*(char **)s1, *(char **)s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_parts(char *dir, ...)
|
||||||
|
{
|
||||||
|
DIR *d;
|
||||||
|
struct dirent *e;
|
||||||
|
struct stat st;
|
||||||
|
char *ent[NUM_SCRIPTS];
|
||||||
|
int i, num = 0, argnum = 1;
|
||||||
|
char *args[NUM_ARGS];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if ((d = opendir(dir)) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (chdir(dir))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
va_start(ap, dir);
|
||||||
|
while (argnum < NUM_ARGS && (args[argnum++] = va_arg(ap, char *)));
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
e = readdir(d);
|
||||||
|
if (e) {
|
||||||
|
if (e->d_type == DT_REG) {
|
||||||
|
if (stat(e->d_name, &st))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (st.st_mode & S_IXUSR) {
|
||||||
|
ent[num++] = strdup(e->d_name);
|
||||||
|
if (num >= NUM_SCRIPTS)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
qsort(ent, num, sizeof(char *), cmp);
|
||||||
|
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
|
args[0] = ent[i];
|
||||||
|
execv(ent[i], args);
|
||||||
|
free(ent[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in new issue
Block a user