在Alpine 3.9上使用带有run-parts的正则表达式

问题描述 投票:1回答:1

我正在创建一个Docker镜像FROM alpine:3.9.2,我需要运行run-parts。我过去在ubuntu:16.04上使用了下面的脚本而没有任何问题。

 run-parts --verbose --regex '\.sh$' "$DIR"

但是,这一次,我传递给它的选项出错。即

run-parts:无法识别的选项:详细

run-parts:无法识别的选项:正则表达式

从我的下面高山3.9.2使用run-parts 4.8.6 https://pkgs.alpinelinux.org/package/edge/main/x86/run-parts应该来自debianutils https://manpages.debian.org/testing/debianutils/run-parts.8.en.html并支持verboseregex

我在这里错过了什么吗?

如何在Alpine 3.9.2上运行以.sh结尾的所有文件?

regex alpine
1个回答
2
投票

默认情况下,高山图像中有非常剪切版本的run-parts。这是繁忙的一个:

/ # which run-parts
/bin/run-parts
/ # run-parts --help
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: run-parts [-a ARG]... [-u UMASK] [--reverse] [--test] [--exit-on-error] DIRECTORY

Run a bunch of scripts in DIRECTORY

    -a ARG      Pass ARG as argument to scripts
    -u UMASK    Set UMASK before running scripts
    --reverse   Reverse execution order
    --test      Dry run
    --exit-on-error Exit if a script exits with non-zero

它只能在目录中运行一堆脚本。

如果你想使用debianutils包中的未切割的run-parts,你需要先将它安装到alpine图像:

/ # apk add --no-cache run-parts
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/1) Installing run-parts (4.8.6-r0)
Executing busybox-1.29.3-r10.trigger
OK: 6 MiB in 15 packages

现在,在高山实例中有一个完整版的run-parts

/ # which run-parts
/usr/bin/run-parts
/ # run-parts --help
Usage: run-parts [OPTION]... DIRECTORY
      --test          print script names which would run, but don't run them.
      --list          print names of all valid files (can not be used with
                      --test)
  -v, --verbose       print script names before running them.
      --report        print script names if they produce output.
      --reverse       reverse execution order of scripts.
      --exit-on-error exit as soon as a script returns with a non-zero exit
                      code.
      --lsbsysinit    validate filenames based on LSB sysinit specs.
      --new-session   run each script in a separate process session
      --regex=PATTERN validate filenames based on POSIX ERE pattern PATTERN.
  -u, --umask=UMASK   sets umask to UMASK (octal), default is 022.
  -a, --arg=ARGUMENT  pass ARGUMENT to scripts, use once for each argument.
  -V, --version       output version information and exit.
  -h, --help          display this help and exit.
© www.soinside.com 2019 - 2024. All rights reserved.