summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-01-24 11:29:47 +0000
committerLaurent Bercot <ska@appnovation.com>2022-01-24 11:29:47 +0000
commit4c4e732c0202dd283d6b5822956787ceefc0f5a1 (patch)
treefefc5ee2b54e1138e57c6a8965b574559b6a102b
parentee97396929ce61ce32cbd3a620f42c5aa98d2651 (diff)
downloads6-linux-init-4c4e732c0202dd283d6b5822956787ceefc0f5a1.tar.xz
Better usage message for telinit when invoked as init
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/init/s6-linux-init-telinit.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/init/s6-linux-init-telinit.c b/src/init/s6-linux-init-telinit.c
index 65fb491..ef99e5f 100644
--- a/src/init/s6-linux-init-telinit.c
+++ b/src/init/s6-linux-init-telinit.c
@@ -15,12 +15,23 @@
#include "initctl.h"
#define USAGE "s6-linux-init-telinit runlevel"
-#define dieusage() strerr_dieusage(100, USAGE)
+#define USAGE1 "(as pid 1) s6-linux-init [ -c basedir ] [ -p initpath ] [ -s envdumpdir ] [ -m umask ] [ -d devtmpfs ] [ -D initdefault ] [ -n | -N ] [ -C ] [ -B ] stage2_args..."
int main (int argc, char const *const *argv, char const *const *envp)
{
char const *newargv[8] = { S6_EXTBINPREFIX "s6-sudo", "-e", "-T", "3600000", "--", RUNLEVELD_PATH, 0, 0 } ;
- PROG = "s6-linux-init-telinit" ;
+ char const *usage = strrchr(argv[0], '/') ;
+ if (usage) usage++ ; else usage = argv[0] ;
+ if (!strcmp(usage, "init") || !strcmp(usage, "s6-linux-init"))
+ {
+ usage = USAGE1 ;
+ PROG = "s6-linux-init" ;
+ }
+ else
+ {
+ usage = USAGE ;
+ PROG = "s6-linux-init-telinit" ;
+ }
{
subgetopt l = SUBGETOPT_ZERO ;
for (;;)
@@ -40,13 +51,13 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'C' :
case 'B' :
break ;
- default : dieusage() ;
+ default : strerr_dieusage(100, usage) ;
}
}
argc -= l.ind ; argv += l.ind ;
}
- if (!argc) dieusage() ;
+ if (!argc) strerr_dieusage(100, usage) ;
newargv[6] = argv[0] ;