6 Commits
v1.1 ... v1.2

Author SHA1 Message Date
Prokopenko Andrey
dc72f24c43 removed double quoting from zpool statements 2021-11-25 23:37:05 +01:00
Prokopenko Andrey
f2331df185 zpool options update for debian 2021-11-25 22:27:06 +01:00
Andrey Prokopenko
effc9964ee shellcheck code fixes 2021-11-18 20:22:53 +01:00
terem42
c1391bb65f Update shellcheck.yml 2021-09-25 12:10:32 +02:00
Andrey Prokopenko
e322cf49b4 modified permissions 2021-09-25 12:08:54 +02:00
Andrey Prokopenko
762993e7e8 updated shellcheck workflow 2021-09-25 12:04:16 +02:00
6 changed files with 79 additions and 41 deletions

View File

@@ -1,24 +1,11 @@
name: shellcheck name: shellcheck
on: on: push
push:
branches: [master, develop]
pull_request:
branches: [master]
jobs: jobs:
Shellcheck: test:
name: Shellcheck
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Code checkout - uses: actions/checkout@v2
uses: actions/checkout@v2 - name: Run shellcheck
run: ci/run_shellcheck.sh
- name: Check scripts with Shellcheck
uses: essentialkaos/shellcheck-action@v1
with:
files: hetzner-debian10-zfs-setup.sh hetzner-debian11-zfs-setup.sh hetzner-ubuntu18-zfs-setup.sh hetzner-ubuntu20-zfs-setup.sh
severity: error
format: gcc
shell: bash

25
ci/run_shellcheck.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -o pipefail
set -o errexit
set -o nounset
set -o errtrace
shopt -s inherit_errexit
# Always download the latest version:
#
# - it's fast and stable enough not to worry about it;
# - the workflow is basically single-person, so there's no risk of a new dev encountering an error found
# by a new shellcheck version.
mkdir -p /opt/shellcheck
wget -qO- https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz \
| tar xJv -O shellcheck-stable/shellcheck \
> /opt/shellcheck/shellcheck
chmod +x /opt/shellcheck/shellcheck
/opt/shellcheck/shellcheck --version
grep -lZP '^#!/bin/\w+sh' -R | xargs -0 /opt/shellcheck/shellcheck

View File

