aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-line-length.bash2
-rwxr-xr-xscripts/docker-pid1.bash23
-rwxr-xr-xscripts/docker-run.bash19
-rwxr-xr-xscripts/docker.bash9
4 files changed, 52 insertions, 1 deletions
diff --git a/scripts/check-line-length.bash b/scripts/check-line-length.bash
index c6a040d..3dd4cd1 100755
--- a/scripts/check-line-length.bash
+++ b/scripts/check-line-length.bash
@@ -6,6 +6,8 @@ set -o pipefail
find=(
find .
-name .git -prune -o
+ -name .log -prune -o
+ -path ./test/formatters -prune -o
-name "*.elc" -o
-type f -print
)
diff --git a/scripts/docker-pid1.bash b/scripts/docker-pid1.bash
new file mode 100755
index 0000000..cee0dff
--- /dev/null
+++ b/scripts/docker-pid1.bash
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cat <<"EOF" > /etc/sudoers.d/apheleia
+%sudo ALL=(ALL:ALL) NOPASSWD: ALL
+EOF
+
+groupadd -g "$(stat -c %g "$PWD")" -o -p '!' -r apheleia
+useradd -u "$(stat -c %u "$PWD")" -g "$(stat -c %g "$PWD")" \
+ -o -p '!' -m -N -l -s /usr/bin/bash -G sudo apheleia
+
+runuser -u apheleia touch /home/apheleia/.sudo_as_admin_successful
+
+if (( "$#" == 0 )) || [[ -z "$1" ]]; then
+ set -- bash
+fi
+
+if (( "$#" == 1 )) && [[ "$1" == *" "* ]]; then
+ set -- bash -c "$1"
+fi
+
+exec runuser -u apheleia -- "$@"
diff --git a/scripts/docker-run.bash b/scripts/docker-run.bash
new file mode 100755
index 0000000..e7de1f4
--- /dev/null
+++ b/scripts/docker-run.bash
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+repo="$(git rev-parse --show-toplevel)"
+
+docker=(docker)
+if [[ "$OSTYPE" != darwin* ]] && [[ "$EUID" != 0 ]]; then
+ docker=(sudo -E "${docker[@]}")
+fi
+
+it=()
+
+if [[ -t 0 ]]; then
+ it+=(-it)
+fi
+
+exec "${docker[@]}" run "${it[@]}" --rm -v "${repo}:/src" \
+ --entrypoint=/src/scripts/docker-pid1.bash "$@"
diff --git a/scripts/docker.bash b/scripts/docker.bash
index d846122..812cded 100755
--- a/scripts/docker.bash
+++ b/scripts/docker.bash
@@ -22,4 +22,11 @@ docker build . -t "apheleia:$tag" \
--build-arg "UID=$UID" \
--build-arg "VERSION=$tag"
-docker run -it --rm -v "$PWD:/home/docker/src" "apheleia:$tag" "${args[@]}"
+it=()
+
+if [[ -t 0 ]]; then
+ it+=(-it)
+fi
+
+docker run "${it[@]}" --rm -v "$PWD:/home/docker/src" \
+ "apheleia:$tag" "${args[@]}"