Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shellcheck - fix errors and add to CI #26

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ jobs:
uses: swapdisk/lvm_snapshots/.github/workflows/ansible-lint.yml@main
pylint:
uses: swapdisk/lvm_snapshots/.github/workflows/pylint.yml@main
shellcheck:
uses: swapdisk/lvm_snapshots/.github/workflows/shellcheck.yml@main
prechecks:
needs:
- ansible-lint
- pylint
- shellcheck
runs-on: ubuntu-latest
steps:
- run: >-
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ShellCheck
on:
- push
- pull_request
- workflow_call

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
8 changes: 4 additions & 4 deletions roles/bigboot/files/bigboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ parse_flags() {
do
case $i in
-d=*|--device=*)
DEVICE_NAME=(${i#*=})
DEVICE_NAME="(${i#*=})"
;;
-s=*|--size=*)
INCREMENT_BOOT_PARTITION_SIZE=(${i#*=})
INCREMENT_BOOT_PARTITION_SIZE="(${i#*=})"
;;
-b=*|--boot=*)
BOOT_PARTITION_NUMBER=(${i#*=})
BOOT_PARTITION_NUMBER="(${i#*=})"
;;
-p=*|--prefix=*)
PARTITION_PREFIX=(${i#*=})
PARTITION_PREFIX="(${i#*=})"
;;
-h)
print_help
Expand Down
1 change: 1 addition & 0 deletions roles/bigboot/files/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ check(){

install() {
inst_multiple -o /usr/bin/mount /usr/bin/umount /usr/sbin/parted /usr/bin/mktemp /usr/bin/wc /usr/bin/date /usr/bin/sed /usr/bin/awk /usr/bin/basename /usr/sbin/resize2fs /usr/sbin/tune2fs /usr/sbin/partprobe /usr/bin/numfmt /usr/sbin/lvm /usr/bin/lsblk /usr/sbin/e2fsck /usr/sbin/fdisk /usr/bin/findmnt /usr/bin/tail /usr/ /usr/sbin/xfs_growfs /usr/sbin/xfs_db
# shellcheck disable=SC2154
inst_hook pre-mount 99 "$moddir/increase-boot-partition.sh"
inst_binary "$moddir/sfdisk.static" "/usr/sbin/sfdisk"
inst_simple "$moddir/bigboot.sh" "/usr/bin/bigboot.sh"
Expand Down
1 change: 1 addition & 0 deletions roles/shrink_lv/files/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ check(){

install() {
inst_multiple -o /usr/bin/numfmt /usr/bin/findmnt /usr/bin/lsblk /usr/sbin/lvm /usr/bin/awk /usr/bin/sed /usr/bin/mktemp /usr/bin/date /usr/bin/head /usr/sbin/blockdev /usr/sbin/tune2fs /usr/sbin/resize2fs /usr/bin/cut /usr/sbin/fsadm /usr/sbin/fsck.ext4
# shellcheck disable=SC2154
inst_hook pre-mount 99 "$moddir/shrink-start.sh"
inst_simple "$moddir/shrink.sh" "/usr/bin/shrink.sh"
}
9 changes: 5 additions & 4 deletions roles/shrink_lv/files/shrink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ function get_device_name() {
}

function ensure_size_in_bytes() {
local expected_size=$(/usr/bin/numfmt --from iec "$1")
let expected_size=(${expected_size} + $VOLUME_SIZE_ALIGNMENT)/$VOLUME_SIZE_ALIGNMENT*$VOLUME_SIZE_ALIGNMENT
local expected_size
expected_size=$(/usr/bin/numfmt --from iec "$1")
(( expected_size=(expected_size+VOLUME_SIZE_ALIGNMENT)/VOLUME_SIZE_ALIGNMENT*VOLUME_SIZE_ALIGNMENT ))
echo $expected_size
}

Expand Down Expand Up @@ -163,7 +164,7 @@ function parse_flags() {
do
case $i in
-d=*|--device=*)
entries+=(${i#*=})
entries+="(${i#*=})"
;;
-h)
display_help
Expand All @@ -185,7 +186,7 @@ function parse_flags() {

function parse_entry() {
IFS=':'
read -a strarr <<< "$1"
read -ra strarr <<< "$1"

if [[ ${#strarr[@]} != 2 ]]; then
echo "Invalid device entry $1"
Expand Down