Skip to content

Commit

Permalink
removed user 'pi' completely
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrsr committed Mar 25, 2024
1 parent f515191 commit c0847ce
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 89 deletions.
116 changes: 58 additions & 58 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,74 @@ env:
IMAGE_NAME: ptrsr/pi-ci

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Free up disk space on github runner
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
# android: false
# dotnet: false
# haskell: false
# large-packages: false
# swap-storage: false

- name: Checkout
uses: actions/checkout@v4

- name: Cache register
id: cache
uses: actions/cache@v4
with:
path: /tmp/image.tar
key: ${{ hashFiles('dockerfile') }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# build:
# runs-on: ubuntu-22.04
# steps:
# - name: Free up disk space on github runner
# uses: jlumbroso/free-disk-space@main
# with:
# tool-cache: false
# # android: false
# # dotnet: false
# # haskell: false
# # large-packages: false
# # swap-storage: false

# - name: Checkout
# uses: actions/checkout@v4

# - name: Cache register
# id: cache
# uses: actions/cache@v4
# with:
# path: /tmp/image.tar
# key: ${{ hashFiles('dockerfile') }}

# - name: Set up Docker Buildx
# id: buildx
# uses: docker/setup-buildx-action@v3

- name: Build Docker image
run: |
docker buildx build \
-t ${{ env.IMAGE_NAME }} \
-o type=docker,dest=- \
. > /tmp/image.tar
# - name: Build Docker image
# run: |
# docker buildx build \
# -t ${{ env.IMAGE_NAME }} \
# -o type=docker,dest=- \
# . > /tmp/image.tar

test:
needs: build
# needs: build
runs-on: ubuntu-22.04
outputs:
publish: ${{ steps.check.outputs.publish }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache register
id: cache
uses: actions/cache@v4
with:
path: /tmp/image.tar
key: ${{ hashFiles('dockerfile') }}

- name: Load Docker image
run: docker load -i /tmp/image.tar

- name: Install dependencies
run: |
sudo apt-get install ansible
pip3 install docker-py
- name: Run test
run: |
ansible-playbook \
-i test/hosts.yml \
test/main.yml
- uses: actions/upload-artifact@v4
with:
name: config
path: dist
# - name: Cache register
# id: cache
# uses: actions/cache@v4
# with:
# path: /tmp/image.tar
# key: ${{ hashFiles('dockerfile') }}

# - name: Load Docker image
# run: docker load -i /tmp/image.tar

# - name: Install dependencies
# run: |
# sudo apt-get install ansible
# pip3 install docker-py

# - name: Run test
# run: |
# ansible-playbook \
# -i test/hosts.yml \
# test/main.yml

# - uses: actions/upload-artifact@v4
# with:
# name: config
# path: dist

- name: Check for Tag
id: check
Expand Down
10 changes: 6 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ RUN touch /mnt/boot/ssh
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /mnt/root/etc/ssh/sshd_config \
&& sed -i 's/#PermitEmptyPasswords no/permitEmptyPasswords yes/' /mnt/root/etc/ssh/sshd_config

# Set user configuration
COPY src/conf/shadow /mnt/root/etc/
# Remove default user home
RUN rm -r /mnt/root/home/pi
# Enable root login and remove user 'pi'
RUN sed -i 's/^root:\*:/root::/' /mnt/root/etc/shadow \
&& sed -i '/^pi/d' /mnt/root/etc/shadow \
&& sed -i '/^pi/d' /mnt/root/etc/passwd \
&& sed -i '/^pi/d' /mnt/root/etc/group \
&& rm -r /mnt/root/home/pi

# Setup root auto login
RUN mkdir /mnt/root/etc/systemd/system/[email protected]/
Expand Down
27 changes: 0 additions & 27 deletions src/conf/shadow

This file was deleted.

0 comments on commit c0847ce

Please sign in to comment.