@@ -62,7 +62,9 @@ function print_step_info_header {
############################################################################### ###############################################################################
# ${FUNCNAME[1]}" # ${FUNCNAME[1]}"
[[ "${1:-}" != "" ]] && echo -n " $1" || true if [[ "${1:-}" != "" ]]; then
echo -n " $1"
fi
echo " echo "
############################################################################### ###############################################################################
@@ -141,13 +143,13 @@ function initial_load_debian_zed_cache {
local success=0 local success=0
if [[ ! -e /mnt/etc/zfs/zfs-list.cache/rpool ]] || [[ -e /mnt/etc/zfs/zfs-list.cache/rpool && (( $(ls -l /mnt/etc/zfs/zfs-list.cache/rpool 2> /dev/null | cut -d ' ' -f 5) == 0 )) ]]; then if [[ ! -e /mnt/etc/zfs/zfs-list.cache/rpool ]] || [[ -e /mnt/etc/zfs/zfs-list.cache/rpool && (( $(find /mnt/etc/zfs/zfs-list.cache/rpool -type f -printf '%s' 2> /dev/null) == 0 )) ]]; then
chroot_execute "zfs set canmount=noauto rpool" chroot_execute "zfs set canmount=noauto rpool"
SECONDS=0 SECONDS=0
while (( SECONDS++ <= 120 )); do while (( SECONDS++ <= 120 )); do
if [[ -e /mnt/etc/zfs/zfs-list.cache/rpool ]] && (( "$(ls -l /mnt/etc/zfs/zfs-list.cache/rpool | cut -d ' ' -f 5)" > 0 )); then if [[ -e /mnt/etc/zfs/zfs-list.cache/rpool ]] && (( $(find /mnt/etc/zfs/zfs-list.cache/rpool -type f -printf '%s' 2> /dev/null) > 0 )); then
success=1 success=1
break break
else else
@@ -432,8 +434,7 @@ function unmount_and_export_fs {
echo "===========exporting zfs pools=============" echo "===========exporting zfs pools============="
set +e set +e
while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do
zpool export -a 2> /dev/null if zpool export -a 2> /dev/null; then
if [[ $? == 0 ]]; then
zpools_exported=1 zpools_exported=1
echo "all zfs pools were succesfully exported" echo "all zfs pools were succesfully exported"
break; break;
@@ -540,12 +541,14 @@ echo "======= create zfs pools and datasets =========="
pools_mirror_option= pools_mirror_option=
fi fi
# shellcheck disable=SC2086
zpool create \ zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \ "$v_bpool_tweaks" -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \ -O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}" $v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"
# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \ echo -n "$v_passphrase" | zpool create \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
$v_rpool_tweaks \ $v_rpool_tweaks \
@@ -838,7 +841,9 @@ chroot_execute "zfs set mountpoint=legacy $v_rpool_name/tmp"
chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab" chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab"
echo "========= add swap, if defined" echo "========= add swap, if defined"
[[ $v_swap_size -gt 0 ]] && chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab" || true if [[ $v_swap_size -gt 0 ]]; then
chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab"
fi
chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume" chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume"
echo "======= unmounting filesystems and zfs pools ==========" echo "======= unmounting filesystems and zfs pools =========="

View File

@@ -62,7 +62,10 @@ function print_step_info_header {
############################################################################### ###############################################################################
# ${FUNCNAME[1]}" # ${FUNCNAME[1]}"
[[ "${1:-}" != "" ]] && echo -n " $1" || true if [[ "${1:-}" != "" ]]; then
echo -n " $1"
fi
echo " echo "
############################################################################### ###############################################################################
@@ -141,13 +144,13 @@ function initial_load_debian_zed_cache {
local success=0 local success=0
if [[ ! -e /mnt/etc/zfs/zfs-list.cache/rpool ]] || [[ -e /mnt/etc/zfs/zfs-list.cache/rpool && (( $(ls -l /mnt/etc/zfs/zfs-list.cache/rpool 2> /dev/null | cut -d ' ' -f 5) == 0 )) ]]; then if [[ ! -e /mnt/etc/zfs/zfs-list.cache/rpool ]] || [[ -e /mnt/etc/zfs/zfs-list.cache/rpool && (( $(find /mnt/etc/zfs/zfs-list.cache/rpool -type f -printf '%s' 2> /dev/null) == 0 )) ]]; then
chroot_execute "zfs set canmount=noauto rpool" chroot_execute "zfs set canmount=noauto rpool"
SECONDS=0 SECONDS=0
while (( SECONDS++ <= 120 )); do while (( SECONDS++ <= 120 )); do
if [[ -e /mnt/etc/zfs/zfs-list.cache/rpool ]] && (( "$(ls -l /mnt/etc/zfs/zfs-list.cache/rpool | cut -d ' ' -f 5)" > 0 )); then if [[ -e /mnt/etc/zfs/zfs-list.cache/rpool ]] && (( $(find /mnt/etc/zfs/zfs-list.cache/rpool -type f -printf '%s' 2> /dev/null) > 0 )); then
success=1 success=1
break break
else else
@@ -432,8 +435,7 @@ function unmount_and_export_fs {
echo "===========exporting zfs pools=============" echo "===========exporting zfs pools============="
set +e set +e
while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do
zpool export -a 2> /dev/null if zpool export -a 2> /dev/null; then
if [[ $? == 0 ]]; then
zpools_exported=1 zpools_exported=1
echo "all zfs pools were succesfully exported" echo "all zfs pools were succesfully exported"
break; break;
@@ -540,12 +542,14 @@ echo "======= create zfs pools and datasets =========="
pools_mirror_option= pools_mirror_option=
fi fi
# shellcheck disable=SC2086
zpool create \ zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \ $v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \ -O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}" $v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"
# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \ echo -n "$v_passphrase" | zpool create \
$v_rpool_tweaks \ $v_rpool_tweaks \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
@@ -842,7 +846,10 @@ chroot_execute "zfs set mountpoint=legacy $v_rpool_name/tmp"
chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab" chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab"
echo "========= add swap, if defined" echo "========= add swap, if defined"
[[ $v_swap_size -gt 0 ]] && chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab" || true if [[ $v_swap_size -gt 0 ]]; then
chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab"
fi
chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume" chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume"
echo "======= unmounting filesystems and zfs pools ==========" echo "======= unmounting filesystems and zfs pools =========="

View File

@@ -62,7 +62,9 @@ function print_step_info_header {
############################################################################### ###############################################################################
# ${FUNCNAME[1]}" # ${FUNCNAME[1]}"
[[ "${1:-}" != "" ]] && echo -n " $1" || true if [[ "${1:-}" != "" ]]; then
echo -n " $1"
fi
echo " echo "
############################################################################### ###############################################################################
@@ -399,8 +401,8 @@ function unmount_and_export_fs {
echo "===========exporting zfs pools=============" echo "===========exporting zfs pools============="
set +e set +e
while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do
zpool export -a 2> /dev/null
if [[ $? == 0 ]]; then if zpool export -a 2> /dev/null; then
zpools_exported=1 zpools_exported=1
echo "all zfs pools were succesfully exported" echo "all zfs pools were succesfully exported"
break; break;
@@ -507,12 +509,14 @@ echo "======= create zfs pools and datasets =========="
pools_mirror_option= pools_mirror_option=
fi fi
# shellcheck disable=SC2086
zpool create \ zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \ $v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \ -O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}" $v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"
# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \ echo -n "$v_passphrase" | zpool create \
$v_rpool_tweaks \ $v_rpool_tweaks \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
@@ -830,7 +834,10 @@ chroot_execute "zfs set mountpoint=legacy $v_rpool_name/tmp"
chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab" chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab"
echo "========= add swap, if defined" echo "========= add swap, if defined"
[[ $v_swap_size -gt 0 ]] && chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab" || true if [[ $v_swap_size -gt 0 ]]; then
chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab"
fi
chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume" chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume"
echo "======= unmounting filesystems and zfs pools ==========" echo "======= unmounting filesystems and zfs pools =========="

View File

@@ -62,7 +62,9 @@ function print_step_info_header {
############################################################################### ###############################################################################
# ${FUNCNAME[1]}" # ${FUNCNAME[1]}"
[[ "${1:-}" != "" ]] && echo -n " $1" || true if [[ "${1:-}" != "" ]]; then
echo -n " $1"
fi
echo " echo "
############################################################################### ###############################################################################
@@ -399,8 +401,8 @@ function unmount_and_export_fs {
echo "===========exporting zfs pools=============" echo "===========exporting zfs pools============="
set +e set +e
while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do while (( zpools_exported == 99 )) && (( SECONDS++ <= 60 )); do
zpool export -a 2> /dev/null
if [[ $? == 0 ]]; then if zpool export -a 2> /dev/null; then
zpools_exported=1 zpools_exported=1
echo "all zfs pools were succesfully exported" echo "all zfs pools were succesfully exported"
break; break;
@@ -507,12 +509,14 @@ echo "======= create zfs pools and datasets =========="
pools_mirror_option= pools_mirror_option=
fi fi
# shellcheck disable=SC2086
zpool create \ zpool create \
$v_bpool_tweaks -O canmount=off -O devices=off \ $v_bpool_tweaks -O canmount=off -O devices=off \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
-O mountpoint=/boot -R $c_zfs_mount_dir -f \ -O mountpoint=/boot -R $c_zfs_mount_dir -f \
$v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}" $v_bpool_name $pools_mirror_option "${bpool_disks_partitions[@]}"
# shellcheck disable=SC2086
echo -n "$v_passphrase" | zpool create \ echo -n "$v_passphrase" | zpool create \
$v_rpool_tweaks \ $v_rpool_tweaks \
-o cachefile=/etc/zfs/zpool.cache \ -o cachefile=/etc/zfs/zpool.cache \
@@ -831,7 +835,10 @@ chroot_execute "zfs set mountpoint=legacy $v_rpool_name/tmp"
chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab" chroot_execute "echo $v_rpool_name/tmp /tmp zfs nodev,relatime 0 0 >> /etc/fstab"
echo "========= add swap, if defined" echo "========= add swap, if defined"
[[ $v_swap_size -gt 0 ]] && chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab" || true if [[ $v_swap_size -gt 0 ]]; then
chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab"
fi
chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume" chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume"
echo "======= unmounting filesystems and zfs pools ==========" echo "======= unmounting filesystems and zfs pools =========="