Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Commit 5264fea

Browse files
committed
Tidy up regexes
1 parent f0548e1 commit 5264fea

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

root/etc/s6-overlay/s6-rc.d/init-pmm-oneshot/run

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cd / || exit 1
55
# halt startup if no config file is found
66
if [[ -n ${PMM_CONFIG} ]]; then
77
CONFIG_FILE=${PMM_CONFIG}
8-
elif echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--config|-c)([^\S])(.+\/[^\/]+)\.(yml|yaml)'; then
9-
CONFIG_FILE=$(echo "${CLI_OPTIONS}" | grep -Po '[\s]?(--config|-c)([^\S])\K(.+\/[^\/]+)\.(yml|yaml)')
8+
elif echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--config|-c)([\s])(.+\/[^\/]+)\.(yml|yaml)'; then
9+
CONFIG_FILE=$(echo "${CLI_OPTIONS}" | grep -Po '([\s]|^)(--config|-c)([\s])\K(.+\/[^\/]+)\.(yml|yaml)')
1010
else
1111
CONFIG_FILE="/config/config.yml"
1212
fi
@@ -16,11 +16,11 @@ if [[ -n "${CONFIG_FILE}" ]] && [[ ! -e "${CONFIG_FILE}" ]]; then
1616
s6-rc -bad change
1717
fi
1818

19-
if { echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--run|-r)([^\S]|$)'; } && { echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--config|-c)([^\S])(.+\/[^\/]+)\.(yml|yaml)'; }; then
19+
if { echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--run|-r)([\s]|$)'; } && { echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--config|-c)([\s])(.+\/[^\/]+)\.(yml|yaml)'; }; then
2020
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py ${CLI_OPTIONS}
21-
elif echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--run|-r)([^\S]|$)'; then
21+
elif echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--run|-r)([\s]|$)'; then
2222
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py --config "${CONFIG_FILE}" ${CLI_OPTIONS}
23-
elif echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--config|-c)([^\S])(.+\/[^\/]+)\.(yml|yaml)'; then
23+
elif echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--config|-c)([\s])(.+\/[^\/]+)\.(yml|yaml)'; then
2424
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py --run ${CLI_OPTIONS}
2525
else
2626
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py --run --config "${CONFIG_FILE}" ${CLI_OPTIONS}

root/etc/s6-overlay/s6-rc.d/svc-pmm/run

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cd / || exit 1
55
# halt startup if no config file is found
66
if [[ -n ${PMM_CONFIG} ]]; then
77
CONFIG_FILE=${PMM_CONFIG}
8-
elif echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--config|-c)([^\S])(.+\/[^\/]+)\.(yml|yaml)'; then
9-
CONFIG_FILE=$(echo "${CLI_OPTIONS}" | grep -Po '[\s]?(--config|-c)([^\S])\K(.+\/[^\/]+)\.(yml|yaml)')
8+
elif echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--config|-c)([\s])(.+\/[^\/]+)\.(yml|yaml)'; then
9+
CONFIG_FILE=$(echo "${CLI_OPTIONS}" | grep -Po '([\s]|^)(--config|-c)([\s])\K(.+\/[^\/]+)\.(yml|yaml)')
1010
else
1111
CONFIG_FILE="/config/config.yml"
1212
fi
@@ -16,13 +16,13 @@ if [[ -n "${CONFIG_FILE}" ]] && [[ ! -e "${CONFIG_FILE}" ]]; then
1616
s6-rc -bad change
1717
fi
1818

19-
if { echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--time|-t)([^\S])'; } && { echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--config|-c)([^\S])(.+\/[^\/]+)\.(yml|yaml)'; }; then
19+
if { echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--time|-t)([\s])'; } && { echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--config|-c)([\s])(.+\/[^\/]+)\.(yml|yaml)'; }; then
2020
exec \
2121
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py ${CLI_OPTIONS}
22-
elif echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--time|-t)([^\S])'; then
22+
elif echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--time|-t)([\s])'; then
2323
exec \
2424
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py --config "${CONFIG_FILE}" ${CLI_OPTIONS}
25-
elif echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--config|-c)([^\S])(.+\/[^\/]+)\.(yml|yaml)'; then
25+
elif echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--config|-c)([\s])(.+\/[^\/]+)\.(yml|yaml)'; then
2626
exec \
2727
s6-setuidgid abc python3 /app/pmm/plex_meta_manager.py --time "${PMM_TIME:-03:00}" ${CLI_OPTIONS}
2828
else

root/init-hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/with-contenv bash
22

3-
if [[ $(tr "[:upper:]" "[:lower:]" <<<"${PMM_RUN}") = "true" ]] || echo "${CLI_OPTIONS}" | grep -qPo '[\s]?(--run|-r)([^\S]|$)'; then
3+
if [[ $(tr "[:upper:]" "[:lower:]" <<<"${PMM_RUN}") = "true" ]] || echo "${CLI_OPTIONS}" | grep -qPo '([\s]|^)(--run|-r)([\s]|$)'; then
44
rm -rf /etc/s6-overlay/s6-rc.d/svc-pmm
55
rm -rf /etc/s6-overlay/s6-rc.d/user/contents.d/svc-pmm
66
rm -rf /etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-pmm-config

0 commit comments

Comments
 (0)