Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1079773
Consistency
theseal Nov 25, 2025
bdd5fed
Shellcheck and shfmt
theseal Nov 25, 2025
aaccee1
shellcheck and shfmt
theseal Nov 25, 2025
6fdd4c7
shellcheck and shfmt
theseal Nov 25, 2025
3cb5e46
shellcheck and shfmt
theseal Nov 25, 2025
7b479df
shellcheck and shfmt
theseal Nov 25, 2025
3943774
shellcheck and shfmt
theseal Nov 25, 2025
9bc77df
shellcheck and shfmt
theseal Nov 25, 2025
d7d6afa
shellcheck and shfmt
theseal Nov 25, 2025
58ff4d8
shellcheck and shfmt
theseal Nov 25, 2025
d81c6ff
shellcheck and shfmt
theseal Nov 25, 2025
36c7ddd
shellcheck and shfmt
theseal Nov 25, 2025
acb8124
shellcheck and shfmt
theseal Nov 25, 2025
3e5a32a
shellcheck and shfmt
theseal Nov 25, 2025
634f5ac
shellcheck and shfmt
theseal Nov 25, 2025
624f9f0
shellcheck and shfmt
theseal Nov 25, 2025
63a13a8
shellcheck and shfmt
theseal Nov 25, 2025
0f80724
shellcheck and shfmt
theseal Nov 25, 2025
f84e680
shellcheck and shfmt
theseal Nov 26, 2025
2acc17d
Automatic shellcheck?
theseal Nov 26, 2025
4b82be4
Default branch is main
theseal Nov 26, 2025
8f7efc6
Suggestion from Sonar
theseal Nov 26, 2025
47ff356
Run shfmt aswell
theseal Nov 26, 2025
ee20d90
Variable reporter
theseal Nov 26, 2025
20e36b6
Test if shellcheck runs
theseal Nov 26, 2025
d75a049
Revert "Test if shellcheck runs"
theseal Nov 26, 2025
e955524
Try to override the default
theseal Nov 27, 2025
35d6d27
Run on PRs only
theseal Nov 27, 2025
5531e9c
Local config is not always present
theseal Nov 27, 2025
0e56a7c
Don't expand variable later on
theseal Nov 28, 2025
eea8839
Cosmos is already run at boot via crontab
theseal Nov 28, 2025
83a338d
[[ is considered safer
theseal Nov 28, 2025
d7b3488
Even more unsafe tests
theseal Nov 28, 2025
bf6865f
Syntax error
theseal Nov 28, 2025
d2d13a7
Missed another unsafe test
theseal Nov 28, 2025
485f1fb
File is no longer created
theseal Nov 28, 2025
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
21 changes: 21 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: shellcheck
on:
pull_request:
branches: [ "main" ]
jobs:
shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1
id: reporter
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: "github-pr-review"
if_false: "github-check"
- name: shellcheck
uses: reviewdog/action-shellcheck@4c07458293ac342d477251099501a718ae5ef86e # v1.32.0
with:
reporter: ${{ steps.reporter.outputs.value }}
check_all_files_with_shebangs: "true"
11 changes: 11 additions & 0 deletions .github/workflows/shfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: shfmt
on: [pull_request]
jobs:
shfmt:
name: runner / shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: reviewdog/action-shfmt@d8f080930b9be5847b4f97e9f4122b81a82aaeac # v1.0.4
with:
shfmt_flags: ""
73 changes: 43 additions & 30 deletions addhost
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,53 @@ cmd_do_bootstrap="no"
cmd_fqdn=""

function usage() {
echo "Usage: $0 [-h] [-b] [-n fqdn] [--] [<host>]"
echo " -h show help"
echo " -b bootstrap <host> (using ssh)"
echo " -n specify FQDN (if not the same as <host>)"
echo ""
echo " <host> can be an IP number, or something that resolves to one"
echo "Usage: $0 [-h] [-b] [-n fqdn] [--] [<host>]"
echo " -h show help"
echo " -b bootstrap <host> (using ssh)"
echo " -n specify FQDN (if not the same as <host>)"
echo ""
echo " <host> can be an IP number, or something that resolves to one"
}

while getopts "bhn:p:" this; do
case "${this}" in
h) usage; exit 0;;
b) cmd_do_bootstrap="yes" ;;
n) cmd_fqdn="${OPTARG}" ;;
p) cmd_proxy="${OPTARG}" ;;
*) echo "Unknown option ${this}"; echo ""; usage; exit 1;;
esac
case "${this}" in
h)
usage
exit 0
;;
b) cmd_do_bootstrap="yes" ;;
n) cmd_fqdn="${OPTARG}" ;;
p) cmd_proxy="${OPTARG}" ;;
*)
echo "Unknown option ${this}"
echo ""
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
shift $((OPTIND - 1))

if [[ ! $cmd_hostname ]]; then
cmd_hostname="$1"
cmd_hostname="$1"
fi

if [[ ! $cmd_fqdn ]]; then
cmd_fqdn="$cmd_hostname"
cmd_fqdn="$cmd_hostname"
fi

if test -z "$cmd_hostname"; then
usage
exit 1
usage
exit 1
fi

proxyjump=()
if [[ -n $cmd_proxy ]]; then
proxyjump="-o ProxyJump=${cmd_proxy}"
proxyjump+=("-o")
proxyjump+=("ProxyJump=${cmd_proxy}i")
fi

# shellcheck source=/dev/null
test -f cosmos.conf && . ./cosmos.conf

_remote=${remote:='ro'}
Expand All @@ -49,21 +60,23 @@ rrepo=${repo:="$defrepo"}
rtag=${tag:="changeme"}

if [[ ! $rrepo ]]; then
echo "$0: repo not set in cosmos.conf and no git remote named '${_remote}' found"
exit 1
echo "$0: repo not set in cosmos.conf and no git remote named '${_remote}' found"
exit 1
fi

if [ ! -d "$cmd_fqdn" ]; then
cp -pr default "$cmd_fqdn"
git add "$cmd_fqdn"
git commit -m "$cmd_fqdn added" "$cmd_fqdn"
./bump-tag
cp -pr default "$cmd_fqdn"
git add "$cmd_fqdn"
git commit -m "$cmd_fqdn added" "$cmd_fqdn"
./bump-tag
fi

if [ "$cmd_do_bootstrap" = "yes" ]; then
cosmos_deb=$(find apt/ -maxdepth 1 -name 'cosmos_*.deb' | sort -V | tail -1)
scp $proxyjump "$cosmos_deb" apt/bootstrap-cosmos.sh root@"$cmd_hostname":
ssh root@"$cmd_hostname" $proxyjump ./bootstrap-cosmos.sh "$cmd_fqdn" "$rrepo" "$rtag"
ssh root@"$cmd_hostname" $proxyjump cosmos update
ssh root@"$cmd_hostname" $proxyjump cosmos apply
cosmos_deb=$(find apt/ -maxdepth 1 -name 'cosmos_*.deb' | sort -V | tail -1)
scp "${proxyjump[@]}" "$cosmos_deb" apt/bootstrap-cosmos.sh root@"$cmd_hostname":
# We want to expand the variables on clientside - shellcheck ignore
# shellcheck disable=SC2029
ssh root@"$cmd_hostname" "${proxyjump[@]}" ./bootstrap-cosmos.sh "$cmd_fqdn" "$rrepo" "$rtag"
ssh root@"$cmd_hostname" "${proxyjump[@]}" cosmos update
ssh root@"$cmd_hostname" "${proxyjump[@]}" cosmos apply
fi
Loading
Loading