mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50c99762f1 | ||
|
|
067043b298 | ||
|
|
439699ef52 | ||
|
|
f20936dae0 | ||
|
|
d5bea7eeeb | ||
|
|
5da0a460fe | ||
|
|
63033d7dcf | ||
|
|
2857dafaf4 | ||
|
|
8355c37285 | ||
|
|
dc49b523d1 | ||
|
|
bf863673c8 |
@@ -6,6 +6,7 @@ Major Contributors:
|
||||
* Mattias Walström <mattias.walstrom@westermo.se>
|
||||
* Jonas Johansson <jonas.johansson@westermo.se>
|
||||
* Jacques de Laval <jacques@de-laval.se>
|
||||
* Magnus Malm <magnusmalm@gmail.com>
|
||||
|
||||
Original Author(s):
|
||||
* Claudio Matsuoka <cmatsuoka@gmail.com>
|
||||
|
||||
+16
@@ -29,3 +29,19 @@ release: distcheck
|
||||
printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' '; \
|
||||
printf "$$file.sha256\t"; cat ../$$file.sha256 | cut -f1 -d' '; \
|
||||
done
|
||||
|
||||
run:
|
||||
srcdir=@srcdir@/test \
|
||||
top_builddir=@top_builddir@ \
|
||||
TENV_ROOT=$(tenv_root) \
|
||||
@srcdir@/test/setup-root.sh
|
||||
|
||||
mkdir -p $(dir $(tenv_root)/@FINIT_CONF@)
|
||||
echo 'tty [12345] @console linux noclear nologin' > $(tenv_root)/@FINIT_CONF@
|
||||
|
||||
-TENV_ROOT=$(tenv_root) \
|
||||
TESTENV_PATH=@sbindir@:/bin \
|
||||
FINIT_RCSD=@FINIT_RCSD@ \
|
||||
test/tenv/start.sh finit
|
||||
|
||||
run : tenv_root ?= @abs_top_builddir@/run-rootfs
|
||||
|
||||
+6
-3
@@ -89,11 +89,11 @@ AC_ARG_ENABLE(contrib,
|
||||
enable_all_plugins=auto
|
||||
AC_PLUGIN([alsa-utils], [no], [Save and restore ALSA sound settings using alsactl])
|
||||
AC_PLUGIN([dbus], [no], [Setup and start system message bus, D-Bus])
|
||||
AC_PLUGIN([hotplug], [yes], [Setup and start udev or mdev hotplug daemon])
|
||||
AC_PLUGIN([modules-load], [no], [Scans /etc/modules-load.d for modules to load])
|
||||
AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf])
|
||||
AC_PLUGIN([x11-common], [no], [Console setup (for X)])
|
||||
AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW events. Can be replaced with externally built plugin that links with libnl or similar.])
|
||||
AC_PLUGIN([hotplug], [yes], [Setup and start udev or mdev hotplug daemon])
|
||||
|
||||
# Check for extra arguments or packages
|
||||
AC_ARG_WITH(heading,
|
||||
@@ -113,7 +113,7 @@ AC_ARG_WITH(rc-local,
|
||||
[rclocal=$withval], [rclocal=yes])
|
||||
|
||||
AC_ARG_WITH(sysconfig,
|
||||
AS_HELP_STRING([--with-sysconfig=DIR], [System environment, default /etc/default & /etc/conf.d]),
|
||||
AS_HELP_STRING([--with-sysconfig=DIR], [System environment directory, sourced by .conf files, default /etc/default & /etc/conf.d]),
|
||||
[sysconfig=$withval], [sysconfig=default])
|
||||
|
||||
AC_ARG_WITH(hostname,
|
||||
@@ -224,6 +224,9 @@ AC_DEFINE_UNQUOTED(RESCUE_CONF, "$rescue_conf", [Finit rescue mode .conf])
|
||||
AC_EXPAND_DIR(sample_conf, "$libdir/finit/sample.conf")
|
||||
AC_DEFINE_UNQUOTED(SAMPLE_CONF, "$sample_conf", [Finit sameple.conf for initctl create])
|
||||
|
||||
AC_EXPAND_DIR(path_stdpath, "$sbindir:$bindir:/usr/sbin:/usr/bin:/sbin:/bin")
|
||||
AC_DEFINE_UNQUOTED(_PATH_STDPATH, "$path_stdpath", [Default PATH])
|
||||
|
||||
# Generate all files
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -232,7 +235,7 @@ cat <<EOF
|
||||
------------------ Summary ------------------
|
||||
$PACKAGE_NAME version $PACKAGE_VERSION
|
||||
Prefix................: $prefix
|
||||
Exec prefix...........: $eprefix
|
||||
Exec prefix...........: `eval echo $exec_prefix`
|
||||
Sysconfdir............: `eval echo $sysconfdir`
|
||||
Localstatedir.........: `eval echo $localstatedir`
|
||||
Finit config file.....: $conf_path
|
||||
|
||||
+5
-2
@@ -235,8 +235,11 @@ static void pidfile_init(void *arg)
|
||||
*/
|
||||
path = realpath(_PATH_VARRUN, NULL);
|
||||
if (!path) {
|
||||
_pe("Failed ");
|
||||
return;
|
||||
path = realpath("/run", NULL);
|
||||
if (!path) {
|
||||
_e("System does not have %s or /run, aborting.", _PATH_VARRUN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pidfile_add_path(&iw_pidfile, path))
|
||||
|
||||
@@ -716,7 +716,6 @@ static struct conf_change *conf_find(char *file)
|
||||
struct conf_change *node, *tmp;
|
||||
|
||||
TAILQ_FOREACH_SAFE(node, &conf_change_list, link, tmp) {
|
||||
_d("file: %s vs changed file: %s", file, node->name);
|
||||
if (string_compare(node->name, file))
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,6 @@
|
||||
#include <lite/lite.h>
|
||||
#include <uev/uev.h>
|
||||
|
||||
/* just in case */
|
||||
#ifndef _PATH_STDPATH
|
||||
#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_VARRUN
|
||||
#define _PATH_VARRUN "/var/run/"
|
||||
#endif
|
||||
|
||||
+15
-2
@@ -143,10 +143,9 @@ static int do_runlevel(char *arg)
|
||||
struct init_request rq = {
|
||||
.magic = INIT_MAGIC,
|
||||
.cmd = INIT_CMD_RUNLVL,
|
||||
.runlevel = (int)arg[0],
|
||||
};
|
||||
|
||||
if (!rq.runlevel) {
|
||||
if (!arg) {
|
||||
int prevlevel = 0;
|
||||
int runlevel;
|
||||
char prev;
|
||||
@@ -165,6 +164,9 @@ static int do_runlevel(char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set runlevel */
|
||||
rq.runlevel = (int)arg[0];
|
||||
|
||||
return client_send(&rq, sizeof(rq));
|
||||
}
|
||||
|
||||
@@ -195,6 +197,13 @@ static int do_startstop(int cmd, char *arg)
|
||||
.cmd = INIT_CMD_SVC_QUERY
|
||||
};
|
||||
|
||||
if (!arg || !arg[0])
|
||||
errx(1, "missing argument to %s", (cmd == INIT_CMD_START_SVC
|
||||
? "start"
|
||||
: (cmd == INIT_CMD_STOP_SVC
|
||||
? "stop"
|
||||
: "restart")));
|
||||
|
||||
strlcpy(rq.data, arg, sizeof(rq.data));
|
||||
if (client_send(&rq, sizeof(rq))) {
|
||||
fprintf(stderr, "No such job(s) or service(s): %s\n\n", rq.data);
|
||||
@@ -343,6 +352,9 @@ static int do_cond(char *cmd)
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
if (!cmd)
|
||||
goto fallback;
|
||||
|
||||
arg = strpbrk(cmd, " \0");
|
||||
if (arg)
|
||||
*arg++ = 0;
|
||||
@@ -352,6 +364,7 @@ static int do_cond(char *cmd)
|
||||
return command[c].cb(arg);
|
||||
}
|
||||
|
||||
fallback:
|
||||
return do_cond_show(NULL);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ static int do_edit(char *arg, int creat)
|
||||
char *editor[] = {
|
||||
"sensible-editor",
|
||||
"editor",
|
||||
"${VISUAL:-${EDITOR:-$(command -v mg vi | head -1)}}"
|
||||
"${VISUAL:-${EDITOR:-$(command -v mg || command -v vi)}}"
|
||||
};
|
||||
char path[256];
|
||||
char *fn;
|
||||
|
||||
+38
-6
@@ -918,24 +918,56 @@ static void parse_name(svc_t *svc, char *arg)
|
||||
*/
|
||||
static void parse_cmdline_args(svc_t *svc, char *cmd)
|
||||
{
|
||||
int i;
|
||||
char sep = 0;
|
||||
char *arg;
|
||||
int i = 0;
|
||||
|
||||
strlcpy(svc->args[0], cmd, sizeof(svc->args[0]));
|
||||
strlcpy(svc->args[i++], cmd, sizeof(svc->args[0]));
|
||||
|
||||
while (i < MAX_NUM_SVC_ARGS)
|
||||
svc->args[i++][0] = 0;
|
||||
|
||||
/*
|
||||
* Copy supplied args. Stop at MAX_NUM_SVC_ARGS-1 to allow the args
|
||||
* array to be zero-terminated.
|
||||
*/
|
||||
for (i = 1; (arg = strtok(NULL, " ")) && i < (MAX_NUM_SVC_ARGS - 1); i++)
|
||||
strlcpy(svc->args[i], arg, sizeof(svc->args[0]));
|
||||
for (i = 1; (arg = strtok(NULL, " ")) && i < (MAX_NUM_SVC_ARGS - 1);) {
|
||||
char ch = arg[0];
|
||||
size_t len;
|
||||
|
||||
/* XXX: ugly string arg re-concatenation, fixme */
|
||||
if (ch == '"' || ch == '\'')
|
||||
sep = ch;
|
||||
else if (sep)
|
||||
strlcat(svc->args[i], " ", sizeof(svc->args[0]));
|
||||
|
||||
strlcat(svc->args[i], arg, sizeof(svc->args[0]));
|
||||
|
||||
/* string arg contained already? */
|
||||
len = strlen(arg);
|
||||
if (sep && len >= 1) {
|
||||
ch = arg[len - 1];
|
||||
if (ch != sep)
|
||||
continue;
|
||||
}
|
||||
|
||||
sep = 0;
|
||||
i++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear remaining args in case they were set earlier.
|
||||
* This also zero-terminates the args array.
|
||||
*/
|
||||
for (; i < MAX_NUM_SVC_ARGS; i++)
|
||||
svc->args[i][0] = 0;
|
||||
while (i < MAX_NUM_SVC_ARGS)
|
||||
svc->args[i++][0] = 0;
|
||||
#if 0
|
||||
for (i = 0; i < MAX_NUM_SVC_ARGS; i++) {
|
||||
if (!svc->args[i][0])
|
||||
break;
|
||||
_d("%s ", svc->args[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,6 @@ fi
|
||||
mkdir -p "$FINIT_RCSD"
|
||||
|
||||
tty=/dev/$(cat /sys/class/tty/console/active)
|
||||
mkfifo "$tty"
|
||||
ln -fs /shared/pts "$tty"
|
||||
|
||||
exec "$@"
|
||||
|
||||
@@ -138,7 +138,3 @@ echo "$finit_ppid" > "$TENV_ROOT"/running_test.pid
|
||||
log "$color_reset" 'Setup of test environment done' ''
|
||||
|
||||
finit_pid=$(retry "pgrep -P $finit_ppid")
|
||||
|
||||
tty=/dev/$(texec cat /sys/class/tty/console/active)
|
||||
texec cat "$tty" &
|
||||
sleep 1
|
||||
|
||||
@@ -38,6 +38,7 @@ binaries = $(DEST)/bin/cat \
|
||||
$(DEST)/bin/env \
|
||||
$(DEST)/bin/find \
|
||||
$(DEST)/bin/kill \
|
||||
$(DEST)/bin/ln \
|
||||
$(DEST)/bin/ls \
|
||||
$(DEST)/bin/mkdir \
|
||||
$(DEST)/bin/mkfifo \
|
||||
@@ -57,6 +58,7 @@ dirs = $(DEST)/bin \
|
||||
$(DEST)/etc \
|
||||
$(DEST)/proc \
|
||||
$(DEST)/sbin \
|
||||
$(DEST)/shared \
|
||||
$(DEST)/sys \
|
||||
$(DEST)/test_assets \
|
||||
$(DEST)/tmp
|
||||
|
||||
+4
-1
@@ -45,4 +45,7 @@ exec "$unshare" \
|
||||
--mount \
|
||||
--mount-proc \
|
||||
--uts --ipc --net \
|
||||
"$chroot" "$TENV_ROOT" /bin/chrootsetup.sh "$@"
|
||||
sh -c "
|
||||
ln -fs /proc/1/fd/1 $TENV_ROOT/shared/pts;
|
||||
exec $chroot $TENV_ROOT /bin/chrootsetup.sh $*
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user