Skip to content

Commit

Permalink
Add formatting and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
luther7 committed Sep 11, 2024
1 parent 3207f9a commit 5fb4390
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 20 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Lint
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: ./scripts/lint-all
6 changes: 6 additions & 0 deletions scripts/format-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

./scripts/format-terraform
./scripts/format-shell-scripts
5 changes: 5 additions & 0 deletions scripts/format-shell-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

shfmt --write .
5 changes: 5 additions & 0 deletions scripts/format-terraform
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

terraform fmt -recursive
6 changes: 6 additions & 0 deletions scripts/lint-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

./scripts/lint-terraform
./scripts/lint-shell-scripts
7 changes: 7 additions & 0 deletions scripts/lint-shell-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

shellcheck --exclude=SC1091 terraform/setup.bash
find scripts -type f -exec shellcheck --exclude=SC1091 {} \;
shfmt --diff .
5 changes: 5 additions & 0 deletions scripts/lint-terraform
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

terraform fmt -recursive -check
38 changes: 18 additions & 20 deletions terraform/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ curl \
--silent \
--show-error \
--location \
https://tailscale.com/install.sh \
| sh
cat <<EOF > /etc/sysctl.d/99-tailscale.conf
https://tailscale.com/install.sh |
sh
cat <<EOF >/etc/sysctl.d/99-tailscale.conf
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
EOF
Expand All @@ -32,30 +32,28 @@ tailscale serve --bg 8082

echo "--> Mount storage volume"
# shellcheck disable=SC2154
storage_name=$( \
storage_name=$(
lsblk \
--output name,size \
| grep "${storage_volume_size}G" \
| awk '{ print $1 }' \
--output name,size |
grep "${storage_volume_size}G" |
awk '{ print $1 }'
)
# shellcheck disable=SC2154
storage_uuid=$( \
storage_uuid=$(
lsblk \
--output name,size,UUID \
| grep "${storage_volume_size}G" \
| awk '{ print $3 }' \
--output name,size,UUID |
grep "${storage_volume_size}G" |
awk '{ print $3 }'
)
if ! \
file \
if ! file \
--special-files \
--dereference \
"/dev/$storage_name" \
| grep --silent ext4; \
then
"/dev/$storage_name" |
grep --silent ext4; then
mkfs.ext4 "/dev/$storage_name"
fi
mkdir /storage
echo "UUID=$storage_uuid /storage ext4 defaults,nofail 0 2" >> /etc/fstab
echo "UUID=$storage_uuid /storage ext4 defaults,nofail 0 2" >>/etc/fstab
systemctl daemon-reload
mount "/dev/$storage_name" /storage
mount --all
Expand All @@ -70,9 +68,9 @@ curl \
--show-error \
--location \
https://github.com/containers/common/raw/main/pkg/seccomp/seccomp.json \
> /etc/containers/seccomp.json
>/etc/containers/seccomp.json
mkdir --parents /home/ubuntu/.config/containers/
cat <<EOF > /home/ubuntu/.config/containers/storage.conf
cat <<EOF >/home/ubuntu/.config/containers/storage.conf
[storage]
driver = "overlay"
runroot = "/run/user/1000/containers"
Expand All @@ -92,7 +90,7 @@ systemctl --machine=ubuntu@ --user --now enable podman.socket

echo "--> Install and start traccar systemd unit"
mkdir --parents /home/ubuntu/.config/containers/systemd
cat <<EOF > /home/ubuntu/.config/containers/systemd/traccar.kube
cat <<EOF >/home/ubuntu/.config/containers/systemd/traccar.kube
[Install]
WantedBy=default.target
Expand Down

0 comments on commit 5fb4390

Please sign in to comment.