first commit
This commit is contained in:
commit
1a611dc730
19
.editorconfig
Normal file
19
.editorconfig
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset=utf-8
|
||||||
|
end_of_line=lf
|
||||||
|
trim_trailing_whitespace=true
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style=space
|
||||||
|
indent_size=2
|
||||||
|
|
||||||
|
[*.{yaml,yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[Dockerfile]
|
||||||
|
indent_style = space
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
**/.idea/
|
||||||
|
node_modules/
|
||||||
44
action.yml
Normal file
44
action.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: 'docker-fix-socket-perm'
|
||||||
|
description: 'fix docker host socket permissions'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
socket-path:
|
||||||
|
required: true
|
||||||
|
description: "location of the docker socket"
|
||||||
|
default: '/var/run/docker.sock'
|
||||||
|
workaround-group:
|
||||||
|
required: true
|
||||||
|
description: "name of the workaround group to be created (if necessary)"
|
||||||
|
default: 'hostdocker'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
SOCK_OWNER_GID=$(stat -c %g ${{ inputs.socket-path }})
|
||||||
|
echo "${{ inputs.socket-path }} is owned by gid=$SOCK_OWNER_GID"
|
||||||
|
|
||||||
|
RUNNING_AS_USER=$(whoami)
|
||||||
|
echo "${{ running as user: $RUNNING_AS_USER }}"
|
||||||
|
|
||||||
|
SUDO_PREFIX=""
|
||||||
|
if [[ "$RUNNING_AS_USER" != "root" ]]; then
|
||||||
|
echo "current user is not sudo, assuming sudo is required"
|
||||||
|
SUDO_PREFIX="sudo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if getent group $SOCK_OWNER_GID | grep -q "$RUNNING_AS_USER"; then
|
||||||
|
echo "User is already a member of $SOCK_OWNER_GID"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q -E ":$SOCK_OWNER_GID:" /etc/group; then
|
||||||
|
echo "Group for gid=$SOCK_OWNER_GID already exists, adding user to it"
|
||||||
|
$SUDO_PREFIX usermod -aG $(getent group $SOCK_OWNER_GID | cut -d: -f1) $RUNNING_AS_USER
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Group for gid=$SOCK_OWNER_GID does not exist, creating workaround group: ${{ input.workaround-group }}
|
||||||
|
$SUDO_PREFIX groupadd -g $SOCK_OWNER_GID ${{ input.workaround-group }} \
|
||||||
|
$SUDO_PREFIX usermod -aG ${{ input.workaround-group }} $RUNNING_AS_USER
|
||||||
Loading…
Reference in New Issue
Block a user